@@ -2413,22 +2413,22 @@ fn sidebar_enum(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, e: &clean:
2413
2413
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
2414
2414
enum ItemSection {
2415
2415
Reexports ,
2416
+ PrimitiveTypes ,
2416
2417
Modules ,
2418
+ Macros ,
2417
2419
Structs ,
2418
- Unions ,
2419
2420
Enums ,
2420
- Functions ,
2421
- TypeDefinitions ,
2422
- Statics ,
2423
2421
Constants ,
2422
+ Statics ,
2424
2423
Traits ,
2424
+ Functions ,
2425
+ TypeDefinitions ,
2426
+ Unions ,
2425
2427
Implementations ,
2426
2428
TypeMethods ,
2427
2429
Methods ,
2428
2430
StructFields ,
2429
2431
Variants ,
2430
- Macros ,
2431
- PrimitiveTypes ,
2432
2432
AssociatedTypes ,
2433
2433
AssociatedConstants ,
2434
2434
ForeignTypes ,
@@ -2440,6 +2440,38 @@ enum ItemSection {
2440
2440
}
2441
2441
2442
2442
impl ItemSection {
2443
+ const ALL : & ' static [ Self ] = {
2444
+ use ItemSection :: * ;
2445
+ // NOTE: The order here affects the order in the UI.
2446
+ & [
2447
+ Reexports ,
2448
+ PrimitiveTypes ,
2449
+ Modules ,
2450
+ Macros ,
2451
+ Structs ,
2452
+ Enums ,
2453
+ Constants ,
2454
+ Statics ,
2455
+ Traits ,
2456
+ Functions ,
2457
+ TypeDefinitions ,
2458
+ Unions ,
2459
+ Implementations ,
2460
+ TypeMethods ,
2461
+ Methods ,
2462
+ StructFields ,
2463
+ Variants ,
2464
+ AssociatedTypes ,
2465
+ AssociatedConstants ,
2466
+ ForeignTypes ,
2467
+ Keywords ,
2468
+ OpaqueTypes ,
2469
+ AttributeMacros ,
2470
+ DeriveMacros ,
2471
+ TraitAliases ,
2472
+ ]
2473
+ } ;
2474
+
2443
2475
fn id ( self ) -> & ' static str {
2444
2476
match self {
2445
2477
Self :: Reexports => "reexports" ,
@@ -2535,39 +2567,13 @@ fn item_ty_to_section(ty: ItemType) -> ItemSection {
2535
2567
fn sidebar_module ( buf : & mut Buffer , items : & [ clean:: Item ] ) {
2536
2568
let mut sidebar = String :: new ( ) ;
2537
2569
2538
- let mut already_emitted_sections = FxHashSet :: default ( ) ;
2539
- // ordering taken from item_module, reorder, where it prioritized elements in a certain order
2540
- // to print its headings
2541
- for & myty in & [
2542
- ItemType :: Import ,
2543
- ItemType :: Primitive ,
2544
- ItemType :: Module ,
2545
- ItemType :: Macro ,
2546
- ItemType :: Struct ,
2547
- ItemType :: Enum ,
2548
- ItemType :: Constant ,
2549
- ItemType :: Static ,
2550
- ItemType :: Trait ,
2551
- ItemType :: Function ,
2552
- ItemType :: Typedef ,
2553
- ItemType :: Union ,
2554
- ItemType :: Impl ,
2555
- ItemType :: TyMethod ,
2556
- ItemType :: Method ,
2557
- ItemType :: StructField ,
2558
- ItemType :: Variant ,
2559
- ItemType :: AssocType ,
2560
- ItemType :: AssocConst ,
2561
- ItemType :: ForeignType ,
2562
- ItemType :: Keyword ,
2563
- ] {
2564
- if items. iter ( ) . any ( |it| !it. is_stripped ( ) && it. type_ ( ) == myty && it. name . is_some ( ) ) {
2565
- let sec = item_ty_to_section ( myty) ;
2566
- if !already_emitted_sections. insert ( sec) {
2567
- continue ;
2568
- }
2569
- sidebar. push_str ( & format ! ( "<li><a href=\" #{}\" >{}</a></li>" , sec. id( ) , sec. name( ) ) ) ;
2570
- }
2570
+ let item_sections_in_use: FxHashSet < _ > = items
2571
+ . iter ( )
2572
+ . filter ( |it| !it. is_stripped ( ) && it. name . is_some ( ) )
2573
+ . map ( |it| item_ty_to_section ( it. type_ ( ) ) )
2574
+ . collect ( ) ;
2575
+ for & sec in ItemSection :: ALL . iter ( ) . filter ( |sec| item_sections_in_use. contains ( sec) ) {
2576
+ sidebar. push_str ( & format ! ( "<li><a href=\" #{}\" >{}</a></li>" , sec. id( ) , sec. name( ) ) ) ;
2571
2577
}
2572
2578
2573
2579
if !sidebar. is_empty ( ) {
0 commit comments