@@ -1288,56 +1288,90 @@ impl clean::Impl {
1288
1288
if self . is_negative_trait_impl ( ) {
1289
1289
write ! ( f, "!" ) ?;
1290
1290
}
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
+ }
1292
1308
write ! ( f, " for " ) ?;
1293
1309
}
1294
1310
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 ( ) {
1333
1312
fmt_type ( ty, f, use_absolute, cx) ?;
1334
1313
} else {
1335
- fmt_type ( & self . for_ , f, use_absolute, cx) ?;
1314
+ self . print_type ( & self . for_ , f, use_absolute, cx) ?;
1336
1315
}
1337
1316
1338
1317
print_where_clause ( & self . generics , cx, 0 , Ending :: Newline ) . fmt ( f)
1339
1318
} )
1340
1319
}
1320
+ fn print_type < ' a , ' tcx : ' a > (
1321
+ & self ,
1322
+ type_ : & clean:: Type ,
1323
+ f : & mut fmt:: Formatter < ' _ > ,
1324
+ use_absolute : bool ,
1325
+ cx : & ' a Context < ' tcx > ,
1326
+ ) -> Result < ( ) , fmt:: Error > {
1327
+ if let clean:: Type :: Tuple ( types) = type_
1328
+ && let [ clean:: Type :: Generic ( name) ] = & types[ ..]
1329
+ && ( self . kind . is_fake_variadic ( ) || self . kind . is_auto ( ) )
1330
+ {
1331
+ // Hardcoded anchor library/core/src/primitive_docs.rs
1332
+ // Link should match `# Trait implementations`
1333
+ primitive_link_fragment (
1334
+ f,
1335
+ PrimitiveType :: Tuple ,
1336
+ format_args ! ( "({name}₁, {name}₂, …, {name}ₙ)" ) ,
1337
+ "#trait-implementations-1" ,
1338
+ cx,
1339
+ ) ?;
1340
+ } else if let clean:: Type :: Array ( ty, len) = type_
1341
+ && let clean:: Type :: Generic ( name) = & * * ty
1342
+ && & len[ ..] == "1"
1343
+ && ( self . kind . is_fake_variadic ( ) || self . kind . is_auto ( ) )
1344
+ {
1345
+ primitive_link ( f, PrimitiveType :: Array , format_args ! ( "[{name}; N]" ) , cx) ?;
1346
+ } else if let clean:: BareFunction ( bare_fn) = & type_
1347
+ && let [ clean:: Argument { type_ : clean:: Type :: Generic ( name) , .. } ] =
1348
+ & bare_fn. decl . inputs . values [ ..]
1349
+ && ( self . kind . is_fake_variadic ( ) || self . kind . is_auto ( ) )
1350
+ {
1351
+ // Hardcoded anchor library/core/src/primitive_docs.rs
1352
+ // Link should match `# Trait implementations`
1353
+
1354
+ print_higher_ranked_params_with_space ( & bare_fn. generic_params , cx) . fmt ( f) ?;
1355
+ bare_fn. safety . print_with_space ( ) . fmt ( f) ?;
1356
+ print_abi_with_space ( bare_fn. abi ) . fmt ( f) ?;
1357
+ let ellipsis = if bare_fn. decl . c_variadic { ", ..." } else { "" } ;
1358
+ primitive_link_fragment (
1359
+ f,
1360
+ PrimitiveType :: Tuple ,
1361
+ format_args ! ( "fn({name}₁, {name}₂, …, {name}ₙ{ellipsis})" ) ,
1362
+ "#trait-implementations-1" ,
1363
+ cx,
1364
+ ) ?;
1365
+ // Write output.
1366
+ if !bare_fn. decl . output . is_unit ( ) {
1367
+ write ! ( f, " -> " ) ?;
1368
+ fmt_type ( & bare_fn. decl . output , f, use_absolute, cx) ?;
1369
+ }
1370
+ } else {
1371
+ fmt_type ( & type_, f, use_absolute, cx) ?;
1372
+ }
1373
+ Ok ( ( ) )
1374
+ }
1341
1375
}
1342
1376
1343
1377
impl clean:: Arguments {
0 commit comments