]>
Commit | Line | Data |
---|---|---|
2c00a5a8 XL |
1 | // Test that NLL analysis propagates lifetimes correctly through |
2 | // field accesses, Box accesses, etc. | |
3 | ||
2c00a5a8 XL |
4 | fn foo(s: &mut (i32,)) -> i32 { |
5 | let t = &mut *s; // this borrow should last for the entire function | |
6 | let x = &t.0; | |
7 | *s = (2,); //~ ERROR cannot assign to `*s` | |
8 | *x | |
9 | } | |
10 | ||
11 | fn bar(s: &Box<(i32,)>) -> &'static i32 { | |
12 | // FIXME(#46983): error message should be better | |
3c0e092e | 13 | &s.0 //~ ERROR lifetime may not live long enough |
2c00a5a8 XL |
14 | } |
15 | ||
16 | fn main() { | |
17 | foo(&mut (0,)); | |
18 | bar(&Box::new((1,))); | |
19 | } |