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
Not totally sure what the root issue is, I guess it is that borrowck doesn't realize that the lifetime of "x as @mut Trait" needs to be limited to the lifetime of x.
Or perhaps it shouldn't be allowed at all to implement traits without lifetime parameters for structs with lifetime parameters.
trait R
{
fn set_v(&mut self, v: int);
}
struct A<'self>
{
v: &'self mut int
}
impl<'self> R for A<'self>
{
fn set_v(&mut self, v: int)
{
*self.v = v;
}
}
fn boom() -> @mut R
{
let mut i = 3;
let a = @mut A {v: &mut i};
let f: @mut R = a as @mut R;
f
}
pub fn main()
{
let mut f = boom();
f.set_v(66); // write to random place on stack
}
The text was updated successfully, but these errors were encountered:
Not totally sure what the root issue is, I guess it is that borrowck doesn't realize that the lifetime of "x as @mut Trait" needs to be limited to the lifetime of x.
Or perhaps it shouldn't be allowed at all to implement traits without lifetime parameters for structs with lifetime parameters.
The text was updated successfully, but these errors were encountered: