1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Simplified regression test for #30438, inspired by arielb1.
13 trait Trait { type Out; }
15 struct Test<'a> { s: &'a str }
17 fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y <Test<'z> as Trait>::Out where 'z: 'static {
18 let x = Test { s: "this cannot last" };
20 //~^ ERROR: `x` does not live long enough
23 impl<'b> Trait for Test<'b> { type Out = Test<'b>; }
26 let orig = Test { s: "Hello World" };
28 println!("{}", orig.s); // OK since `orig` is valid
29 println!("{}", r.s); // Segfault (method does not return a sane value)