-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone
Description
(NB. This is assuming my in-progress branch)
If you run issue-36082.rs
in NLL mode, you get:
> rustc --stage1 issue-36082.rs -Zborrowck=mir
error[E0597]: borrowed value does not live long enough
--> issue-36082.rs:21:19
|
21 | let val: &_ = x.borrow().0;
| ^^^^^^^^^^ - temporary value only lives until here
| |
| temporary value does not live long enough
...
30 | println!("{}", val);
| --- borrow later used here
There is no suggestion about using a let binding to increase the lifetime of the temporary, unlike AST borrowck:
> rustc --stage1 issue-36082.rs
error[E0597]: borrowed value does not live long enough
--> issue-36082.rs:21:19
|
21 | let val: &_ = x.borrow().0;
| ^^^^^^^^^^ - temporary value dropped here while still borrowed
| |
| temporary value does not live long enough
...
31 | }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
That said, this seems like a case where the AST borrowck message could also be improved. I doubt many people understand it very well.
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.