@@ -6,13 +6,11 @@ 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 , WithConstness } ;
9+ use rustc_middle:: ty:: { self , ToPredicate , Ty , TyCtxt , WithConstness } ;
1010
1111use super :: { Normalized , Obligation , ObligationCause , PredicateObligation , SelectionContext } ;
1212pub use rustc_infer:: traits:: util:: * ;
1313
14- use std:: iter;
15-
1614///////////////////////////////////////////////////////////////////////////
1715// `TraitAliasExpander` iterator
1816///////////////////////////////////////////////////////////////////////////
@@ -359,69 +357,6 @@ pub fn impl_item_is_final(tcx: TyCtxt<'_>, assoc_item: &ty::AssocItem) -> bool {
359357 assoc_item. defaultness . is_final ( ) && tcx. impl_defaultness ( assoc_item. container . id ( ) ) . is_final ( )
360358}
361359
362- /// Map a bound from an associated item to apply to some other type.
363- /// For example, given the following trait
364- ///
365- /// trait X<A> { type Y<'a>: PartialEq<A> }
366- ///
367- /// Say that we know that `<() as X<B>>::Y<'c> = i32` and we need to check that
368- /// the `PartialEq` bound applies. We would then call this function with:
369- ///
370- /// - `bound` = `<Self as X<A>>::Y<'a>: PartialEq`
371- /// - `normalized_projection_ty` = `i32`
372- /// - `assoc_item_substs` = `[(), B, 'c]`
373- ///
374- /// This method would then return `i32: PartialEq<B>`.
375- pub fn subst_assoc_item_bound < ' tcx > (
376- tcx : TyCtxt < ' tcx > ,
377- bound : ty:: Predicate < ' tcx > ,
378- normalized_projection_ty : Ty < ' tcx > ,
379- assoc_item_substs : & [ GenericArg < ' tcx > ] ,
380- ) -> ty:: Predicate < ' tcx > {
381- // We're substituting these inside the closure passed to map_bound, so they
382- // can't have escaping bound regions.
383- assert ! ( !normalized_projection_ty. has_escaping_bound_vars( ) ) ;
384- assert ! ( !assoc_item_substs. iter( ) . all( |arg| arg. has_escaping_bound_vars( ) ) ) ;
385-
386- let translate_predicate_substs = move |predicate_substs : SubstsRef < ' tcx > | {
387- tcx. mk_substs (
388- iter:: once ( normalized_projection_ty. into ( ) )
389- . chain ( predicate_substs[ 1 ..] . iter ( ) . map ( |s| s. subst ( tcx, assoc_item_substs) ) ) ,
390- )
391- } ;
392-
393- match bound. kind ( ) {
394- ty:: PredicateKind :: Trait ( poly_tr, c) => poly_tr
395- . map_bound ( |tr| {
396- let trait_substs = translate_predicate_substs ( tr. trait_ref . substs ) ;
397- ty:: TraitRef { def_id : tr. def_id ( ) , substs : trait_substs }
398- } )
399- . with_constness ( * c)
400- . to_predicate ( tcx) ,
401- ty:: PredicateKind :: Projection ( poly_projection) => poly_projection
402- . map_bound ( |projection| {
403- let projection_substs = translate_predicate_substs ( projection. projection_ty . substs ) ;
404- ty:: ProjectionPredicate {
405- projection_ty : ty:: ProjectionTy {
406- substs : projection_substs,
407- item_def_id : projection. projection_ty . item_def_id ,
408- } ,
409- ty : projection. ty . subst ( tcx, assoc_item_substs) ,
410- }
411- } )
412- . to_predicate ( tcx) ,
413- ty:: PredicateKind :: TypeOutlives ( poly_outlives) => poly_outlives
414- . map_bound ( |outlives| {
415- ty:: OutlivesPredicate (
416- normalized_projection_ty,
417- outlives. 1 . subst ( tcx, assoc_item_substs) ,
418- )
419- } )
420- . to_predicate ( tcx) ,
421- _ => bug ! ( "unexepected projection bound: `{:?}`" , bound) ,
422- }
423- }
424-
425360pub enum TupleArgumentsFlag {
426361 Yes ,
427362 No ,
0 commit comments