RS.CLIPPY.ALLOW_ATTRIBUTES

`#[allow]` will not trigger if a warning isn't found. `#[expect]` triggers if there are no warnings.

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: allow_attributes. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for usage of the #[allow] attribute and suggests replacing it with the #[expect] (See RFC 2383)

This lint only warns outer attributes (#[allow]), as inner attributes (#![allow]) are usually used to enable or disable lints on a global scale.

Why is this bad?

#[expect] attributes suppress the lint emission, but emit a warning, if the expectation is unfulfilled. This can be useful to be notified when the lint is no longer triggered.

Example

#[allow(unused_mut)]
fn foo() -> usize {
    let mut a = Vec::new();
    a.len()
}

Use instead:

#[expect(unused_mut)]
fn foo() -> usize {
    let mut a = Vec::new();
    a.len()
}

Configuration

  • msrv: The minimum rust version that the project supports. Defaults to the rust-version field in Cargo.toml

    (default: current version)