@@ -65,6 +65,7 @@ use std::iter;
65
65
enum PlaceAncestryRelation {
66
66
Ancestor ,
67
67
Descendant ,
68
+ SamePlace ,
68
69
Divergent ,
69
70
}
70
71
@@ -564,7 +565,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
564
565
for possible_ancestor in min_cap_list. iter_mut ( ) {
565
566
match determine_place_ancestry_relation ( & place, & possible_ancestor. place ) {
566
567
// current place is descendant of possible_ancestor
567
- PlaceAncestryRelation :: Descendant => {
568
+ PlaceAncestryRelation :: Descendant | PlaceAncestryRelation :: SamePlace => {
568
569
ancestor_found = true ;
569
570
let backup_path_expr_id = possible_ancestor. info . path_expr_id ;
570
571
@@ -2281,12 +2282,14 @@ fn determine_place_ancestry_relation(
2281
2282
iter:: zip ( projections_a, projections_b) . all ( |( proj_a, proj_b) | proj_a. kind == proj_b. kind ) ;
2282
2283
2283
2284
if same_initial_projections {
2285
+ use std:: cmp:: Ordering ;
2286
+
2284
2287
// First min(n, m) projections are the same
2285
2288
// 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 ,
2290
2293
}
2291
2294
} else {
2292
2295
PlaceAncestryRelation :: Divergent
0 commit comments