@@ -14,9 +14,9 @@ use super::util;
1414use super :: util:: { closure_trait_ref_and_return_type, predicate_for_trait_def} ;
1515use super :: wf;
1616use super :: {
17- DerivedObligationCause , ErrorReporting , ImplDerivedObligation , ImplDerivedObligationCause ,
18- Normalized , Obligation , ObligationCause , ObligationCauseCode , Overflow , PredicateObligation ,
19- Selection , SelectionError , SelectionResult , TraitObligation , TraitQueryMode ,
17+ ErrorReporting , ImplDerivedObligation , ImplDerivedObligationCause , Normalized , Obligation ,
18+ ObligationCause , ObligationCauseCode , Overflow , PredicateObligation , Selection , SelectionError ,
19+ SelectionResult , TraitObligation , TraitQueryMode ,
2020} ;
2121
2222use crate :: infer:: { InferCtxt , InferOk , TypeFreshener } ;
@@ -2316,17 +2316,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
23162316 debug ! ( ?predicates) ;
23172317 assert_eq ! ( predicates. parent, None ) ;
23182318 let mut obligations = Vec :: with_capacity ( predicates. predicates . len ( ) ) ;
2319- let parent_code = cause. clone_code ( ) ;
23202319 for ( predicate, span) in predicates. predicates {
23212320 let span = * span;
2322- let derived =
2323- DerivedObligationCause { parent_trait_pred, parent_code : parent_code. clone ( ) } ;
2324- let code = ImplDerivedObligation ( Box :: new ( ImplDerivedObligationCause {
2325- derived,
2326- impl_def_id : def_id,
2327- span,
2328- } ) ) ;
2329- let cause = ObligationCause :: new ( cause. span , cause. body_id , code) ;
2321+ let cause = cause. clone ( ) . derived_cause ( parent_trait_pred, |derived| {
2322+ ImplDerivedObligation ( Box :: new ( ImplDerivedObligationCause {
2323+ derived,
2324+ impl_def_id : def_id,
2325+ span,
2326+ } ) )
2327+ } ) ;
23302328 let predicate = normalize_with_depth_to (
23312329 self ,
23322330 param_env,
0 commit comments