Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive unfulfilled_lint_expectations for enum_glob_use with --all-targets or --tests #13358

Open
lnicola opened this issue Sep 6, 2024 · 3 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@lnicola
Copy link
Member

lnicola commented Sep 6, 2024

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.

rust-lang/rust#130021
rust-lang/rust-analyzer#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 lnicola added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Sep 6, 2024
@Urgau
Copy link
Member

Urgau commented Sep 7, 2024

The lint emission is gated behind the compilation unit NOT behind a test harness generation, it shouldn't be.

if cx.sess().is_test_crate() {
return;
}

@junbl
Copy link

junbl commented Sep 25, 2024

Same issue with both missing_docs and clippy::missing_docs_in_private_items, unfulfilled lint on all_targets and tests and nothing otherwise:

> cargo clippy 
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
> cargo clippy --all-targets
warning: this lint expectation is unfulfilled
 --> src/main.rs:5:10
  |
5 | #[expect(clippy::missing_docs_in_private_items)]
  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unfulfilled_lint_expectations)]` on by default

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

with this code:

#![deny(clippy::missing_docs_in_private_items)]

#[expect(clippy::missing_docs_in_private_items)]
const WHO_AM_I: () = ();

@dragonrider7225
Copy link

Same issue with both missing_docs and clippy::missing_docs_in_private_items, unfulfilled lint on all_targets and tests and nothing otherwise:

It's worth noting that in the case of missing_docs, this issue has been resolved as of rustc 1.83.0: [https://github.com/rust-lang/rust/pull/130025].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

4 participants