Skip to content

Commit d46b42f

Browse files
committed
only dump causes if we have nothing better
1 parent 0285f81 commit d46b42f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
2828
if let Some(cause) = regioncx.why_region_contains_point(borrow.region, context.loc) {
2929
let mir = self.mir;
3030

31-
cause.label_diagnostic(mir, err);
32-
3331
match *cause.root_cause() {
3432
Cause::LiveVar(local, location) => {
3533
match find_regular_use(&mir, regioncx, borrow, location, local) {
@@ -72,7 +70,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
7270
}
7371
}
7472

75-
_ => (),
73+
_ => {
74+
cause.label_diagnostic(mir, err);
75+
}
7676
}
7777
}
7878
}

src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0506]: cannot assign to `x` because it is borrowed
2-
--> $DIR/maybe-initialized-drop-implicit-fragment-drop.rs:31:5
2+
--> $DIR/maybe-initialized-drop-implicit-fragment-drop.rs:32:5
33
|
4-
27 | let wrap = Wrap { p: &mut x };
4+
28 | let wrap = Wrap { p: &mut x };
55
| ------ borrow of `x` occurs here
66
...
7-
31 | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
7+
32 | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
88
| ^^^^^ assignment to borrowed `x` occurs here
9-
32 | // FIXME ^ Should not error in the future with implicit dtors, only manually implemented ones
10-
33 | }
9+
33 | // FIXME ^ Should not error in the future with implicit dtors, only manually implemented ones
10+
34 | }
1111
| - borrow later used here, when `foo` is dropped
1212

1313
error: aborting due to previous error

0 commit comments

Comments
 (0)