@@ -6,7 +6,7 @@ use smallvec::SmallVec;
66use rustc_data_structures:: fx:: FxHashSet ;
77use rustc_hir:: def_id:: DefId ;
88use rustc_middle:: ty:: subst:: { GenericArg , Subst , SubstsRef } ;
9- use rustc_middle:: ty:: { self , ToPredicate , Ty , TyCtxt , TypeFoldable } ;
9+ use rustc_middle:: ty:: { self , ImplSubject , ToPredicate , Ty , TyCtxt , TypeFoldable } ;
1010
1111use super :: { Normalized , Obligation , ObligationCause , PredicateObligation , SelectionContext } ;
1212pub use rustc_infer:: traits:: { self , util:: * } ;
@@ -190,19 +190,19 @@ impl Iterator for SupertraitDefIds<'_> {
190190// Other
191191///////////////////////////////////////////////////////////////////////////
192192
193- /// Instantiate all bound parameters of the impl with the given substs,
194- /// returning the resulting trait ref and all obligations that arise.
193+ /// Instantiate all bound parameters of the impl subject with the given substs,
194+ /// returning the resulting subject and all obligations that arise.
195195/// The obligations are closed under normalization.
196- pub fn impl_trait_ref_and_oblig < ' a , ' tcx > (
196+ pub fn impl_subject_and_oblig < ' a , ' tcx > (
197197 selcx : & mut SelectionContext < ' a , ' tcx > ,
198198 param_env : ty:: ParamEnv < ' tcx > ,
199199 impl_def_id : DefId ,
200200 impl_substs : SubstsRef < ' tcx > ,
201- ) -> ( ty :: TraitRef < ' tcx > , impl Iterator < Item = PredicateObligation < ' tcx > > ) {
202- let impl_trait_ref = selcx. tcx ( ) . impl_trait_ref ( impl_def_id) . unwrap ( ) ;
203- let impl_trait_ref = impl_trait_ref . subst ( selcx. tcx ( ) , impl_substs) ;
204- let Normalized { value : impl_trait_ref , obligations : normalization_obligations1 } =
205- super :: normalize ( selcx, param_env, ObligationCause :: dummy ( ) , impl_trait_ref ) ;
201+ ) -> ( ImplSubject < ' tcx > , impl Iterator < Item = PredicateObligation < ' tcx > > ) {
202+ let subject = selcx. tcx ( ) . impl_subject ( impl_def_id) ;
203+ let subject = subject . subst ( selcx. tcx ( ) , impl_substs) ;
204+ let Normalized { value : subject , obligations : normalization_obligations1 } =
205+ super :: normalize ( selcx, param_env, ObligationCause :: dummy ( ) , subject ) ;
206206
207207 let predicates = selcx. tcx ( ) . predicates_of ( impl_def_id) ;
208208 let predicates = predicates. instantiate ( selcx. tcx ( ) , impl_substs) ;
@@ -215,35 +215,7 @@ pub fn impl_trait_ref_and_oblig<'a, 'tcx>(
215215 . chain ( normalization_obligations1. into_iter ( ) )
216216 . chain ( normalization_obligations2. into_iter ( ) ) ;
217217
218- ( impl_trait_ref, impl_obligations)
219- }
220-
221- /// Instantiate all bound parameters of the impl with the given substs,
222- /// returning the resulting trait ref and all obligations that arise.
223- /// The obligations are closed under normalization.
224- pub fn inherent_impl_and_oblig < ' a , ' tcx > (
225- selcx : & mut SelectionContext < ' a , ' tcx > ,
226- param_env : ty:: ParamEnv < ' tcx > ,
227- impl_def_id : DefId ,
228- impl_substs : SubstsRef < ' tcx > ,
229- ) -> ( Ty < ' tcx > , impl Iterator < Item = PredicateObligation < ' tcx > > ) {
230- let ty = selcx. tcx ( ) . type_of ( impl_def_id) ;
231- let ty = ty. subst ( selcx. tcx ( ) , impl_substs) ;
232- let Normalized { value : ty, obligations : normalization_obligations1 } =
233- super :: normalize ( selcx, param_env, ObligationCause :: dummy ( ) , ty) ;
234-
235- let predicates = selcx. tcx ( ) . predicates_of ( impl_def_id) ;
236- let predicates = predicates. instantiate ( selcx. tcx ( ) , impl_substs) ;
237- let Normalized { value : predicates, obligations : normalization_obligations2 } =
238- super :: normalize ( selcx, param_env, ObligationCause :: dummy ( ) , predicates) ;
239- let impl_obligations =
240- predicates_for_generics ( ObligationCause :: dummy ( ) , 0 , param_env, predicates) ;
241-
242- let impl_obligations = impl_obligations
243- . chain ( normalization_obligations1. into_iter ( ) )
244- . chain ( normalization_obligations2. into_iter ( ) ) ;
245-
246- ( ty, impl_obligations)
218+ ( subject, impl_obligations)
247219}
248220
249221pub fn predicates_for_generics < ' tcx > (
0 commit comments