@@ -388,7 +388,8 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
388
388
( true , Ok ( Certainty :: Maybe ( MaybeCause :: Ambiguity ) ) ) | ( false , Err ( _) ) => { }
389
389
_ => return ControlFlow :: Continue ( ( ) ) ,
390
390
}
391
- let pred_kind = goal. goal ( ) . predicate . kind ( ) ;
391
+
392
+ let pred = goal. goal ( ) . predicate ;
392
393
393
394
let candidates = self . non_trivial_candidates ( goal) ;
394
395
let candidate = match candidates. as_slice ( ) {
@@ -410,20 +411,20 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
410
411
411
412
// FIXME: Also, what about considering >1 layer up the stack? May be necessary
412
413
// 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 ) )
416
417
}
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 ) )
419
420
}
420
421
ty:: PredicateKind :: NormalizesTo ( normalizes_to)
421
422
if matches ! (
422
423
normalizes_to. alias. kind( tcx) ,
423
424
ty:: AliasTermKind :: ProjectionTy | ty:: AliasTermKind :: ProjectionConst
424
425
) =>
425
426
{
426
- ChildMode :: Trait ( pred_kind . rebind ( ty:: TraitPredicate {
427
+ ChildMode :: Trait ( pred . kind ( ) . rebind ( ty:: TraitPredicate {
427
428
trait_ref : normalizes_to. alias . trait_ref ( tcx) ,
428
429
polarity : ty:: PredicatePolarity :: Positive ,
429
430
} ) )
@@ -457,10 +458,12 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
457
458
for nested_goal in nested_goals {
458
459
trace ! ( nested_goal = ?( nested_goal. goal( ) , nested_goal. source( ) , nested_goal. result( ) ) ) ;
459
460
461
+ let nested_pred = nested_goal. goal ( ) . predicate ;
462
+
460
463
let make_obligation = |cause| Obligation {
461
464
cause,
462
465
param_env : nested_goal. goal ( ) . param_env ,
463
- predicate : nested_goal . goal ( ) . predicate ,
466
+ predicate : nested_pred ,
464
467
recursion_depth : self . obligation . recursion_depth + 1 ,
465
468
} ;
466
469
@@ -510,28 +513,17 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
510
513
511
514
// alias-relate may fail because the lhs or rhs can't be normalized,
512
515
// 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
+ ) ?;
535
527
}
536
528
537
529
self . detect_error_in_higher_ranked_projection ( goal) ?;
0 commit comments