@@ -617,6 +617,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
617
617
for ( _, captures) in & mut root_var_min_capture_list {
618
618
captures. sort_by ( |capture1, capture2| {
619
619
for ( p1, p2) in capture1. place . projections . iter ( ) . zip ( & capture2. place . projections ) {
620
+ // We do not need to look at the `Projection.ty` fields here because at each
621
+ // step of the iteration, the projections will either be the same and therefore
622
+ // the types must be as well or the current projection will be different and
623
+ // we will return the result of comparing the field indexes.
620
624
match ( p1. kind , p2. kind ) {
621
625
// Paths are the same, continue to next loop.
622
626
( ProjectionKind :: Deref , ProjectionKind :: Deref ) => { }
@@ -628,7 +632,34 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
628
632
return i1. cmp ( & i2) ;
629
633
}
630
634
631
- ( l, r) => bug ! ( "ProjectionKinds were different: ({:?}, {:?})" , l, r) ,
635
+ // We should have either a pair of `Deref`s or a pair of `Field`s.
636
+ // Anything else is a bug.
637
+ (
638
+ l @ ( ProjectionKind :: Deref | ProjectionKind :: Field ( ..) ) ,
639
+ r @ ( ProjectionKind :: Deref | ProjectionKind :: Field ( ..) ) ,
640
+ ) => bug ! (
641
+ "ProjectionKinds Deref and Field were mismatched: ({:?}, {:?})" ,
642
+ l,
643
+ r
644
+ ) ,
645
+ (
646
+ l
647
+ @
648
+ ( ProjectionKind :: Index
649
+ | ProjectionKind :: Subslice
650
+ | ProjectionKind :: Deref
651
+ | ProjectionKind :: Field ( ..) ) ,
652
+ r
653
+ @
654
+ ( ProjectionKind :: Index
655
+ | ProjectionKind :: Subslice
656
+ | ProjectionKind :: Deref
657
+ | ProjectionKind :: Field ( ..) ) ,
658
+ ) => bug ! (
659
+ "ProjectionKinds Index or Subslice were unexpected: ({:?}, {:?})" ,
660
+ l,
661
+ r
662
+ ) ,
632
663
}
633
664
}
634
665
0 commit comments