rust-lang / rust-lang/rust-clippy
Clippy errors in build.rs suppress errors in the crate itself
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the behavior with the main.rs and build.rs snippets using cargo clippy, confirming that the build.rs diagnostic suppresses the main.rs error. Trace how cargo clippy handles diagnostics from build scripts and the crate, then verify that both errors are reported together.
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
- Mostly clear
- Newbie friendliness
- 35/100