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.
This commit is contained in:
Matthew Jasper 2018-09-23 15:56:14 +01:00
parent f49f6e73a8
commit d3f9af8891
5 changed files with 4 additions and 9 deletions

View file

@ -143,13 +143,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
Some(Cause::DropVar(local, location)) => match &mir.local_decls[local].name {
Some(local_name) => {
let mut should_note_order = false;
if let Some((WriteKind::StorageDeadOrDrop(_), place)) = kind_place {
if let Some((WriteKind::StorageDeadOrDrop, place)) = kind_place {
if let Place::Local(borrowed_local) = place {
let dropped_local_scope = mir.local_decls[local].visibility_scope;
let borrowed_local_scope =
mir.local_decls[*borrowed_local].visibility_scope;
if mir.is_sub_scope(borrowed_local_scope, dropped_local_scope) {
if mir.is_sub_scope(borrowed_local_scope, dropped_local_scope)
&& local != *borrowed_local
{
should_note_order = true;
}
}

View file

@ -8,8 +8,6 @@ LL | }
| |
| `v` dropped here while still borrowed
| borrow later used here, when `v` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined
error: aborting due to previous error

View file

@ -23,8 +23,6 @@ LL | }
| |
| `d1` dropped here while still borrowed
| borrow later used here, when `d1` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined
error: aborting due to 2 previous errors

View file

@ -11,7 +11,6 @@ LL | }
| borrow later used here, when `foo` is dropped
|
= note: consider using a `let` binding to create a longer lived value
= note: values in a scope are dropped in the opposite order they are defined
error: aborting due to previous error

View file

@ -11,8 +11,6 @@ LL | }
| |
| `factorial` dropped here while still borrowed
| borrow later used here, when `factorial` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined
error[E0506]: cannot assign to `factorial` because it is borrowed
--> $DIR/unboxed-closures-failed-recursive-fn-1.rs:30:5