@@ -93,7 +93,8 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
9393
9494fn external_generic_args (
9595 cx : & mut DocContext < ' _ > ,
96- trait_did : Option < DefId > ,
96+ did : DefId ,
97+ is_trait : bool ,
9798 has_self : bool ,
9899 bindings : Vec < TypeBinding > ,
99100 substs : SubstsRef < ' _ > ,
@@ -121,32 +122,30 @@ fn external_generic_args(
121122 } )
122123 . collect ( ) ;
123124
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 }
141140 }
142141}
143142
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
145144/// from `Fn<(A, B,), C>` to `Fn(A, B) -> C`
146145pub ( super ) fn external_path (
147146 cx : & mut DocContext < ' _ > ,
148147 did : DefId ,
149- trait_did : Option < DefId > ,
148+ is_trait : bool ,
150149 has_self : bool ,
151150 bindings : Vec < TypeBinding > ,
152151 substs : SubstsRef < ' _ > ,
@@ -158,7 +157,7 @@ pub(super) fn external_path(
158157 res : Res :: Def ( def_kind, did) ,
159158 segments : vec ! [ PathSegment {
160159 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) ,
162161 } ] ,
163162 }
164163}
0 commit comments