-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
While working on #52663, I saw a collection of cases where the .nll.stderr
files shows that we are currently generating a diagnostic where we suggest the user do something like change a &
-type to a &mut
-type, but the problem is that in adding the mut
, we seem to lose bits of the original input type that it probably needs, such as explicit lifetimes.
See for example:
rust/src/test/ui/did_you_mean/issue-39544.nll.stderr
Lines 12 to 13 in fefe816
LL | fn foo<'z>(&'z self) { | |
| -------- help: consider changing this to be a mutable reference: `&mut self` |
rust/src/test/ui/did_you_mean/issue-39544.nll.stderr
Lines 37 to 38 in fefe816
LL | fn foo2<'a>(&'a self, other: &Z) { | |
| -------- help: consider changing this to be a mutable reference: `&mut self` |
rust/src/test/ui/did_you_mean/issue-39544.nll.stderr
Lines 54 to 55 in fefe816
LL | fn foo3<'a>(self: &'a Self, other: &Z) { | |
| -------- help: consider changing this to be a mutable reference: `&mut Z` |
rust/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr
Lines 28 to 29 in fefe816
LL | fn assign_field2<'a>(x: &'a Own<Point>) { | |
| -------------- help: consider changing this to be a mutable reference: `&mut Own<Point>` |
rust/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr
Lines 60 to 61 in fefe816
LL | fn assign_method2<'a>(x: &'a Own<Point>) { | |
| -------------- help: consider changing this to be a mutable reference: `&mut Own<Point>` |
rust/src/test/ui/span/mut-arg-hint.nll.stderr
Lines 12 to 13 in fefe816
LL | pub fn foo<'a>(mut a: &'a String) { | |
| ---------- help: consider changing this to be a mutable reference: `&mut std::string::String` |
LL | fn reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { | |
| --------------- help: consider changing this to be a mutable reference: `&mut &mut i32` |
rust/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.nll.stderr
Lines 12 to 13 in fefe816
LL | fn copy_reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { | |
| --------------- help: consider changing this to be a mutable reference: `&mut &mut i32` |