Closed
Description
#![feature(unsafe_destructor)]
struct A;
impl Drop for A {
fn drop(&mut self) {}
}
struct B<'a> {
a: &'a A,
}
#[unsafe_destructor]
impl<'a> Drop for B<'a> {
fn drop(&mut self) {}
}
impl A {
fn b(&self) -> B {
B { a: self }
}
}
fn main() {
let a = A;
match a.b() {
_ => {}
}
}
test.rs:25:11: 25:12 error: `a` does not live long enough
test.rs:25 match a.b() {
^
test.rs:23:11: 28:2 note: reference must be valid for the destruction scope surrounding block at 23:10...
test.rs:23 fn main() {
test.rs:24 let a = A;
test.rs:25 match a.b() {
test.rs:26 _ => {}
test.rs:27 }
test.rs:28 }
test.rs:24:14: 28:2 note: ...but borrowed value is only valid for the block suffix following statement 0 at 24:13
test.rs:24 let a = A;
test.rs:25 match a.b() {
test.rs:26 _ => {}
test.rs:27 }
test.rs:28 }
error: aborting due to previous error
Adding anything after the match (like ;
or ()
) causes the error to go away.
cc @pnkfelix