@@ -19,14 +19,13 @@ use rustc_span::def_id::DefId;
1919use crate :: traits:: project:: { normalize_with_depth, normalize_with_depth_to} ;
2020use crate :: traits:: util:: { self , closure_trait_ref_and_return_type, predicate_for_trait_def} ;
2121use crate :: traits:: {
22- BuiltinDerivedObligation , DerivedObligationCause , ImplDerivedObligation ,
23- ImplDerivedObligationCause , ImplSource , ImplSourceAutoImplData , ImplSourceBuiltinData ,
24- ImplSourceClosureData , ImplSourceConstDestructData , ImplSourceDiscriminantKindData ,
25- ImplSourceFnPointerData , ImplSourceGeneratorData , ImplSourceObjectData , ImplSourcePointeeData ,
26- ImplSourceTraitAliasData , ImplSourceTraitUpcastingData , ImplSourceUserDefinedData , Normalized ,
27- ObjectCastObligation , Obligation , ObligationCause , OutputTypeParameterMismatch ,
28- PredicateObligation , Selection , SelectionError , TraitNotObjectSafe , TraitObligation ,
29- Unimplemented , VtblSegment ,
22+ BuiltinDerivedObligation , ImplDerivedObligation , ImplDerivedObligationCause , ImplSource ,
23+ ImplSourceAutoImplData , ImplSourceBuiltinData , ImplSourceClosureData ,
24+ ImplSourceConstDestructData , ImplSourceDiscriminantKindData , ImplSourceFnPointerData ,
25+ ImplSourceGeneratorData , ImplSourceObjectData , ImplSourcePointeeData , ImplSourceTraitAliasData ,
26+ ImplSourceTraitUpcastingData , ImplSourceUserDefinedData , Normalized , ObjectCastObligation ,
27+ Obligation , ObligationCause , OutputTypeParameterMismatch , PredicateObligation , Selection ,
28+ SelectionError , TraitNotObjectSafe , TraitObligation , Unimplemented , VtblSegment ,
3029} ;
3130
3231use super :: BuiltinImplConditions ;
@@ -1125,21 +1124,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11251124 let substs = self . rematch_impl ( impl_def_id, & new_obligation) ;
11261125 debug ! ( ?substs, "impl substs" ) ;
11271126
1128- let derived = DerivedObligationCause {
1129- parent_trait_pred : obligation. predicate ,
1130- parent_code : obligation. cause . clone_code ( ) ,
1131- } ;
1132- let derived_code = ImplDerivedObligation ( Box :: new ( ImplDerivedObligationCause {
1133- derived,
1134- impl_def_id,
1135- span : obligation. cause . span ,
1136- } ) ) ;
1137-
1138- let cause = ObligationCause :: new (
1139- obligation. cause . span ,
1140- obligation. cause . body_id ,
1141- derived_code,
1142- ) ;
1127+ let cause = obligation. derived_cause ( |derived| {
1128+ ImplDerivedObligation ( Box :: new ( ImplDerivedObligationCause {
1129+ derived,
1130+ impl_def_id,
1131+ span : obligation. cause . span ,
1132+ } ) )
1133+ } ) ;
11431134 ensure_sufficient_stack ( || {
11441135 self . vtable_impl (
11451136 impl_def_id,
0 commit comments