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 //~^ WARN unnecessary lifetime parameter `'z`
9 let x = Test { s: "this cannot last" };
11 //~^ ERROR: cannot return reference to local variable `x`
14 impl<'b> Trait for Test<'b> { type Out = Test<'b>; }
17 let orig = Test { s: "Hello World" };
19 println!("{}", orig.s); // OK since `orig` is valid
20 println!("{}", r.s); // Segfault (method does not return a sane value)