You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NLL: lost "borrowed value needs to live until here" (diagnostic regression compared to AST-borrowck) #54382
Standard Error
Compiling playground v0.0.1 (/playground)
error[E0597]: `_thing1` does not live long enough
--> src/main.rs:6:26
|
6 | D("other").next(&_thing1)
| ^^^^^^^ borrowed value does not live long enough
7 | }
| - `_thing1` dropped here while still borrowed
8 |
9 | ;
| - borrowed value needs to live until here
under NLL, it only emits this:
error[E0597]: `_thing1` does not live long enough
--> src/main.rs:6:25
|
6 | D("other").next(&_thing1)
| ^^^^^^^^ borrowed value does not live long enough
7 | }
| - `_thing1` dropped here while still borrowed
In particular, the note 8 "borrowed value needs to live until here" that highlights the semi-colon after the end of the block is no longer emitted.
My current plan for addressing #54556 is to improve diagnostics. The first step in that path, IMO, would be to figure out how to bring back the note about how long the borrowed value needs to live.
error[E0597]: `_thing1` does not live long enough
--> src/main.rs:6:25
|
4 | {
| _____-
| |_____|
| ||
5 | || let mut _thing1 = D(Box::new("thing1"));
6 | || D("other").next(&_thing1)
| || ^^^^^^^^ borrowed value does not live long enough
7 | || }
| || -
| || |
| ||_____`_thing1` dropped here while still borrowed
| |______a temporary with access to the borrow is created here ...
| ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D`
the labels look good, but the spans associated with them -- woah...
Activity
nikomatsakis commentedon Oct 30, 2018
Current output:
the labels look good, but the spans associated with them -- woah...
pnkfelix commentedon Oct 31, 2018
Hmm I wonder why the temp is being given the span of the whole block rather than the blocks tail expr
pnkfelix commentedon Oct 31, 2018
And likewise, why the drop of the temporary is no longer associated with the span of the semicolon on the whole statement ...
pnkfelix commentedon Nov 6, 2018
Triage: While I do want to address this, I don't think we would feel all that inclined to backport a fix to the beta channel.
So, tagging as P-high, but removing from the Release milestone.
Also, I'm going to assign this to myself since I've taken a special interest in issues involving tail expressions of blocks.
Regression test for issue rust-lang#54382
Rollup merge of rust-lang#55781 - pnkfelix:issue-54382-more-precise-s…
Rollup merge of rust-lang#55781 - pnkfelix:issue-54382-more-precise-s…