@@ -77,16 +77,12 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
7777 Crate { module, primitives, external_traits : cx. external_traits . clone ( ) }
7878}
7979
80- fn external_generic_args (
80+ crate fn substs_to_args (
8181 cx : & mut DocContext < ' _ > ,
82- did : DefId ,
83- has_self : bool ,
84- bindings : Vec < TypeBinding > ,
85- substs : SubstsRef < ' _ > ,
86- ) -> GenericArgs {
87- let mut skip_self = has_self;
88- let mut ty_kind = None ;
89- let args: Vec < _ > = substs
82+ substs : & [ ty:: subst:: GenericArg < ' _ > ] ,
83+ mut skip_first : bool ,
84+ ) -> Vec < GenericArg > {
85+ substs
9086 . iter ( )
9187 . filter_map ( |kind| match kind. unpack ( ) {
9288 GenericArgKind :: Lifetime ( lt) => match * lt {
@@ -95,23 +91,32 @@ fn external_generic_args(
9591 }
9692 _ => lt. clean ( cx) . map ( GenericArg :: Lifetime ) ,
9793 } ,
98- GenericArgKind :: Type ( _) if skip_self => {
99- skip_self = false ;
94+ GenericArgKind :: Type ( _) if skip_first => {
95+ skip_first = false ;
10096 None
10197 }
102- GenericArgKind :: Type ( ty) => {
103- ty_kind = Some ( ty. kind ( ) ) ;
104- Some ( GenericArg :: Type ( ty. clean ( cx) ) )
105- }
98+ GenericArgKind :: Type ( ty) => Some ( GenericArg :: Type ( ty. clean ( cx) ) ) ,
10699 GenericArgKind :: Const ( ct) => Some ( GenericArg :: Const ( Box :: new ( ct. clean ( cx) ) ) ) ,
107100 } )
108- . collect ( ) ;
101+ . collect ( )
102+ }
103+
104+ fn external_generic_args (
105+ cx : & mut DocContext < ' _ > ,
106+ did : DefId ,
107+ has_self : bool ,
108+ bindings : Vec < TypeBinding > ,
109+ substs : SubstsRef < ' _ > ,
110+ ) -> GenericArgs {
111+ let args = substs_to_args ( cx, & substs, has_self) ;
109112
110113 if cx. tcx . fn_trait_kind_from_lang_item ( did) . is_some ( ) {
111- let inputs = match ty_kind. unwrap ( ) {
112- ty:: Tuple ( tys) => tys. iter ( ) . map ( |t| t. clean ( cx) ) . collect ( ) ,
113- _ => return GenericArgs :: AngleBracketed { args, bindings : bindings. into ( ) } ,
114- } ;
114+ let inputs =
115+ // The trait's first substitution is the one after self, if there is one.
116+ match substs. iter ( ) . nth ( if has_self { 1 } else { 0 } ) . unwrap ( ) . expect_ty ( ) . kind ( ) {
117+ ty:: Tuple ( tys) => tys. iter ( ) . map ( |t| t. clean ( cx) ) . collect ( ) ,
118+ _ => return GenericArgs :: AngleBracketed { args, bindings : bindings. into ( ) } ,
119+ } ;
115120 let output = None ;
116121 // FIXME(#20299) return type comes from a projection now
117122 // match types[1].kind {
0 commit comments