@@ -77,16 +77,12 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
77
77
Crate { module, primitives, external_traits : cx. external_traits . clone ( ) }
78
78
}
79
79
80
- fn external_generic_args (
80
+ crate fn substs_to_args (
81
81
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
90
86
. iter ( )
91
87
. filter_map ( |kind| match kind. unpack ( ) {
92
88
GenericArgKind :: Lifetime ( lt) => match * lt {
@@ -95,23 +91,32 @@ fn external_generic_args(
95
91
}
96
92
_ => lt. clean ( cx) . map ( GenericArg :: Lifetime ) ,
97
93
} ,
98
- GenericArgKind :: Type ( _) if skip_self => {
99
- skip_self = false ;
94
+ GenericArgKind :: Type ( _) if skip_first => {
95
+ skip_first = false ;
100
96
None
101
97
}
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) ) ) ,
106
99
GenericArgKind :: Const ( ct) => Some ( GenericArg :: Const ( Box :: new ( ct. clean ( cx) ) ) ) ,
107
100
} )
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) ;
109
112
110
113
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
+ } ;
115
120
let output = None ;
116
121
// FIXME(#20299) return type comes from a projection now
117
122
// match types[1].kind {
0 commit comments