@@ -1541,6 +1541,7 @@ struct AllTypes {
1541
1541
typedefs : HashSet < ItemEntry > ,
1542
1542
statics : HashSet < ItemEntry > ,
1543
1543
constants : HashSet < ItemEntry > ,
1544
+ keywords : HashSet < ItemEntry > ,
1544
1545
}
1545
1546
1546
1547
impl AllTypes {
@@ -1556,6 +1557,7 @@ impl AllTypes {
1556
1557
typedefs : HashSet :: with_capacity ( 100 ) ,
1557
1558
statics : HashSet :: with_capacity ( 100 ) ,
1558
1559
constants : HashSet :: with_capacity ( 100 ) ,
1560
+ keywords : HashSet :: with_capacity ( 100 ) ,
1559
1561
}
1560
1562
}
1561
1563
@@ -2063,12 +2065,13 @@ impl<'a> fmt::Display for Item<'a> {
2063
2065
clean:: StaticItem ( ..) | clean:: ForeignStaticItem ( ..) => write ! ( fmt, "Static " ) ?,
2064
2066
clean:: ConstantItem ( ..) => write ! ( fmt, "Constant " ) ?,
2065
2067
clean:: ForeignTypeItem => write ! ( fmt, "Foreign Type " ) ?,
2068
+ clean:: KeywordItem ( ..) => write ! ( fmt, "Keyword " ) ?,
2066
2069
_ => {
2067
2070
// We don't generate pages for any other type.
2068
2071
unreachable ! ( ) ;
2069
2072
}
2070
2073
}
2071
- if !self . item . is_primitive ( ) {
2074
+ if !self . item . is_primitive ( ) && ! self . item . is_keyword ( ) {
2072
2075
let cur = & self . cx . current ;
2073
2076
let amt = if self . item . is_mod ( ) { cur. len ( ) - 1 } else { cur. len ( ) } ;
2074
2077
for ( i, component) in cur. iter ( ) . enumerate ( ) . take ( amt) {
@@ -2126,6 +2129,7 @@ impl<'a> fmt::Display for Item<'a> {
2126
2129
item_static ( fmt, self . cx , self . item , i) ,
2127
2130
clean:: ConstantItem ( ref c) => item_constant ( fmt, self . cx , self . item , c) ,
2128
2131
clean:: ForeignTypeItem => item_foreign_type ( fmt, self . cx , self . item ) ,
2132
+ clean:: KeywordItem ( ref k) => item_keyword ( fmt, self . cx , self . item , k) ,
2129
2133
_ => {
2130
2134
// We don't generate pages for any other type.
2131
2135
unreachable ! ( ) ;
@@ -2353,29 +2357,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
2353
2357
write ! ( w, "</table>" ) ?;
2354
2358
}
2355
2359
curty = myty;
2356
- let ( short, name) = match myty. unwrap ( ) {
2357
- ItemType :: ExternCrate |
2358
- ItemType :: Import => ( "reexports" , "Re-exports" ) ,
2359
- ItemType :: Module => ( "modules" , "Modules" ) ,
2360
- ItemType :: Struct => ( "structs" , "Structs" ) ,
2361
- ItemType :: Union => ( "unions" , "Unions" ) ,
2362
- ItemType :: Enum => ( "enums" , "Enums" ) ,
2363
- ItemType :: Function => ( "functions" , "Functions" ) ,
2364
- ItemType :: Typedef => ( "types" , "Type Definitions" ) ,
2365
- ItemType :: Static => ( "statics" , "Statics" ) ,
2366
- ItemType :: Constant => ( "constants" , "Constants" ) ,
2367
- ItemType :: Trait => ( "traits" , "Traits" ) ,
2368
- ItemType :: Impl => ( "impls" , "Implementations" ) ,
2369
- ItemType :: TyMethod => ( "tymethods" , "Type Methods" ) ,
2370
- ItemType :: Method => ( "methods" , "Methods" ) ,
2371
- ItemType :: StructField => ( "fields" , "Struct Fields" ) ,
2372
- ItemType :: Variant => ( "variants" , "Variants" ) ,
2373
- ItemType :: Macro => ( "macros" , "Macros" ) ,
2374
- ItemType :: Primitive => ( "primitives" , "Primitive Types" ) ,
2375
- ItemType :: AssociatedType => ( "associated-types" , "Associated Types" ) ,
2376
- ItemType :: AssociatedConst => ( "associated-consts" , "Associated Constants" ) ,
2377
- ItemType :: ForeignType => ( "foreign-types" , "Foreign Types" ) ,
2378
- } ;
2360
+ let ( short, name) = item_ty_to_strs ( & myty. unwrap ( ) ) ;
2379
2361
write ! ( w, "<h2 id='{id}' class='section-header'>\
2380
2362
<a href=\" #{id}\" >{name}</a></h2>\n <table>",
2381
2363
id = derive_id( short. to_owned( ) ) , name = name) ?;
@@ -4360,6 +4342,33 @@ fn sidebar_enum(fmt: &mut fmt::Formatter, it: &clean::Item,
4360
4342
Ok ( ( ) )
4361
4343
}
4362
4344
4345
+ fn item_ty_to_strs ( ty : & ItemType ) -> ( & ' static str , & ' static str ) {
4346
+ match * ty {
4347
+ ItemType :: ExternCrate |
4348
+ ItemType :: Import => ( "reexports" , "Re-exports" ) ,
4349
+ ItemType :: Module => ( "modules" , "Modules" ) ,
4350
+ ItemType :: Struct => ( "structs" , "Structs" ) ,
4351
+ ItemType :: Union => ( "unions" , "Unions" ) ,
4352
+ ItemType :: Enum => ( "enums" , "Enums" ) ,
4353
+ ItemType :: Function => ( "functions" , "Functions" ) ,
4354
+ ItemType :: Typedef => ( "types" , "Type Definitions" ) ,
4355
+ ItemType :: Static => ( "statics" , "Statics" ) ,
4356
+ ItemType :: Constant => ( "constants" , "Constants" ) ,
4357
+ ItemType :: Trait => ( "traits" , "Traits" ) ,
4358
+ ItemType :: Impl => ( "impls" , "Implementations" ) ,
4359
+ ItemType :: TyMethod => ( "tymethods" , "Type Methods" ) ,
4360
+ ItemType :: Method => ( "methods" , "Methods" ) ,
4361
+ ItemType :: StructField => ( "fields" , "Struct Fields" ) ,
4362
+ ItemType :: Variant => ( "variants" , "Variants" ) ,
4363
+ ItemType :: Macro => ( "macros" , "Macros" ) ,
4364
+ ItemType :: Primitive => ( "primitives" , "Primitive Types" ) ,
4365
+ ItemType :: AssociatedType => ( "associated-types" , "Associated Types" ) ,
4366
+ ItemType :: AssociatedConst => ( "associated-consts" , "Associated Constants" ) ,
4367
+ ItemType :: ForeignType => ( "foreign-types" , "Foreign Types" ) ,
4368
+ ItemType :: Keyword => ( "keywords" , "Keywords" ) ,
4369
+ }
4370
+ }
4371
+
4363
4372
fn sidebar_module ( fmt : & mut fmt:: Formatter , _it : & clean:: Item ,
4364
4373
items : & [ clean:: Item ] ) -> fmt:: Result {
4365
4374
let mut sidebar = String :: new ( ) ;
@@ -4379,29 +4388,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item,
4379
4388
ItemType :: TyMethod , ItemType :: Method , ItemType :: StructField , ItemType :: Variant ,
4380
4389
ItemType :: AssociatedType , ItemType :: AssociatedConst , ItemType :: ForeignType ] {
4381
4390
if items. iter ( ) . any ( |it| !it. is_stripped ( ) && it. type_ ( ) == myty) {
4382
- let ( short, name) = match myty {
4383
- ItemType :: ExternCrate |
4384
- ItemType :: Import => ( "reexports" , "Re-exports" ) ,
4385
- ItemType :: Module => ( "modules" , "Modules" ) ,
4386
- ItemType :: Struct => ( "structs" , "Structs" ) ,
4387
- ItemType :: Union => ( "unions" , "Unions" ) ,
4388
- ItemType :: Enum => ( "enums" , "Enums" ) ,
4389
- ItemType :: Function => ( "functions" , "Functions" ) ,
4390
- ItemType :: Typedef => ( "types" , "Type Definitions" ) ,
4391
- ItemType :: Static => ( "statics" , "Statics" ) ,
4392
- ItemType :: Constant => ( "constants" , "Constants" ) ,
4393
- ItemType :: Trait => ( "traits" , "Traits" ) ,
4394
- ItemType :: Impl => ( "impls" , "Implementations" ) ,
4395
- ItemType :: TyMethod => ( "tymethods" , "Type Methods" ) ,
4396
- ItemType :: Method => ( "methods" , "Methods" ) ,
4397
- ItemType :: StructField => ( "fields" , "Struct Fields" ) ,
4398
- ItemType :: Variant => ( "variants" , "Variants" ) ,
4399
- ItemType :: Macro => ( "macros" , "Macros" ) ,
4400
- ItemType :: Primitive => ( "primitives" , "Primitive Types" ) ,
4401
- ItemType :: AssociatedType => ( "associated-types" , "Associated Types" ) ,
4402
- ItemType :: AssociatedConst => ( "associated-consts" , "Associated Constants" ) ,
4403
- ItemType :: ForeignType => ( "foreign-types" , "Foreign Types" ) ,
4404
- } ;
4391
+ let ( short, name) = item_ty_to_strs ( & myty) ;
4405
4392
sidebar. push_str ( & format ! ( "<li><a href=\" #{id}\" >{name}</a></li>" ,
4406
4393
id = short,
4407
4394
name = name) ) ;
@@ -4462,6 +4449,12 @@ fn item_primitive(w: &mut fmt::Formatter, cx: &Context,
4462
4449
render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
4463
4450
}
4464
4451
4452
+ fn item_keyword ( w : & mut fmt:: Formatter , cx : & Context ,
4453
+ it : & clean:: Item ,
4454
+ _p : & str ) -> fmt:: Result {
4455
+ document ( w, cx, it)
4456
+ }
4457
+
4465
4458
const BASIC_KEYWORDS : & ' static str = "rust, rustlang, rust-lang" ;
4466
4459
4467
4460
fn make_item_keywords ( it : & clean:: Item ) -> String {
0 commit comments