]> git.lizzy.rs Git - rust.git/commitdiff
WIP patch `compile-fail/nll/region-ends-after-if-condition.rs`
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 30 Oct 2017 14:59:14 +0000 (10:59 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 31 Oct 2017 16:41:40 +0000 (12:41 -0400)
src/test/compile-fail/nll/region-ends-after-if-condition.rs

index dbc35fa99b0251e17433fe2727457820fbb4cd76..bec56982c57a19787dfac06ec894198624ae271f 100644 (file)
@@ -21,12 +21,26 @@ struct MyStruct {
     field: String
 }
 
-fn main() {
+fn foo1() {
     let mut my_struct = MyStruct { field: format!("Hello") };
 
     let value = &my_struct.field;
     if value.is_empty() {
         my_struct.field.push_str("Hello, world!");
-        //~^ ERROR cannot borrow (Ast)
+        //~^ ERROR (Ast) [E0502]
     }
 }
+
+fn foo2() {
+    let mut my_struct = MyStruct { field: format!("Hello") };
+
+    let value = &my_struct.field;
+    if value.is_empty() {
+        my_struct.field.push_str("Hello, world!");
+        //~^ ERROR (Ast) [E0502]
+        //~| ERROR (Mir) [E0502]
+    }
+    drop(value);
+}
+
+fn main() { }