rust/src/test/ui/borrowck/borrowck-borrow-from-temporary.rs

15 lines
266 B
Rust
Raw Normal View History

// Test lifetimes are linked properly when we take reference
// to interior.
2017-08-13 03:46:49 -05:00
fn id<T>(x: T) -> T { x }
struct Foo(isize);
fn foo<'a>() -> &'a isize {
2017-08-13 03:46:49 -05:00
let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough
x
}
pub fn main() {
}