Skip to content

Enable path trimming for error messages in clippy #7212

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

Open
veber-alex opened this issue May 12, 2021 · 4 comments
Open

Enable path trimming for error messages in clippy #7212

veber-alex opened this issue May 12, 2021 · 4 comments

Comments

@veber-alex
Copy link

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.

@xFrednet
Copy link
Member

This is most likely related to #6385

This is the second issue in a short time that came up in this regard, it might be that there has been a change that increased the frequency 🤔

@veber-alex
Copy link
Author

Hi, any updates on this issue?
According to rust-lang/rust@c5a6131 path trimming is not enabled for clippy for a reason but having some option to enable it anyway would be nice.
Unfortunately the obvious way shown below doesn't work.
RUSTFLAGS="-Ztrim-diagnostic-paths=yes" cargo clippy

@xFrednet
Copy link
Member

Hey, there hasn't been any progress to my knowledge, probably also because as with #6385 there hasn't been any leads where to start looking for the issue. Your linked commit could have something todo with it and is a new idea to look into. 🙃

@camsteffen
Copy link
Contributor

I opened a tracking issue for this at #7798 since there is some refactoring needed to support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants