1 // Original regression test for Issue #30438.
9 impl <'a> Index<usize> for Test<'a> {
10 type Output = Test<'a>;
11 fn index(&self, _: usize) -> &Self::Output {
12 return &Test { s: &self.s};
13 //~^ ERROR: cannot return reference to temporary value
18 let s = "Hello World".to_string();
19 let test = Test{s: &s};
21 println!("{}", test.s); // OK since test is valid
22 println!("{}", r.s); // Segfault since value pointed by r has already been dropped