rust-lang / rust-lang/rust-clippy
Enable path trimming for error messages in clippy
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Consider this code:
fn main() {
let mut a = vec![String::new()];
let b = vec![10];
a = b;
}
When using "cargo check" the error message uses trimmed type paths and is much more readable:
error[E0308]: mismatched types
--> src/main.rs:5:9
|
5 | a = b;
| ^ expected struct `String`, found integer
|
= note: expected struct `Vec<String>`
found struct `Vec<{integer}>`
But when running "cargo clippy" you get this output:
error[E0308]: mismatched types
--> src/main.rs:5:9
|
5 | a = b;
| ^ expected struct `std::string::String`, found integer
|
= note: expected struct `std::vec::Vec<std::string::String>`
found struct `std::vec::Vec<{integer}>`
I have rust-analyzer set to always run clippy instead of check and as a result I get worse error messages inside the IDE.
Please consider enabling path trimming for clippy.
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
Reproduce the example with both cargo check and cargo clippy, and compare their diagnostic path formatting. Trace how Clippy invokes or configures compiler diagnostics; done means Clippy emits trimmed type paths like cargo check for the shown mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100