Clippy lints / Pedantic
Clippy lint · Pedantic · checked with Clippy 0.1.99
clippy::inline_always: Checks for items annotated with #[inline(always)], unless the annotated function is empty or simply panics
What it meansChecks for items annotated with #[inline(always)], unless the annotated function is empty or simply panics. It is in the pedantic group and off by default.
Does it matter?
While there are valid uses of this annotation (and once you know when to use it, by all means allow this lint), it’s a common newbie-mistake to pepper one’s code with it. As a rule of thumb, before slapping #[inline(always)] on a function, measure if that additional function call really affects your runtime profile sufficiently to make up for the increase in compile time.
Stricter lints with some false positives. Off by default; opt in with clippy::pedantic.
How to fix it
Clippy does not fix this one automatically. Change the code by hand:
Flagged
#[inline(always)]
fn not_quite_hot_code(..) { ... }
Turn it off, or on
It is off by default. To use it, set it to warn or deny:
Whole crate (Cargo.toml)
[lints.clippy]
inline_always = "warn"In code
#![warn(clippy::inline_always)]One run
cargo clippy -- -W clippy::inline-alwaysThe [lints] table needs Rust 1.74 or newer. In a workspace, put it under [workspace.lints.clippy] and add [lints] workspace = true to each member.
Clippy's own documentation
What it does
Checks for items annotated with #[inline(always)],
unless the annotated function is empty or simply panics.
Why is this bad?
While there are valid uses of this annotation (and once
you know when to use it, by all means allow this lint), it’s a common
newbie-mistake to pepper one’s code with it.
As a rule of thumb, before slapping #[inline(always)] on a function,
measure if that additional function call really affects your runtime profile
sufficiently to make up for the increase in compile time.
Known problems
False positives, big time. This lint is meant to be deactivated by everyone doing serious performance work. This means having done the measurement.
Example
#[inline(always)]
fn not_quite_hot_code(..) { ... }
From the Clippy lint list (0.1.99), part of the Rust project, MIT or Apache-2.0. Official entry.
Related lints
- too_many_linesChecks for functions with a large amount of lines
- missing_errors_docChecks the doc comments of publicly visible functions that return a Result type and warns if there is no # Errors section
- must_use_candidateChecks for public functions that have no #[must_use] attribute, but return something not already marked must-use, have no mutable arg and mutate no statics
- inconsistent_struct_constructorstruct constructor field order is inconsistent with struct definition field order
- index_refutable_slicethis binding can be a slice pattern to avoid indexing
- inefficient_to_stringChecks for usage of .to_string() on an &&T where T implements ToString directly (like &&str or &&String)
- into_iter_without_iterThis is the opposite of the iter_without_into_iter lint. It looks for IntoIterator for (&|&mut) Type implementations without an inherent iter or iter_mut method on the type or on any of the types in its Deref chain
- invalid_upcast_comparisonsbecause of the numeric bounds on `x` prior to casting, this expression is always false
- ip_constanthand-coded well-known IP address
All 847 Clippy lints · Rust compiler errors · Cargo.toml checker
Up next
Related lintclippy::too_many_linesChecks for functions with a large amount of linesRead it next →Did this answer your question?