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

Clippy errors in build.rs suppress errors in the crate itself #9534

Open
Wilfred opened this issue Sep 25, 2022 · 1 comment
Open

Clippy errors in build.rs suppress errors in the crate itself #9534

Wilfred opened this issue Sep 25, 2022 · 1 comment
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@Wilfred
Copy link
Contributor

Wilfred commented Sep 25, 2022

Summary

When there are clippy errors in build.rs, cargo clippy no longer reports any errors in the rest of the crate.

This is confusing when using rust-analyzer with clippy as the check command. If there are any clippy errors in build.rs, you lose all red underlines in the other files you're editing.

Reproducer

I had a main.rs with a type error

fn main() {
    return 1;
}

and a build.rs with a clippy error:

fn say_hello(s: &str) {
    if s.contains("unix") {
        println!("unixish");
    } else if s.contains("macos") {
        println!("unixish");
    } else {
        println!("probably windows");
    }
}

fn main() {
    say_hello("abc");
}

I expected to see this happen:

$ cargo clippy
... reports the rustc failure in main.rs ...

Instead, this happened:

$ cargo clippy
... only complains about build.rs ...

Version

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-unknown-linux-gnu
release: 1.63.0
LLVM version: 14.0.5

Additional Labels

No response

@Wilfred Wilfred added the C-bug Category: Clippy is not doing the correct thing label Sep 25, 2022
@Alexendoo
Copy link
Member

Alexendoo commented Sep 25, 2022

That would be confusing indeed. As a workaround you could downgrade the errors to warnings just for the build script, #![warn(clippy::correctness)] or #![warn(clippy::all)]

Wilfred added a commit to Wilfred/difftastic that referenced this issue Dec 31, 2022
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
Projects
None yet
Development

No branches or pull requests

2 participants