]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-47470.rs
Rollup merge of #60685 - dtolnay:spdx, r=nikomatsakis
[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 #![feature(nll)]
6
7 struct Foo<'a>(&'a ());
8 trait Bar {
9     type Assoc;
10     fn get(self) -> Self::Assoc;
11 }
12
13 impl<'a> Bar for Foo<'a> {
14     type Assoc = &'a u32;
15     fn get(self) -> Self::Assoc {
16         let local = 42;
17         &local //~ ERROR cannot return reference to local variable `local`
18     }
19 }
20
21 fn main() {
22     let f = Foo(&()).get();
23     println!("{}", f);
24 }