@@ -1541,6 +1541,7 @@ struct AllTypes {
15411541 typedefs : HashSet < ItemEntry > ,
15421542 statics : HashSet < ItemEntry > ,
15431543 constants : HashSet < ItemEntry > ,
1544+ keywords : HashSet < ItemEntry > ,
15441545}
15451546
15461547impl AllTypes {
@@ -1556,6 +1557,7 @@ impl AllTypes {
15561557 typedefs : HashSet :: with_capacity ( 100 ) ,
15571558 statics : HashSet :: with_capacity ( 100 ) ,
15581559 constants : HashSet :: with_capacity ( 100 ) ,
1560+ keywords : HashSet :: with_capacity ( 100 ) ,
15591561 }
15601562 }
15611563
@@ -2063,12 +2065,13 @@ impl<'a> fmt::Display for Item<'a> {
20632065 clean:: StaticItem ( ..) | clean:: ForeignStaticItem ( ..) => write ! ( fmt, "Static " ) ?,
20642066 clean:: ConstantItem ( ..) => write ! ( fmt, "Constant " ) ?,
20652067 clean:: ForeignTypeItem => write ! ( fmt, "Foreign Type " ) ?,
2068+ clean:: KeywordItem ( ..) => write ! ( fmt, "Keyword " ) ?,
20662069 _ => {
20672070 // We don't generate pages for any other type.
20682071 unreachable ! ( ) ;
20692072 }
20702073 }
2071- if !self . item . is_primitive ( ) {
2074+ if !self . item . is_primitive ( ) && ! self . item . is_keyword ( ) {
20722075 let cur = & self . cx . current ;
20732076 let amt = if self . item . is_mod ( ) { cur. len ( ) - 1 } else { cur. len ( ) } ;
20742077 for ( i, component) in cur. iter ( ) . enumerate ( ) . take ( amt) {
@@ -2126,6 +2129,7 @@ impl<'a> fmt::Display for Item<'a> {
21262129 item_static ( fmt, self . cx , self . item , i) ,
21272130 clean:: ConstantItem ( ref c) => item_constant ( fmt, self . cx , self . item , c) ,
21282131 clean:: ForeignTypeItem => item_foreign_type ( fmt, self . cx , self . item ) ,
2132+ clean:: KeywordItem ( ref k) => item_keyword ( fmt, self . cx , self . item , k) ,
21292133 _ => {
21302134 // We don't generate pages for any other type.
21312135 unreachable ! ( ) ;
@@ -2353,29 +2357,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
23532357 write ! ( w, "</table>" ) ?;
23542358 }
23552359 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 ( ) ) ;
23792361 write ! ( w, "<h2 id='{id}' class='section-header'>\
23802362 <a href=\" #{id}\" >{name}</a></h2>\n <table>",
23812363 id = derive_id( short. to_owned( ) ) , name = name) ?;
@@ -4360,6 +4342,33 @@ fn sidebar_enum(fmt: &mut fmt::Formatter, it: &clean::Item,
43604342 Ok ( ( ) )
43614343}
43624344
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+
43634372fn sidebar_module ( fmt : & mut fmt:: Formatter , _it : & clean:: Item ,
43644373 items : & [ clean:: Item ] ) -> fmt:: Result {
43654374 let mut sidebar = String :: new ( ) ;
@@ -4379,29 +4388,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item,
43794388 ItemType :: TyMethod , ItemType :: Method , ItemType :: StructField , ItemType :: Variant ,
43804389 ItemType :: AssociatedType , ItemType :: AssociatedConst , ItemType :: ForeignType ] {
43814390 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) ;
44054392 sidebar. push_str ( & format ! ( "<li><a href=\" #{id}\" >{name}</a></li>" ,
44064393 id = short,
44074394 name = name) ) ;
@@ -4462,6 +4449,12 @@ fn item_primitive(w: &mut fmt::Formatter, cx: &Context,
44624449 render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
44634450}
44644451
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+
44654458const BASIC_KEYWORDS : & ' static str = "rust, rustlang, rust-lang" ;
44664459
44674460fn make_item_keywords ( it : & clean:: Item ) -> String {
0 commit comments