1 // This test case is exploring the space of how blocks with tail
2 // expressions and statements can be composed, trying to keep each
3 // case on one line so that we can compare them via a vertical scan
6 // Each comment on the right side of the line is summarizing the
7 // expected suggestion from the diagnostic for issue #54556.
10 { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;`
11 //~^ ERROR does not live long enough
13 { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } } ; // suggest `;`
14 //~^ ERROR does not live long enough
16 { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() }; } // suggest `;`
17 //~^ ERROR does not live long enough
19 let _ = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;`
20 //~^ ERROR does not live long enough
22 let _u = { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } ; // suggest `;`
23 //~^ ERROR does not live long enough
25 let _x = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x`
26 //~^ ERROR does not live long enough
27 let _x = { let mut _t1 = D(Box::new("t1")); let x = D(&_t1).end(); x } ; // no error
30 _y = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x`
31 //~^ ERROR does not live long enough
32 _y = { let mut _t1 = D(Box::new("t1")); let x = D(&_t1).end(); x } ; // no error
35 fn f_param_ref(_t1: D<Box<&'static str>>) { D(&_t1).unit() } // no error
37 fn f_local_ref() { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } // suggest `;`
38 //~^ ERROR does not live long enough
40 fn f() -> String { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } // `let x = ...; x`
41 //~^ ERROR does not live long enough
44 struct D<T: std::fmt::Debug>(T);
46 impl<T: std::fmt::Debug> Drop for D<T> {
48 println!("dropping {:?})", self);
52 impl<T: std::fmt::Debug> D<T> {
53 fn next<U: std::fmt::Debug>(&self, _other: U) -> D<U> { D(_other) }
54 fn end(&self) -> String { format!("End({:?})", self.0) }