@@ -360,7 +360,8 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
360
360
( true , Ok ( Certainty :: Maybe ( MaybeCause :: Ambiguity ) ) ) | ( false , Err ( _) ) => { }
361
361
_ => return ControlFlow :: Continue ( ( ) ) ,
362
362
}
363
- let pred_kind = goal. goal ( ) . predicate . kind ( ) ;
363
+
364
+ let pred = goal. goal ( ) . predicate ;
364
365
365
366
let candidates = self . non_trivial_candidates ( goal) ;
366
367
let candidate = match candidates. as_slice ( ) {
@@ -382,20 +383,20 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
382
383
383
384
// FIXME: Also, what about considering >1 layer up the stack? May be necessary
384
385
// for normalizes-to.
385
- let child_mode = match pred_kind . skip_binder ( ) {
386
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( pred ) ) => {
387
- ChildMode :: Trait ( pred_kind . rebind ( pred ) )
386
+ let child_mode = match pred . kind ( ) . skip_binder ( ) {
387
+ ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( trait_pred ) ) => {
388
+ ChildMode :: Trait ( pred . kind ( ) . rebind ( trait_pred ) )
388
389
}
389
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: HostEffect ( pred ) ) => {
390
- ChildMode :: Host ( pred_kind . rebind ( pred ) )
390
+ ty:: PredicateKind :: Clause ( ty:: ClauseKind :: HostEffect ( host_pred ) ) => {
391
+ ChildMode :: Host ( pred . kind ( ) . rebind ( host_pred ) )
391
392
}
392
393
ty:: PredicateKind :: NormalizesTo ( normalizes_to)
393
394
if matches ! (
394
395
normalizes_to. alias. kind( tcx) ,
395
396
ty:: AliasTermKind :: ProjectionTy | ty:: AliasTermKind :: ProjectionConst
396
397
) =>
397
398
{
398
- ChildMode :: Trait ( pred_kind . rebind ( ty:: TraitPredicate {
399
+ ChildMode :: Trait ( pred . kind ( ) . rebind ( ty:: TraitPredicate {
399
400
trait_ref : normalizes_to. alias . trait_ref ( tcx) ,
400
401
polarity : ty:: PredicatePolarity :: Positive ,
401
402
} ) )
@@ -429,10 +430,12 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
429
430
for nested_goal in nested_goals {
430
431
trace ! ( nested_goal = ?( nested_goal. goal( ) , nested_goal. source( ) , nested_goal. result( ) ) ) ;
431
432
433
+ let nested_pred = nested_goal. goal ( ) . predicate ;
434
+
432
435
let make_obligation = |cause| Obligation {
433
436
cause,
434
437
param_env : nested_goal. goal ( ) . param_env ,
435
- predicate : nested_goal . goal ( ) . predicate ,
438
+ predicate : nested_pred ,
436
439
recursion_depth : self . obligation . recursion_depth + 1 ,
437
440
} ;
438
441
@@ -482,28 +485,17 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
482
485
483
486
// alias-relate may fail because the lhs or rhs can't be normalized,
484
487
// and therefore is treated as rigid.
485
- if let Some ( ty:: PredicateKind :: AliasRelate ( lhs, rhs, _) ) = pred_kind. no_bound_vars ( ) {
486
- if let Some ( obligation) = goal
487
- . infcx ( )
488
- . visit_proof_tree_at_depth (
489
- goal. goal ( ) . with ( tcx, ty:: ClauseKind :: WellFormed ( lhs. into ( ) ) ) ,
490
- goal. depth ( ) + 1 ,
491
- self ,
492
- )
493
- . break_value ( )
494
- {
495
- return ControlFlow :: Break ( obligation) ;
496
- } else if let Some ( obligation) = goal
497
- . infcx ( )
498
- . visit_proof_tree_at_depth (
499
- goal. goal ( ) . with ( tcx, ty:: ClauseKind :: WellFormed ( rhs. into ( ) ) ) ,
500
- goal. depth ( ) + 1 ,
501
- self ,
502
- )
503
- . break_value ( )
504
- {
505
- return ControlFlow :: Break ( obligation) ;
506
- }
488
+ if let Some ( ty:: PredicateKind :: AliasRelate ( lhs, rhs, _) ) = pred. kind ( ) . no_bound_vars ( ) {
489
+ goal. infcx ( ) . visit_proof_tree_at_depth (
490
+ goal. goal ( ) . with ( tcx, ty:: ClauseKind :: WellFormed ( lhs. into ( ) ) ) ,
491
+ goal. depth ( ) + 1 ,
492
+ self ,
493
+ ) ?;
494
+ goal. infcx ( ) . visit_proof_tree_at_depth (
495
+ goal. goal ( ) . with ( tcx, ty:: ClauseKind :: WellFormed ( rhs. into ( ) ) ) ,
496
+ goal. depth ( ) + 1 ,
497
+ self ,
498
+ ) ?;
507
499
}
508
500
509
501
// HACK: When a higher-ranked projection goal fails, check that the corresponding
@@ -512,7 +504,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
512
504
// to see that the leak check failed in the nested `NormalizesTo` goal, so we don't
513
505
// fall back to the regular machinery that should catch when a projection goal fails
514
506
// due to an unsatisfied trait goal.
515
- if let Some ( projection_clause) = goal . goal ( ) . predicate . as_projection_clause ( )
507
+ if let Some ( projection_clause) = pred . as_projection_clause ( )
516
508
&& !projection_clause. bound_vars ( ) . is_empty ( )
517
509
{
518
510
let pred = projection_clause. map_bound ( |proj| proj. projection_term . trait_ref ( tcx) ) ;
0 commit comments