Rollup merge of #85823 - fee1-dead:borrowck-0, r=jackh726
Do not suggest ampmut if rhs is already mutable
Removes invalid suggestion in #85765, although it should highlight the user type instead of the local variable.
Looking at the comments of this line:
84b1005bfd/compiler/rustc_mir_build/src/build/matches/mod.rs (L2107)
It was intentionally set to `None`, causing it to highlight the local variable instead. I am not sure if I will be able to fix it.
Fixes #85765
This commit is contained in:
commit
883e1a5fd4
3 changed files with 26 additions and 2 deletions
|
@ -902,9 +902,13 @@ fn suggest_ampmut<'tcx>(
|
|||
{
|
||||
let lt_name = &src[1..ws_pos];
|
||||
let ty = &src[ws_pos..];
|
||||
return (assignment_rhs_span, format!("&{} mut {}", lt_name, ty));
|
||||
if !ty.trim_start().starts_with("mut") {
|
||||
return (assignment_rhs_span, format!("&{} mut {}", lt_name, ty));
|
||||
}
|
||||
} else if let Some(stripped) = src.strip_prefix('&') {
|
||||
return (assignment_rhs_span, format!("&mut {}", stripped));
|
||||
if !stripped.trim_start().starts_with("mut") {
|
||||
return (assignment_rhs_span, format!("&mut {}", stripped));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue