]>
Commit | Line | Data |
---|---|---|
abe05a73 XL |
1 | // Basic test for liveness constraints: the region (`R1`) that appears |
2 | // in the type of `p` includes the points after `&v[0]` up to (but not | |
3 | // including) the call to `use_x`. The `else` branch is not included. | |
4 | ||
abe05a73 XL |
5 | #![allow(warnings)] |
6 | #![feature(rustc_attrs)] | |
7 | ||
8 | struct MyStruct { | |
9 | field: String | |
10 | } | |
11 | ||
12 | fn foo1() { | |
13 | let mut my_struct = MyStruct { field: format!("Hello") }; | |
14 | ||
15 | let value = &my_struct.field; | |
16 | if value.is_empty() { | |
17 | my_struct.field.push_str("Hello, world!"); | |
abe05a73 XL |
18 | } |
19 | } | |
20 | ||
21 | fn foo2() { | |
22 | let mut my_struct = MyStruct { field: format!("Hello") }; | |
23 | ||
24 | let value = &my_struct.field; | |
25 | if value.is_empty() { | |
26 | my_struct.field.push_str("Hello, world!"); | |
48663c56 | 27 | //~^ ERROR [E0502] |
abe05a73 XL |
28 | } |
29 | drop(value); | |
30 | } | |
31 | ||
32 | fn main() { } |