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
Spurious "does not live long enough" for closure coerced to fn pointer in static item (AST borrowck only) #48540
rustc 1.26.0-nightly (28a1e4f 2018-02-24) with -Z borrowck=mir: OK
Without any -Z flag: error below, even though I believe the program to be valid. But maybe it’s not worth fixing if MIR-based borrow-checking will become the default soon? CC @nikomatsakis
A work-around is to have the closure in an intermediate const item.
error[E0597]: borrowed value does not live long enough
--> a.rs:5:52
|
5 | pub static FOO:Static<fn(&u32) -> &u32> = Static(&[|x| x]);
| ^^^^^^^- temporary value only lives until here
| |
| temporary value does not live long enough
|
= note: borrowed value must be valid for the static lifetime...
error: aborting due to previous error
Activity
nikomatsakis commentedon Feb 27, 2018
It's actually equivalent to
-Zborrowck=mir -Znll -Ztwo-phase-borrows, I thinknikomatsakis commentedon Feb 27, 2018
@SimonSapin is this a regression, do you know?
SimonSapin commentedon Feb 27, 2018
@nikomatsakis Not as far as I know. 1.24.0 stable gives the same error. Note that this is fixed by MIR-borrowck.
nikomatsakis commentedon Feb 27, 2018
OK. In that case I am inclined to wait, yes.
SimonSapin commentedon Nov 26, 2018
Adding the "fixed by NLL" label as an approximation of fixed by MIR borrowck
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=<try>
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=pnkfelix
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=pnkfelix