Auto merge of #54088 - matthewjasper:use-reason-in-dlle-errors, r=pnkfelix
[NLL] Suggest let binding Closes #49821 Also adds an alternative to `explain_why_borrow_contains_point` that allows changing error messages based on the reason that will be given. This will also be useful for #51026, #51169 and maybe further changes to does not live long enough messages.
This commit is contained in:
commit
052d24e6c8
15 changed files with 133 additions and 32 deletions
|
|
@ -8,6 +8,8 @@ LL | let val: &_ = x.borrow().0;
|
|||
...
|
||||
LL | println!("{}", val);
|
||||
| --- borrow later used here
|
||||
|
|
||||
= note: consider using a `let` binding to create a longer lived value
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ LL | let val: &_ = x.borrow().0;
|
|||
...
|
||||
LL | println!("{}", val);
|
||||
| --- borrow later used here
|
||||
|
|
||||
= note: consider using a `let` binding to create a longer lived value
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ fn main() {
|
|||
//[mir]~^^^^^ ERROR borrowed value does not live long enough [E0597]
|
||||
//[mir]~| NOTE temporary value does not live long enough
|
||||
//[mir]~| NOTE temporary value only lives until here
|
||||
//[mir]~| NOTE consider using a `let` binding to create a longer lived value
|
||||
println!("{}", val);
|
||||
//[mir]~^ borrow later used here
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue