rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.06k stars 1.56k forks source link

`unfulfilled_lint_expectations` emitted upon a correct `#[expect(clippy::enum_glob_use)]` #17685

Open its-the-shrimp opened 1 month ago

its-the-shrimp commented 1 month ago

rust-analyzer version: 2024-07-22

rustc version: rustc 1.82.0-nightly (8bfcae730 2024-07-23)

editor or extension: Neovim

code snippet to reproduce:

#![warn(clippy::pedantic)]

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

fn main() {
    print!("{Equal:?}");
}

This code is just fine with cargo check or cargo clippy, but rust-analyzer emits an unfulfilled_lint_expectations warning, even though the clippy::enum_glob_use lint is triggered if the expect attribute is commented out

kpreid commented 2 weeks ago

I'm seeing the same thing with other lints, e.g.

//! crate docs

#![warn(missing_docs)]

#[expect(missing_docs)] // warning: this lint expectation is unfulfilled
pub fn foo() {}

rust-analyzer version: 0.3.2086-standalone (7106cd3be 2024-08-25) [/Users/kpreid/.vscode/extensions/rust-lang.rust-analyzer-0.3.2086-darwin-x64/server/rust-analyzer] rustc version: 1.82.0-nightly (c6db1ca3c 2024-08-25)

Presumably this has something to do with how RA invokes the check command, but I couldn't figure out how to extract the command line to test it separately. It happens whether rust-analyzer.check.command is set to check or clippy.

MrCroxx commented 1 week ago

I'm seeing the same thing with other lints, e.g.

//! crate docs

#![warn(missing_docs)]

#[expect(missing_docs)] // warning: this lint expectation is unfulfilled
pub fn foo() {}

rust-analyzer version: 0.3.2086-standalone (7106cd3 2024-08-25) [/Users/kpreid/.vscode/extensions/rust-lang.rust-analyzer-0.3.2086-darwin-x64/server/rust-analyzer] rustc version: 1.82.0-nightly (c6db1ca3c 2024-08-25)

Presumably this has something to do with how RA invokes the check command, but I couldn't figure out how to extract the command line to test it separately. It happens whether rust-analyzer.check.command is set to check or clippy.

+1 with rust stable-1.81.0

Victor-N-Suadicani commented 1 week ago

Just updated to stable 1.81 and got this.

I can reproduce it directly with cargo using cargo clippy --tests, which also reports "this lint expectation is unfulfilled". But it doesn't happen with cargo check --tests. :thinking:

lnicola commented 1 week ago

This happens because we pass --all-targets by default. But I don't really understand the reason why, we should probably file an issue against Clippy or rustc.

Urgau commented 6 days ago

--all-targets enables --tests which enables the test harness generation (rustc --test) which some lint are gated against, which means that they don't emit the lint which triggers the unfulfilled_lint_expectations lint since it wasn't emitted