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
In going from rustc 0.12.0-pre-nightly (2224edcfe 2014-07-24 00:26:14 +0000) to rustc 0.12.0-pre-nightly (cf1381c1d 2014-07-26 00:46:16 +0000), a certain symmetry breaking seems to have arisen and I want to check that this is not a bug.
The following code works in both nighty :
static myval: int = 5;
struct cls<'a>{
z: &'a int
}
fn create<'r>() -> cls<'r> {
cls { z : & myval }
}
fn main(){}
However the following code, which is a "functionised" version of the above example, fails in the 2014-07-26 nightly but not in the 2014-07-24 nightly.
fn retn() -> int{ return 5; }
struct cls<'a>{
fz: &'a fn() -> int
}
/*
error: borrowed value does not live long enough
cls { fz : & retn }
^~~~
*/
fn create<'r>() -> cls<'r> {
cls { fz : & retn }
}
fn main(){}
I don't understand why the latter should not work, since if I am not mistaken, the scope of the function fn retn() is the same as the scope of static myval: int. Thanks
The text was updated successfully, but these errors were encountered:
In going from
rustc 0.12.0-pre-nightly (2224edcfe 2014-07-24 00:26:14 +0000)
torustc 0.12.0-pre-nightly (cf1381c1d 2014-07-26 00:46:16 +0000)
, a certain symmetry breaking seems to have arisen and I want to check that this is not a bug.The following code works in both nighty :
However the following code, which is a "functionised" version of the above example, fails in the
2014-07-26
nightly but not in the2014-07-24
nightly.I don't understand why the latter should not work, since if I am not mistaken, the scope of the function
fn retn()
is the same as the scope ofstatic myval: int
. ThanksThe text was updated successfully, but these errors were encountered: