1
Fork 0

tweak "make mut" spans (No. 3)

This commit is contained in:
Ezra Shaw 2023-04-19 19:50:08 +12:00 committed by Ezra Shaw
parent 9624d2b08e
commit 57c6a3183c
No known key found for this signature in database
GPG key ID: 5156CF5845150B0D
15 changed files with 43 additions and 39 deletions

View file

@ -1263,6 +1263,10 @@ fn suggest_ampmut<'tcx>(
{
let span = span.with_lo(span.lo() + BytePos(ws_pos as u32)).shrink_to_lo();
(true, span, " mut".to_owned())
} else if binding_exists {
// shrink the span to just after the `&` in `&variable`
let span = span.with_lo(span.lo() + BytePos(1)).shrink_to_lo();
(true, span, "mut ".to_owned())
} else {
let ty_mut = local_decl.ty.builtin_deref(true).unwrap();
assert_eq!(ty_mut.mutbl, hir::Mutability::Not);