@@ -388,7 +388,8 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
388388            ( true ,  Ok ( Certainty :: Maybe ( MaybeCause :: Ambiguity ) ) )  | ( false ,  Err ( _) )  => { } 
389389            _ => return  ControlFlow :: Continue ( ( ) ) , 
390390        } 
391-         let  pred_kind = goal. goal ( ) . predicate . kind ( ) ; 
391+ 
392+         let  pred = goal. goal ( ) . predicate ; 
392393
393394        let  candidates = self . non_trivial_candidates ( goal) ; 
394395        let  candidate = match  candidates. as_slice ( )  { 
@@ -410,20 +411,20 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
410411
411412        // FIXME: Also, what about considering >1 layer up the stack? May be necessary 
412413        // for normalizes-to. 
413-         let  child_mode = match  pred_kind . skip_binder ( )  { 
414-             ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( pred ) )  => { 
415-                 ChildMode :: Trait ( pred_kind . rebind ( pred ) ) 
414+         let  child_mode = match  pred . kind ( ) . skip_binder ( )  { 
415+             ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( trait_pred ) )  => { 
416+                 ChildMode :: Trait ( pred . kind ( ) . rebind ( trait_pred ) ) 
416417            } 
417-             ty:: PredicateKind :: Clause ( ty:: ClauseKind :: HostEffect ( pred ) )  => { 
418-                 ChildMode :: Host ( pred_kind . rebind ( pred ) ) 
418+             ty:: PredicateKind :: Clause ( ty:: ClauseKind :: HostEffect ( host_pred ) )  => { 
419+                 ChildMode :: Host ( pred . kind ( ) . rebind ( host_pred ) ) 
419420            } 
420421            ty:: PredicateKind :: NormalizesTo ( normalizes_to) 
421422                if  matches ! ( 
422423                    normalizes_to. alias. kind( tcx) , 
423424                    ty:: AliasTermKind :: ProjectionTy  | ty:: AliasTermKind :: ProjectionConst 
424425                )  =>
425426            { 
426-                 ChildMode :: Trait ( pred_kind . rebind ( ty:: TraitPredicate  { 
427+                 ChildMode :: Trait ( pred . kind ( ) . rebind ( ty:: TraitPredicate  { 
427428                    trait_ref :  normalizes_to. alias . trait_ref ( tcx) , 
428429                    polarity :  ty:: PredicatePolarity :: Positive , 
429430                } ) ) 
@@ -457,10 +458,12 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
457458        for  nested_goal in  nested_goals { 
458459            trace ! ( nested_goal = ?( nested_goal. goal( ) ,  nested_goal. source( ) ,  nested_goal. result( ) ) ) ; 
459460
461+             let  nested_pred = nested_goal. goal ( ) . predicate ; 
462+ 
460463            let  make_obligation = |cause| Obligation  { 
461464                cause, 
462465                param_env :  nested_goal. goal ( ) . param_env , 
463-                 predicate :  nested_goal . goal ( ) . predicate , 
466+                 predicate :  nested_pred , 
464467                recursion_depth :  self . obligation . recursion_depth  + 1 , 
465468            } ; 
466469
@@ -510,28 +513,17 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
510513
511514        // alias-relate may fail because the lhs or rhs can't be normalized, 
512515        // and therefore is treated as rigid. 
513-         if  let  Some ( ty:: PredicateKind :: AliasRelate ( lhs,  rhs,  _) )  = pred_kind. no_bound_vars ( )  { 
514-             if  let  Some ( obligation)  = goal
515-                 . infcx ( ) 
516-                 . visit_proof_tree_at_depth ( 
517-                     goal. goal ( ) . with ( tcx,  ty:: ClauseKind :: WellFormed ( lhs. into ( ) ) ) , 
518-                     goal. depth ( )  + 1 , 
519-                     self , 
520-                 ) 
521-                 . break_value ( ) 
522-             { 
523-                 return  ControlFlow :: Break ( obligation) ; 
524-             }  else  if  let  Some ( obligation)  = goal
525-                 . infcx ( ) 
526-                 . visit_proof_tree_at_depth ( 
527-                     goal. goal ( ) . with ( tcx,  ty:: ClauseKind :: WellFormed ( rhs. into ( ) ) ) , 
528-                     goal. depth ( )  + 1 , 
529-                     self , 
530-                 ) 
531-                 . break_value ( ) 
532-             { 
533-                 return  ControlFlow :: Break ( obligation) ; 
534-             } 
516+         if  let  Some ( ty:: PredicateKind :: AliasRelate ( lhs,  rhs,  _) )  = pred. kind ( ) . no_bound_vars ( )  { 
517+             goal. infcx ( ) . visit_proof_tree_at_depth ( 
518+                 goal. goal ( ) . with ( tcx,  ty:: ClauseKind :: WellFormed ( lhs. into ( ) ) ) , 
519+                 goal. depth ( )  + 1 , 
520+                 self , 
521+             ) ?; 
522+             goal. infcx ( ) . visit_proof_tree_at_depth ( 
523+                 goal. goal ( ) . with ( tcx,  ty:: ClauseKind :: WellFormed ( rhs. into ( ) ) ) , 
524+                 goal. depth ( )  + 1 , 
525+                 self , 
526+             ) ?; 
535527        } 
536528
537529        self . detect_error_in_higher_ranked_projection ( goal) ?; 
0 commit comments