Skip to content

Commit ac54b74

Browse files
committed
A promoted has a place and can thus be equal to itself
1 parent 4fba7d3 commit ac54b74

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/librustc_mir/borrow_check/places_conflict.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,21 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
327327
Overlap::EqualOrDisjoint
328328
}
329329
}
330-
(Place::Promoted(_), Place::Promoted(_)) |
330+
(Place::Promoted(p1), Place::Promoted(p2)) => {
331+
if p1.0 == p2.0 {
332+
// the same promoted - base case, equal
333+
debug!("place_element_conflict: DISJOINT-OR-EQ-PROMOTED");
334+
Overlap::EqualOrDisjoint
335+
} else {
336+
// different promoteds - base case, disjoint
337+
debug!("place_element_conflict: DISJOINT-PROMOTED");
338+
Overlap::Disjoint
339+
}
340+
}
331341
(Place::Local(_), Place::Promoted(_)) | (Place::Promoted(_), Place::Local(_)) |
332342
(Place::Promoted(_), Place::Static(_)) | (Place::Static(_), Place::Promoted(_)) |
333343
(Place::Local(_), Place::Static(_)) | (Place::Static(_), Place::Local(_)) => {
334-
debug!("place_element_conflict: DISJOINT-STATIC-LOCAL");
344+
debug!("place_element_conflict: DISJOINT-STATIC-LOCAL-PROMOTED");
335345
Overlap::Disjoint
336346
}
337347
(Place::Projection(pi1), Place::Projection(pi2)) => {

0 commit comments

Comments
 (0)