Email me

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-always

The [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.

Pedanticgroup
allowdefault level
nofixed by cargo clippy --fix
pre 1.29.0added in Rust

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

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?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ