@@ -1288,56 +1288,84 @@ impl clean::Impl {
12881288 if self . is_negative_trait_impl ( ) {
12891289 write ! ( f, "!" ) ?;
12901290 }
1291- ty. print ( cx) . fmt ( f) ?;
1291+ if self . kind . is_fake_variadic ( )
1292+ && let generics = ty. generics ( )
1293+ && let & [ inner_type] = generics. as_ref ( ) . map_or ( & [ ] [ ..] , |v| & v[ ..] )
1294+ {
1295+ let last = ty. last ( ) ;
1296+ if f. alternate ( ) {
1297+ write ! ( f, "{}<" , last) ?;
1298+ self . print_type ( inner_type, f, use_absolute, cx) ?;
1299+ write ! ( f, ">" ) ?;
1300+ } else {
1301+ write ! ( f, "{}<" , anchor( ty. def_id( ) , last, cx) . to_string( ) ) ?;
1302+ self . print_type ( inner_type, f, use_absolute, cx) ?;
1303+ write ! ( f, ">" ) ?;
1304+ }
1305+ } else {
1306+ ty. print ( cx) . fmt ( f) ?;
1307+ }
12921308 write ! ( f, " for " ) ?;
12931309 }
12941310
1295- if let clean:: Type :: Tuple ( types) = & self . for_
1296- && let [ clean:: Type :: Generic ( name) ] = & types[ ..]
1297- && ( self . kind . is_fake_variadic ( ) || self . kind . is_auto ( ) )
1298- {
1299- // Hardcoded anchor library/core/src/primitive_docs.rs
1300- // Link should match `# Trait implementations`
1301- primitive_link_fragment (
1302- f,
1303- PrimitiveType :: Tuple ,
1304- format_args ! ( "({name}₁, {name}₂, …, {name}ₙ)" ) ,
1305- "#trait-implementations-1" ,
1306- cx,
1307- ) ?;
1308- } else if let clean:: BareFunction ( bare_fn) = & self . for_
1309- && let [ clean:: Argument { type_ : clean:: Type :: Generic ( name) , .. } ] =
1310- & bare_fn. decl . inputs . values [ ..]
1311- && ( self . kind . is_fake_variadic ( ) || self . kind . is_auto ( ) )
1312- {
1313- // Hardcoded anchor library/core/src/primitive_docs.rs
1314- // Link should match `# Trait implementations`
1315-
1316- print_higher_ranked_params_with_space ( & bare_fn. generic_params , cx) . fmt ( f) ?;
1317- bare_fn. safety . print_with_space ( ) . fmt ( f) ?;
1318- print_abi_with_space ( bare_fn. abi ) . fmt ( f) ?;
1319- let ellipsis = if bare_fn. decl . c_variadic { ", ..." } else { "" } ;
1320- primitive_link_fragment (
1321- f,
1322- PrimitiveType :: Tuple ,
1323- format_args ! ( "fn({name}₁, {name}₂, …, {name}ₙ{ellipsis})" ) ,
1324- "#trait-implementations-1" ,
1325- cx,
1326- ) ?;
1327- // Write output.
1328- if !bare_fn. decl . output . is_unit ( ) {
1329- write ! ( f, " -> " ) ?;
1330- fmt_type ( & bare_fn. decl . output , f, use_absolute, cx) ?;
1331- }
1332- } else if let Some ( ty) = self . kind . as_blanket_ty ( ) {
1311+ if let Some ( ty) = self . kind . as_blanket_ty ( ) {
13331312 fmt_type ( ty, f, use_absolute, cx) ?;
13341313 } else {
1335- fmt_type ( & self . for_ , f, use_absolute, cx) ?;
1314+ self . print_type ( & self . for_ , f, use_absolute, cx) ?;
13361315 }
13371316
13381317 print_where_clause ( & self . generics , cx, 0 , Ending :: Newline ) . fmt ( f)
13391318 } )
13401319 }
1320+ fn print_type < ' a , ' tcx : ' a > ( & self , type_ : & clean:: Type , f : & mut fmt:: Formatter < ' _ > , use_absolute : bool , cx : & ' a Context < ' tcx > ) -> Result < ( ) , fmt:: Error > {
1321+ if let clean:: Type :: Tuple ( types) = type_
1322+ && let [ clean:: Type :: Generic ( name) ] = & types[ ..]
1323+ && ( self . kind . is_fake_variadic ( ) || self . kind . is_auto ( ) )
1324+ {
1325+ // Hardcoded anchor library/core/src/primitive_docs.rs
1326+ // Link should match `# Trait implementations`
1327+ primitive_link_fragment (
1328+ f,
1329+ PrimitiveType :: Tuple ,
1330+ format_args ! ( "({name}₁, {name}₂, …, {name}ₙ)" ) ,
1331+ "#trait-implementations-1" ,
1332+ cx,
1333+ ) ?;
1334+ } else if let clean:: Type :: Array ( ty, len) = type_
1335+ && let clean:: Type :: Generic ( name) = & * * ty
1336+ && & len[ ..] == "1"
1337+ && ( self . kind . is_fake_variadic ( ) || self . kind . is_auto ( ) )
1338+ {
1339+ primitive_link ( f, PrimitiveType :: Array , format_args ! ( "[{name}; N]" ) , cx) ?;
1340+ } else if let clean:: BareFunction ( bare_fn) = & type_
1341+ && let [ clean:: Argument { type_ : clean:: Type :: Generic ( name) , .. } ] =
1342+ & bare_fn. decl . inputs . values [ ..]
1343+ && ( self . kind . is_fake_variadic ( ) || self . kind . is_auto ( ) )
1344+ {
1345+ // Hardcoded anchor library/core/src/primitive_docs.rs
1346+ // Link should match `# Trait implementations`
1347+
1348+ print_higher_ranked_params_with_space ( & bare_fn. generic_params , cx) . fmt ( f) ?;
1349+ bare_fn. safety . print_with_space ( ) . fmt ( f) ?;
1350+ print_abi_with_space ( bare_fn. abi ) . fmt ( f) ?;
1351+ let ellipsis = if bare_fn. decl . c_variadic { ", ..." } else { "" } ;
1352+ primitive_link_fragment (
1353+ f,
1354+ PrimitiveType :: Tuple ,
1355+ format_args ! ( "fn({name}₁, {name}₂, …, {name}ₙ{ellipsis})" ) ,
1356+ "#trait-implementations-1" ,
1357+ cx,
1358+ ) ?;
1359+ // Write output.
1360+ if !bare_fn. decl . output . is_unit ( ) {
1361+ write ! ( f, " -> " ) ?;
1362+ fmt_type ( & bare_fn. decl . output , f, use_absolute, cx) ?;
1363+ }
1364+ } else {
1365+ fmt_type ( & type_, f, use_absolute, cx) ?;
1366+ }
1367+ Ok ( ( ) )
1368+ }
13411369}
13421370
13431371impl clean:: Arguments {
0 commit comments