@@ -2,11 +2,10 @@ pub mod on_unimplemented;
22pub mod suggestions;
33
44use super :: {
5- DerivedObligationCause , EvaluationResult , FulfillmentContext , FulfillmentError ,
6- FulfillmentErrorCode , ImplDerivedObligationCause , MismatchedProjectionTypes , Obligation ,
7- ObligationCause , ObligationCauseCode , OnUnimplementedDirective , OnUnimplementedNote ,
8- OutputTypeParameterMismatch , Overflow , PredicateObligation , SelectionContext , SelectionError ,
9- TraitNotObjectSafe ,
5+ EvaluationResult , FulfillmentContext , FulfillmentError , FulfillmentErrorCode ,
6+ MismatchedProjectionTypes , Obligation , ObligationCause , ObligationCauseCode ,
7+ OnUnimplementedDirective , OnUnimplementedNote , OutputTypeParameterMismatch , Overflow ,
8+ PredicateObligation , SelectionContext , SelectionError , TraitNotObjectSafe ,
109} ;
1110
1211use crate :: infer:: error_reporting:: { TyCategory , TypeAnnotationNeeded as ErrorCode } ;
@@ -684,32 +683,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
684683 let mut code = obligation. cause . code ( ) ;
685684 let mut trait_pred = trait_predicate;
686685 let mut peeled = false ;
687- loop {
688- match & * code {
689- ObligationCauseCode :: FunctionArgumentObligation {
690- parent_code,
691- ..
692- } => {
693- code = & parent_code;
694- }
695- ObligationCauseCode :: ImplDerivedObligation (
696- box ImplDerivedObligationCause {
697- derived,
698- ..
699- } ,
700- )
701- | ObligationCauseCode :: BuiltinDerivedObligation (
702- derived,
703- )
704- | ObligationCauseCode :: DerivedObligation (
705- derived,
706- ) => {
707- peeled = true ;
708- code = & derived. parent_code ;
709- trait_pred = derived. parent_trait_pred ;
710- }
711- _ => break ,
712- } ;
686+ while let Some ( ( parent_code, parent_trait_pred) ) = code. parent ( ) {
687+ code = parent_code;
688+ if let Some ( parent_trait_pred) = parent_trait_pred {
689+ trait_pred = parent_trait_pred;
690+ peeled = true ;
691+ }
713692 }
714693 let def_id = trait_pred. def_id ( ) ;
715694 // Mention *all* the `impl`s for the *top most* obligation, the
0 commit comments