]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-47470.rs
Rollup merge of #105216 - GuillaumeGomez:rm-unused-gui-test, r=notriddle
[rust.git] / src / test / ui / nll / issue-47470.rs
1 // Regression test for #47470: cached results of projections were
2 // causing region relations not to be enforced at all the places where
3 // they have to be enforced.
4
5 struct Foo<'a>(&'a ());
6 trait Bar {
7     type Assoc;
8     fn get(self) -> Self::Assoc;
9 }
10
11 impl<'a> Bar for Foo<'a> {
12     type Assoc = &'a u32;
13     fn get(self) -> Self::Assoc {
14         let local = 42;
15         &local //~ ERROR cannot return reference to local variable `local`
16     }
17 }
18
19 fn main() {
20     let f = Foo(&()).get();
21     println!("{}", f);
22 }