@@ -16,9 +16,7 @@ use rustc_hir::lang_items::LangItem;
16
16
use rustc_infer:: infer:: { DefineOpaqueTypes , HigherRankedType , InferOk } ;
17
17
use rustc_infer:: traits:: ObligationCauseCode ;
18
18
use 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 } ;
22
20
use rustc_middle:: { bug, span_bug} ;
23
21
use rustc_span:: def_id:: DefId ;
24
22
use tracing:: { debug, instrument} ;
@@ -638,60 +636,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
638
636
// higher-ranked things.
639
637
// Prevent, e.g., `dyn Iterator<Item = str>`.
640
638
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
- } ;
689
639
let normalized_bound = normalize_with_depth_to (
690
640
self ,
691
641
obligation. param_env ,
692
642
obligation. cause . clone ( ) ,
693
643
obligation. recursion_depth + 1 ,
694
- arg_bound ,
644
+ bound . instantiate ( tcx , trait_predicate . trait_ref . args ) ,
695
645
& mut nested,
696
646
) ;
697
647
nested. push ( obligation. with ( tcx, normalized_bound) ) ;
0 commit comments