rust/tests/ui/borrowck/borrowck-borrow-from-temporary.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
273 B
Rust
Raw Normal View History

// Test lifetimes are linked properly when we take reference
// to interior.
2017-08-13 08:46:49 +00:00
fn id<T>(x: T) -> T { x }
struct Foo(isize);
fn foo<'a>() -> &'a isize {
let &Foo(ref x) = &id(Foo(3));
x //~ ERROR cannot return value referencing temporary value
}
pub fn main() {
}