Skip to content

Commit d3f9af8

Browse files
committed
Remove irrelevant message about drop order
When dropping a self-borrowing struct we shouldn't add a "values in a scope are dropped in the opposite order they are defined" message, since there is only one value being dropped.
1 parent f49f6e7 commit d3f9af8

File tree

5 files changed

+4
-9
lines changed

5 files changed

+4
-9
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
143143
Some(Cause::DropVar(local, location)) => match &mir.local_decls[local].name {
144144
Some(local_name) => {
145145
let mut should_note_order = false;
146-
if let Some((WriteKind::StorageDeadOrDrop(_), place)) = kind_place {
146+
if let Some((WriteKind::StorageDeadOrDrop, place)) = kind_place {
147147
if let Place::Local(borrowed_local) = place {
148148
let dropped_local_scope = mir.local_decls[local].visibility_scope;
149149
let borrowed_local_scope =
150150
mir.local_decls[*borrowed_local].visibility_scope;
151151

152-
if mir.is_sub_scope(borrowed_local_scope, dropped_local_scope) {
152+
if mir.is_sub_scope(borrowed_local_scope, dropped_local_scope)
153+
&& local != *borrowed_local
154+
{
153155
should_note_order = true;
154156
}
155157
}

src/test/ui/dropck/dropck-union.nll.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ LL | }
88
| |
99
| `v` dropped here while still borrowed
1010
| borrow later used here, when `v` is dropped
11-
|
12-
= note: values in a scope are dropped in the opposite order they are defined
1311

1412
error: aborting due to previous error
1513

src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ LL | }
2323
| |
2424
| `d1` dropped here while still borrowed
2525
| borrow later used here, when `d1` is dropped
26-
|
27-
= note: values in a scope are dropped in the opposite order they are defined
2826

2927
error: aborting due to 2 previous errors
3028

src/test/ui/span/issue28498-reject-ex1.nll.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ LL | }
1111
| borrow later used here, when `foo` is dropped
1212
|
1313
= note: consider using a `let` binding to create a longer lived value
14-
= note: values in a scope are dropped in the opposite order they are defined
1514

1615
error: aborting due to previous error
1716

src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ LL | }
1111
| |
1212
| `factorial` dropped here while still borrowed
1313
| borrow later used here, when `factorial` is dropped
14-
|
15-
= note: values in a scope are dropped in the opposite order they are defined
1614

1715
error[E0506]: cannot assign to `factorial` because it is borrowed
1816
--> $DIR/unboxed-closures-failed-recursive-fn-1.rs:30:5

0 commit comments

Comments
 (0)