rust-lang / rust-lang/rust-clippy
Don't prefix full path specification when suggesting changing & to &mut.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
(moved (again) from https://github.com/rust-lang/rust/issues/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?
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
Start by reproducing the diagnostic with the Rust examples in the issue and identify the Clippy lint responsible for suggesting &mut. Trace how the suggestion renders the reference type, then verify that aliases and ordinary types retain their source-level spelling rather than gaining a fully qualified path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100