@@ -14,9 +14,9 @@ use super::util;
14
14
use super :: util:: { closure_trait_ref_and_return_type, predicate_for_trait_def} ;
15
15
use super :: wf;
16
16
use 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 ,
20
20
} ;
21
21
22
22
use crate :: infer:: { InferCtxt , InferOk , TypeFreshener } ;
@@ -2316,17 +2316,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2316
2316
debug ! ( ?predicates) ;
2317
2317
assert_eq ! ( predicates. parent, None ) ;
2318
2318
let mut obligations = Vec :: with_capacity ( predicates. predicates . len ( ) ) ;
2319
- let parent_code = cause. clone_code ( ) ;
2320
2319
for ( predicate, span) in predicates. predicates {
2321
2320
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
+ } ) ;
2330
2328
let predicate = normalize_with_depth_to (
2331
2329
self ,
2332
2330
param_env,
0 commit comments