1 // Modified regression test for Issue #30438 that exposed an
2 // independent issue (see discussion on ticket).
10 impl <'a> Index<usize> for Test<'a> {
11 type Output = Test<'a>;
12 fn index(&self, _: usize) -> &Self::Output {
14 //~^ ERROR: cannot return reference to temporary value
19 let s = "Hello World".to_string();
20 let test = Test{s: &s};
22 println!("{}", test.s); // OK since test is valid
23 println!("{}", r.s); // Segfault since value pointed by r has already been dropped