1 // Simplified regression test for #30438, inspired by arielb1.
3 trait Trait { type Out; }
5 struct Test<'a> { s: &'a str }
7 fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y <Test<'z> as Trait>::Out where 'z: 'static {
8 let x = Test { s: "this cannot last" };
10 //~^ ERROR: cannot return reference to local variable `x`
13 impl<'b> Trait for Test<'b> { type Out = Test<'b>; }
16 let orig = Test { s: "Hello World" };
18 println!("{}", orig.s); // OK since `orig` is valid
19 println!("{}", r.s); // Segfault (method does not return a sane value)