@@ -65,6 +65,7 @@ use std::iter;
6565enum PlaceAncestryRelation {
6666 Ancestor ,
6767 Descendant ,
68+ SamePlace ,
6869 Divergent ,
6970}
7071
@@ -565,7 +566,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
565566 for possible_ancestor in min_cap_list. iter_mut ( ) {
566567 match determine_place_ancestry_relation ( & place, & possible_ancestor. place ) {
567568 // current place is descendant of possible_ancestor
568- PlaceAncestryRelation :: Descendant => {
569+ PlaceAncestryRelation :: Descendant | PlaceAncestryRelation :: SamePlace => {
569570 ancestor_found = true ;
570571 let backup_path_expr_id = possible_ancestor. info . path_expr_id ;
571572
@@ -2306,12 +2307,14 @@ fn determine_place_ancestry_relation(
23062307 iter:: zip ( projections_a, projections_b) . all ( |( proj_a, proj_b) | proj_a. kind == proj_b. kind ) ;
23072308
23082309 if same_initial_projections {
2310+ use std:: cmp:: Ordering ;
2311+
23092312 // First min(n, m) projections are the same
23102313 // Select Ancestor/Descendant
2311- if projections_b. len ( ) >= projections_a. len ( ) {
2312- PlaceAncestryRelation :: Ancestor
2313- } else {
2314- PlaceAncestryRelation :: Descendant
2314+ match projections_b. len ( ) . cmp ( & projections_a. len ( ) ) {
2315+ Ordering :: Greater => PlaceAncestryRelation :: Ancestor ,
2316+ Ordering :: Equal => PlaceAncestryRelation :: SamePlace ,
2317+ Ordering :: Less => PlaceAncestryRelation :: Descendant ,
23152318 }
23162319 } else {
23172320 PlaceAncestryRelation :: Divergent
0 commit comments