Skip to content

Don't prefix full path specification when suggesting changing & to &mut. #79405

@iago-lito

Description

@iago-lito

(moved from rust-lang/rust-analyzer#6626)

With the following code:

fn f(vec: &Vec<usize>) {
    vec.push(5);
}

I get a suggestion to "change this to a mutable reference", but if I do, I get:

fn f(vec: &mut std::vec::Vec<usize>) {
    vec.push(5);
}

That's a bit overkill, right? I would rather expect

fn f(vec: &mut Vec<usize>) {
    vec.push(5);
}

It actually becomes worse. I've decided to file this bug report after my argument:

shells: &LocatedShells,

was changed to

shells: &mut topology::located_slice::LocatedBoxedSlice<std::collections::HashMap<usize, shell::Shell, std::hash::BuildHasherDefault<fnv::FnvHasher>>>,

instead of just

shells: &mut LocatedShells,

That's definitely overkill, so I end up changing the & to &mut by hand.
Is this something expected? Or something I can configure not to happen?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions