rust-lang / rust-lang/rust-clippy

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

Open
#13,358 5 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-false-positive
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Rust reproducer with cargo clippy and with --all-targets or --tests, comparing enum_glob_use with unreadable_literal. Trace how enum_glob_use and unfulfilled_lint_expectations handle lint expectations across those target modes. Done means the reproducer no longer emits a false unfulfilled-expectation warning while the expected lint behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.