Skip to content

Commit 98a95b8

Browse files
committed
Remove IsPrefixOf impl for Place and use the NeoPlace one
1 parent ed1411c commit 98a95b8

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
698698
// we're not in the uninteresting case where `B` is a
699699
// prefix of `D`), then report this as a more interesting
700700
// destructor conflict.
701-
if !borrow.borrowed_place.is_prefix_of(place_span.0) {
701+
let borrowed_neo_place = self.infcx.tcx.as_new_place(&borrow.borrowed_place);
702+
let other_neo_place = self.infcx.tcx.as_new_place(place_span.0);
703+
if !borrowed_neo_place.is_prefix_of(&other_neo_place) {
702704
self.report_borrow_conflicts_with_destructor(
703705
context, borrow, place_span, kind, dropped_ty,
704706
);

src/librustc_mir/borrow_check/prefixes.rs

-19
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,6 @@ pub trait IsPrefixOf<'tcx> {
1717
fn is_prefix_of(&self, other: &Self) -> bool;
1818
}
1919

20-
impl<'tcx> IsPrefixOf<'tcx> for Place<'tcx> {
21-
fn is_prefix_of(&self, other: &Place<'tcx>) -> bool {
22-
let mut cursor = other;
23-
loop {
24-
if self == cursor {
25-
return true;
26-
}
27-
28-
match *cursor {
29-
Place::Promoted(_) |
30-
Place::Local(_) | Place::Static(_) => return false,
31-
Place::Projection(ref proj) => {
32-
cursor = &proj.base;
33-
}
34-
}
35-
}
36-
}
37-
}
38-
3920
impl<'tcx> IsPrefixOf<'tcx> for NeoPlace<'tcx> {
4021
fn is_prefix_of(&self, other: &NeoPlace<'tcx>) -> bool {
4122
self.base == other.base

0 commit comments

Comments
 (0)