]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-borrow-from-temporary.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-borrow-from-temporary.rs
1 // Test lifetimes are linked properly when we take reference
2 // to interior.
3
4 fn id<T>(x: T) -> T { x }
5
6 struct Foo(isize);
7
8 fn foo<'a>() -> &'a isize {
9     let &Foo(ref x) = &id(Foo(3));
10     x //~ ERROR cannot return value referencing temporary value
11 }
12
13 pub fn main() {
14 }