Skip to content

expect attribute supressing lint, but then saying it's not fulfilled #12998

Closed

Description

NOTE: This is using cargo clippy, but the actual issue may be in the lint_reasons feature. If this is not appropriate for the rustc repo, let me know and I can copy it over to clippy's.

I tried this code:

#![feature(lint_reasons)]

fn main() {
    if true {
        #[expect(clippy::needless_return)]
        return;
    }
}

playground (Use Clippy)

I expected to see this happen: No output because clippy emits the clippy::needless_return lint, which should satisfy the expect.

Instead, this happened:

warning: this lint expectation is unfulfilled
 --> src/main.rs:5:18
  |
5 |         #[expect(clippy::needless_return)]
  |                  ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unfulfilled_lint_expectations)]` on by default

Meta

rustc --version --verbose:

rustc 1.77.0-nightly (2df6406b8 2023-12-26)
binary: rustc
commit-hash: 2df6406b886757a3c1475957660a3a4ae6c786de
commit-date: 2023-12-26
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

@rustbot label +T-compiler +A-clippy +A-lint +F-lint_reasons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-clippyA-lintArea: New lintsC-bugCategory: Clippy is not doing the correct thing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions