Conversation
|
rustbot has assigned @samueltardieu. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
forgot to run dogfood, fixed. |
|
r? @blyxyas |
This comment has been minimized.
This comment has been minimized.
|
This shouldn't change inferred binding types AFAIK, the lint is conservative here and the it should only fire when the type is already known and the move is valid. I'll add an inference focused test to be safe. |
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| fn should_not_lint_mut_ref_drop(x: WithDrop<'_>) { | ||
| if let Some(&mut ref mut x) = x.0 { | ||
| *x = 0; | ||
| } | ||
| } |
There was a problem hiding this comment.
Just a question, where are we checking for that significant drop?
There was a problem hiding this comment.
It's not checked explicitly, we only allow a bare local as the scrutinee, so it bails before drop-ness even matters.
There was a problem hiding this comment.
Okay then, please squash the commits :)
add inference test
closes #16022
The lint should now also fire over
&mut ref mutpatterns when the matched reference can be moved instead of reborrowed. This is a bit conservative for now as it only handles cases where:match/if let,There may be other valid cases but this should cover the straightforward ones without risking incorrect suggestions or complexities.
changelog: [
needless_borrowed_reference] now also lints certain&mut ref mutpatterns