@@ -65,6 +65,7 @@ use std::iter;
6565enum PlaceAncestryRelation {
6666 Ancestor ,
6767 Descendant ,
68+ SamePlace ,
6869 Divergent ,
6970}
7071
@@ -564,7 +565,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
564565 for possible_ancestor in min_cap_list. iter_mut ( ) {
565566 match determine_place_ancestry_relation ( & place, & possible_ancestor. place ) {
566567 // current place is descendant of possible_ancestor
567- PlaceAncestryRelation :: Descendant => {
568+ PlaceAncestryRelation :: Descendant | PlaceAncestryRelation :: SamePlace => {
568569 ancestor_found = true ;
569570 let backup_path_expr_id = possible_ancestor. info . path_expr_id ;
570571
@@ -2281,12 +2282,14 @@ fn determine_place_ancestry_relation(
22812282 iter:: zip ( projections_a, projections_b) . all ( |( proj_a, proj_b) | proj_a. kind == proj_b. kind ) ;
22822283
22832284 if same_initial_projections {
2285+ use std:: cmp:: Ordering ;
2286+
22842287 // First min(n, m) projections are the same
22852288 // Select Ancestor/Descendant
2286- if projections_b. len ( ) >= projections_a. len ( ) {
2287- PlaceAncestryRelation :: Ancestor
2288- } else {
2289- PlaceAncestryRelation :: Descendant
2289+ match projections_b. len ( ) . cmp ( & projections_a. len ( ) ) {
2290+ Ordering :: Greater => PlaceAncestryRelation :: Ancestor ,
2291+ Ordering :: Equal => PlaceAncestryRelation :: SamePlace ,
2292+ Ordering :: Less => PlaceAncestryRelation :: Descendant ,
22902293 }
22912294 } else {
22922295 PlaceAncestryRelation :: Divergent
0 commit comments