@@ -16,9 +16,7 @@ use rustc_hir::lang_items::LangItem;
1616use rustc_infer:: infer:: { DefineOpaqueTypes , HigherRankedType , InferOk } ;
1717use rustc_infer:: traits:: ObligationCauseCode ;
1818use rustc_middle:: traits:: { BuiltinImplSource , SignatureMismatchData } ;
19- use rustc_middle:: ty:: {
20- self , GenericArgs , GenericArgsRef , GenericParamDefKind , ToPolyTraitRef , Ty , TyCtxt , Upcast ,
21- } ;
19+ use rustc_middle:: ty:: { self , GenericArgsRef , ToPolyTraitRef , Ty , TyCtxt , Upcast } ;
2220use rustc_middle:: { bug, span_bug} ;
2321use rustc_span:: def_id:: DefId ;
2422use tracing:: { debug, instrument} ;
@@ -638,60 +636,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
638636 // higher-ranked things.
639637 // Prevent, e.g., `dyn Iterator<Item = str>`.
640638 for bound in self . tcx ( ) . item_bounds ( assoc_type) . transpose_iter ( ) {
641- let arg_bound = if defs. is_empty ( ) {
642- bound. instantiate ( tcx, trait_predicate. trait_ref . args )
643- } else {
644- let mut args = smallvec:: SmallVec :: with_capacity ( defs. count ( ) ) ;
645- args. extend ( trait_predicate. trait_ref . args . iter ( ) ) ;
646- let mut bound_vars: smallvec:: SmallVec < [ ty:: BoundVariableKind ; 8 ] > =
647- smallvec:: SmallVec :: with_capacity (
648- bound. skip_binder ( ) . kind ( ) . bound_vars ( ) . len ( ) + defs. count ( ) ,
649- ) ;
650- bound_vars. extend ( bound. skip_binder ( ) . kind ( ) . bound_vars ( ) . into_iter ( ) ) ;
651- GenericArgs :: fill_single ( & mut args, defs, & mut |param, _| match param. kind {
652- GenericParamDefKind :: Type { .. } => {
653- let kind = ty:: BoundTyKind :: Param ( param. def_id , param. name ) ;
654- let bound_var = ty:: BoundVariableKind :: Ty ( kind) ;
655- bound_vars. push ( bound_var) ;
656- Ty :: new_bound ( tcx, ty:: INNERMOST , ty:: BoundTy {
657- var : ty:: BoundVar :: from_usize ( bound_vars. len ( ) - 1 ) ,
658- kind,
659- } )
660- . into ( )
661- }
662- GenericParamDefKind :: Lifetime => {
663- let kind = ty:: BoundRegionKind :: Named ( param. def_id , param. name ) ;
664- let bound_var = ty:: BoundVariableKind :: Region ( kind) ;
665- bound_vars. push ( bound_var) ;
666- ty:: Region :: new_bound ( tcx, ty:: INNERMOST , ty:: BoundRegion {
667- var : ty:: BoundVar :: from_usize ( bound_vars. len ( ) - 1 ) ,
668- kind,
669- } )
670- . into ( )
671- }
672- GenericParamDefKind :: Const { .. } => {
673- let bound_var = ty:: BoundVariableKind :: Const ;
674- bound_vars. push ( bound_var) ;
675- ty:: Const :: new_bound (
676- tcx,
677- ty:: INNERMOST ,
678- ty:: BoundVar :: from_usize ( bound_vars. len ( ) - 1 ) ,
679- )
680- . into ( )
681- }
682- } ) ;
683- let bound_vars = tcx. mk_bound_variable_kinds ( & bound_vars) ;
684- let assoc_ty_args = tcx. mk_args ( & args) ;
685- let bound =
686- bound. map_bound ( |b| b. kind ( ) . skip_binder ( ) ) . instantiate ( tcx, assoc_ty_args) ;
687- ty:: Binder :: bind_with_vars ( bound, bound_vars) . upcast ( tcx)
688- } ;
689639 let normalized_bound = normalize_with_depth_to (
690640 self ,
691641 obligation. param_env ,
692642 obligation. cause . clone ( ) ,
693643 obligation. recursion_depth + 1 ,
694- arg_bound ,
644+ bound . instantiate ( tcx , trait_predicate . trait_ref . args ) ,
695645 & mut nested,
696646 ) ;
697647 nested. push ( obligation. with ( tcx, normalized_bound) ) ;
0 commit comments