Skip to content

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

Open

Description

(moved (again) from rust-lang/rust#79405)

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesE-hardCall for participation: This a hard problem and requires more experience or effort to work on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions