@@ -6,7 +6,7 @@ use smallvec::SmallVec;
6
6
use rustc_data_structures:: fx:: FxHashSet ;
7
7
use rustc_hir:: def_id:: DefId ;
8
8
use 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 } ;
10
10
11
11
use super :: { Normalized , Obligation , ObligationCause , PredicateObligation , SelectionContext } ;
12
12
pub use rustc_infer:: traits:: { self , util:: * } ;
@@ -190,19 +190,19 @@ impl Iterator for SupertraitDefIds<'_> {
190
190
// Other
191
191
///////////////////////////////////////////////////////////////////////////
192
192
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.
195
195
/// 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 > (
197
197
selcx : & mut SelectionContext < ' a , ' tcx > ,
198
198
param_env : ty:: ParamEnv < ' tcx > ,
199
199
impl_def_id : DefId ,
200
200
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 ) ;
206
206
207
207
let predicates = selcx. tcx ( ) . predicates_of ( impl_def_id) ;
208
208
let predicates = predicates. instantiate ( selcx. tcx ( ) , impl_substs) ;
@@ -215,35 +215,7 @@ pub fn impl_trait_ref_and_oblig<'a, 'tcx>(
215
215
. chain ( normalization_obligations1. into_iter ( ) )
216
216
. chain ( normalization_obligations2. into_iter ( ) ) ;
217
217
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)
247
219
}
248
220
249
221
pub fn predicates_for_generics < ' tcx > (
0 commit comments