]> git.lizzy.rs Git - rust.git/commitdiff
only dump causes if we have nothing better
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 14 Dec 2017 20:01:05 +0000 (15:01 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 20 Dec 2017 19:38:11 +0000 (14:38 -0500)
src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs
src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr

index bfb7e793eee0306069ff0917341778a39f2f53a5..948c1ac0b136255b35b4d2697a9b219890cb1a04 100644 (file)
@@ -28,8 +28,6 @@ pub(in borrow_check) fn explain_why_borrow_contains_point(
             if let Some(cause) = regioncx.why_region_contains_point(borrow.region, context.loc) {
                 let mir = self.mir;
 
-                cause.label_diagnostic(mir, err);
-
                 match *cause.root_cause() {
                     Cause::LiveVar(local, location) => {
                         match find_regular_use(&mir, regioncx, borrow, location, local) {
@@ -72,7 +70,9 @@ pub(in borrow_check) fn explain_why_borrow_contains_point(
                         }
                     }
 
-                    _ => (),
+                    _ => {
+                        cause.label_diagnostic(mir, err);
+                    }
                 }
             }
         }
index b161a068c040feaca7f5e803dc331877eed2e93a..3c685ce111a972e13ae12952995d6fc30b045767 100644 (file)
@@ -1,13 +1,13 @@
 error[E0506]: cannot assign to `x` because it is borrowed
-  --> $DIR/maybe-initialized-drop-implicit-fragment-drop.rs:31:5
+  --> $DIR/maybe-initialized-drop-implicit-fragment-drop.rs:32:5
    |
-27 |     let wrap = Wrap { p: &mut x };
+28 |     let wrap = Wrap { p: &mut x };
    |                          ------ borrow of `x` occurs here
 ...
-31 |     x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
+32 |     x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
    |     ^^^^^ assignment to borrowed `x` occurs here
-32 |     // FIXME ^ Should not error in the future with implicit dtors, only manually implemented ones
-33 | }
+33 |     // FIXME ^ Should not error in the future with implicit dtors, only manually implemented ones
+34 | }
    |  - borrow later used here, when `foo` is dropped
 
 error: aborting due to previous error