Skip to content

Commit bf57a23

Browse files
committed
WIP patch compile-fail/nll/region-ends-after-if-condition.rs
1 parent f27eb1e commit bf57a23

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/test/compile-fail/nll/region-ends-after-if-condition.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,26 @@ struct MyStruct {
2121
field: String
2222
}
2323

24-
fn main() {
24+
fn foo1() {
2525
let mut my_struct = MyStruct { field: format!("Hello") };
2626

2727
let value = &my_struct.field;
2828
if value.is_empty() {
2929
my_struct.field.push_str("Hello, world!");
30-
//~^ ERROR cannot borrow (Ast)
30+
//~^ ERROR (Ast) [E0502]
3131
}
3232
}
33+
34+
fn foo2() {
35+
let mut my_struct = MyStruct { field: format!("Hello") };
36+
37+
let value = &my_struct.field;
38+
if value.is_empty() {
39+
my_struct.field.push_str("Hello, world!");
40+
//~^ ERROR (Ast) [E0502]
41+
//~| ERROR (Mir) [E0502]
42+
}
43+
drop(value);
44+
}
45+
46+
fn main() { }

0 commit comments

Comments
 (0)