NLL: suggested rewritten input types should preserve user-written lifetimes when needed #52880
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
rust/src/test/ui/did_you_mean/issue-39544.nll.stderr
Lines 37 to 38 in fefe816
rust/src/test/ui/did_you_mean/issue-39544.nll.stderr
Lines 54 to 55 in fefe816
rust/src/test/ui/span/mut-arg-hint.nll.stderr
Lines 12 to 13 in fefe816
rust/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.nll.stderr
Lines 12 to 13 in fefe816