rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

False positive `unfulfilled_lint_expectations` for `enum_glob_use` with `--all-targets` or `--tests`

Open lnicola opened this issue 1 year ago • 2 comments

Summary

unfulfilled_lint_expectations seems to trigger for enum_glob_use when either --all-targets or --tests is used. Yet other lints, like unreadable_literal don't behave that way.

https://github.com/rust-lang/rust/issues/130021 https://github.com/rust-lang/rust-analyzer/issues/17685

Lint Name

enum_glob_use

Reproducer

I tried this code:

#![warn(clippy::pedantic)]

#[expect(clippy::enum_glob_use)]
use std::cmp::Ordering::*;

fn main() {
    #[expect(clippy::unreadable_literal)]
    let _ = 1000000000;
    print!("{Equal:?}");
}

I saw this happen:

$ cargo clippy --all-targets
warning: this lint expectation is unfulfilled
 --> src/main.rs:3:10
  |
3 | #[expect(clippy::enum_glob_use)]
  |          ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unfulfilled_lint_expectations)]` on by default

warning: `hello` (bin "hello" test) generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s

I expected to see this happen:

$ cargo clippy
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s

Version

rustc 1.81.0-beta.6 (b5fd9f6f1 2024-08-21)
binary: rustc
commit-hash: b5fd9f6f1061b79c045cc08fe03e00caad536800
commit-date: 2024-08-21
host: x86_64-unknown-linux-gnu
release: 1.81.0-beta.6
LLVM version: 18.1.7

Additional Labels

No response

lnicola avatar Sep 06 '24 09:09 lnicola