@@ -93,7 +93,8 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
93
93
94
94
fn external_generic_args (
95
95
cx : & mut DocContext < ' _ > ,
96
- trait_did : Option < DefId > ,
96
+ did : DefId ,
97
+ is_trait : bool ,
97
98
has_self : bool ,
98
99
bindings : Vec < TypeBinding > ,
99
100
substs : SubstsRef < ' _ > ,
@@ -121,32 +122,30 @@ fn external_generic_args(
121
122
} )
122
123
. collect ( ) ;
123
124
124
- match trait_did {
125
- // Attempt to sugar an external path like Fn<(A, B,), C> to Fn(A, B) -> C
126
- Some ( did) if cx. tcx . fn_trait_kind_from_lang_item ( did) . is_some ( ) => {
127
- assert ! ( ty_kind. is_some( ) ) ;
128
- let inputs = match ty_kind {
129
- Some ( ty:: Tuple ( ref tys) ) => tys. iter ( ) . map ( |t| t. expect_ty ( ) . clean ( cx) ) . collect ( ) ,
130
- _ => return GenericArgs :: AngleBracketed { args, bindings } ,
131
- } ;
132
- let output = None ;
133
- // FIXME(#20299) return type comes from a projection now
134
- // match types[1].kind {
135
- // ty::Tuple(ref v) if v.is_empty() => None, // -> ()
136
- // _ => Some(types[1].clean(cx))
137
- // };
138
- GenericArgs :: Parenthesized { inputs, output }
139
- }
140
- _ => GenericArgs :: AngleBracketed { args, bindings } ,
125
+ if is_trait && cx. tcx . fn_trait_kind_from_lang_item ( did) . is_some ( ) {
126
+ assert ! ( ty_kind. is_some( ) ) ;
127
+ let inputs = match ty_kind {
128
+ Some ( ty:: Tuple ( ref tys) ) => tys. iter ( ) . map ( |t| t. expect_ty ( ) . clean ( cx) ) . collect ( ) ,
129
+ _ => return GenericArgs :: AngleBracketed { args, bindings } ,
130
+ } ;
131
+ let output = None ;
132
+ // FIXME(#20299) return type comes from a projection now
133
+ // match types[1].kind {
134
+ // ty::Tuple(ref v) if v.is_empty() => None, // -> ()
135
+ // _ => Some(types[1].clean(cx))
136
+ // };
137
+ GenericArgs :: Parenthesized { inputs, output }
138
+ } else {
139
+ GenericArgs :: AngleBracketed { args, bindings }
141
140
}
142
141
}
143
142
144
- /// trait_did should be set to a trait's DefId if called on a TraitRef, in order to sugar
143
+ /// `is_trait` should be set to `true` if called on a ` TraitRef` , in order to sugar
145
144
/// from `Fn<(A, B,), C>` to `Fn(A, B) -> C`
146
145
pub ( super ) fn external_path (
147
146
cx : & mut DocContext < ' _ > ,
148
147
did : DefId ,
149
- trait_did : Option < DefId > ,
148
+ is_trait : bool ,
150
149
has_self : bool ,
151
150
bindings : Vec < TypeBinding > ,
152
151
substs : SubstsRef < ' _ > ,
@@ -158,7 +157,7 @@ pub(super) fn external_path(
158
157
res : Res :: Def ( def_kind, did) ,
159
158
segments : vec ! [ PathSegment {
160
159
name,
161
- args: external_generic_args( cx, trait_did , has_self, bindings, substs) ,
160
+ args: external_generic_args( cx, did , is_trait , has_self, bindings, substs) ,
162
161
} ] ,
163
162
}
164
163
}
0 commit comments