Skip to content

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

tests/ui/mut_mut_unfixable.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,12 @@ fn main() {
3131
//~^ mut_mut
3232
***y + **x;
3333
}
34+
35+
if fun(x) {
36+
// The lint will remove the extra `&mut`, but the result will still be a `&mut` of an expr
37+
// of type `&mut _` (x), so the lint will fire again. That's because we've decided that
38+
// doing both fixes in one run is not worth it, given how improbable code like this is.
39+
let y = &mut &mut x;
40+
//~^ mut_mut
41+
}
3442
}

tests/ui/mut_mut_unfixable.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,11 @@ error: an expression of form `&mut &mut _`
3131
LL | let y = &mut &mut &mut 2;
3232
| ^^^^^^^^^^^^^^^^ help: remove the extra `&mut`s: `&mut 2`
3333

34-
error: aborting due to 5 previous errors
34+
error: an expression of form `&mut &mut _`
35+
--> tests/ui/mut_mut_unfixable.rs:39:17
36+
|
37+
LL | let y = &mut &mut x;
38+
| ^^^^^^^^^^^ help: remove the extra `&mut`: `&mut x`
39+
40+
error: aborting due to 6 previous errors
3541

0 commit comments

Comments
 (0)