@@ -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
@@ -565,7 +566,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
565
566
for possible_ancestor in min_cap_list. iter_mut ( ) {
566
567
match determine_place_ancestry_relation ( & place, & possible_ancestor. place ) {
567
568
// current place is descendant of possible_ancestor
568
- PlaceAncestryRelation :: Descendant => {
569
+ PlaceAncestryRelation :: Descendant | PlaceAncestryRelation :: SamePlace => {
569
570
ancestor_found = true ;
570
571
let backup_path_expr_id = possible_ancestor. info . path_expr_id ;
571
572
@@ -2306,12 +2307,14 @@ fn determine_place_ancestry_relation(
2306
2307
iter:: zip ( projections_a, projections_b) . all ( |( proj_a, proj_b) | proj_a. kind == proj_b. kind ) ;
2307
2308
2308
2309
if same_initial_projections {
2310
+ use std:: cmp:: Ordering ;
2311
+
2309
2312
// First min(n, m) projections are the same
2310
2313
// 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 ,
2315
2318
}
2316
2319
} else {
2317
2320
PlaceAncestryRelation :: Divergent
0 commit comments