Skip to content

Enable path trimming for error messages in clippy #7212

@veber-alex

Description

@veber-alex

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions