@@ -591,7 +591,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
591
591
for & ( did, ref item) in orphan_impl_items {
592
592
if let Some ( & ( ref fqp, _) ) = paths. get ( & did) {
593
593
search_index. push ( IndexItem {
594
- ty : item_type ( item) ,
594
+ ty : item. type_ ( ) ,
595
595
name : item. name . clone ( ) . unwrap ( ) ,
596
596
path : fqp[ ..fqp. len ( ) - 1 ] . join ( "::" ) ,
597
597
desc : Escape ( & shorter ( item. doc_value ( ) ) ) . to_string ( ) ,
@@ -835,11 +835,6 @@ fn mkdir(path: &Path) -> io::Result<()> {
835
835
}
836
836
}
837
837
838
- /// Returns a documentation-level item type from the item.
839
- fn item_type ( item : & clean:: Item ) -> ItemType {
840
- ItemType :: from ( item)
841
- }
842
-
843
838
/// Takes a path to a source file and cleans the path to it. This canonicalizes
844
839
/// things like ".." to components which preserve the "top down" hierarchy of a
845
840
/// static HTML tree. Each component in the cleaned path will be passed as an
@@ -1075,7 +1070,7 @@ impl DocFolder for Cache {
1075
1070
// inserted later on when serializing the search-index.
1076
1071
if item. def_id . index != CRATE_DEF_INDEX {
1077
1072
self . search_index . push ( IndexItem {
1078
- ty : item_type ( & item) ,
1073
+ ty : item. type_ ( ) ,
1079
1074
name : s. to_string ( ) ,
1080
1075
path : path. join ( "::" ) . to_string ( ) ,
1081
1076
desc : Escape ( & shorter ( item. doc_value ( ) ) ) . to_string ( ) ,
@@ -1122,7 +1117,7 @@ impl DocFolder for Cache {
1122
1117
self . access_levels . is_public ( item. def_id )
1123
1118
{
1124
1119
self . paths . insert ( item. def_id ,
1125
- ( self . stack . clone ( ) , item_type ( & item) ) ) ;
1120
+ ( self . stack . clone ( ) , item. type_ ( ) ) ) ;
1126
1121
}
1127
1122
}
1128
1123
// link variants to their parent enum because pages aren't emitted
@@ -1135,7 +1130,7 @@ impl DocFolder for Cache {
1135
1130
1136
1131
clean:: PrimitiveItem ( ..) if item. visibility . is_some ( ) => {
1137
1132
self . paths . insert ( item. def_id , ( self . stack . clone ( ) ,
1138
- item_type ( & item) ) ) ;
1133
+ item. type_ ( ) ) ) ;
1139
1134
}
1140
1135
1141
1136
_ => { }
@@ -1304,7 +1299,7 @@ impl Context {
1304
1299
title. push_str ( it. name . as_ref ( ) . unwrap ( ) ) ;
1305
1300
}
1306
1301
title. push_str ( " - Rust" ) ;
1307
- let tyname = item_type ( it ) . css_class ( ) ;
1302
+ let tyname = it . type_ ( ) . css_class ( ) ;
1308
1303
let desc = if it. is_crate ( ) {
1309
1304
format ! ( "API documentation for the Rust `{}` crate." ,
1310
1305
self . shared. layout. krate)
@@ -1407,7 +1402,7 @@ impl Context {
1407
1402
// buf will be empty if the item is stripped and there is no redirect for it
1408
1403
if !buf. is_empty ( ) {
1409
1404
let name = item. name . as_ref ( ) . unwrap ( ) ;
1410
- let item_type = item_type ( & item) ;
1405
+ let item_type = item. type_ ( ) ;
1411
1406
let file_name = & item_path ( item_type, name) ;
1412
1407
let joint_dst = self . dst . join ( file_name) ;
1413
1408
try_err ! ( fs:: create_dir_all( & self . dst) , & self . dst) ;
@@ -1444,7 +1439,7 @@ impl Context {
1444
1439
for item in & m. items {
1445
1440
if maybe_ignore_item ( item) { continue }
1446
1441
1447
- let short = item_type ( item) . css_class ( ) ;
1442
+ let short = item. type_ ( ) . css_class ( ) ;
1448
1443
let myname = match item. name {
1449
1444
None => continue ,
1450
1445
Some ( ref s) => s. to_string ( ) ,
@@ -1541,7 +1536,7 @@ impl<'a> Item<'a> {
1541
1536
}
1542
1537
Some ( format ! ( "{path}{file}?gotosrc={goto}" ,
1543
1538
path = path,
1544
- file = item_path( item_type ( self . item) , external_path. last( ) . unwrap( ) ) ,
1539
+ file = item_path( self . item. type_ ( ) , external_path. last( ) . unwrap( ) ) ,
1545
1540
goto = self . item. def_id. index. as_usize( ) ) )
1546
1541
}
1547
1542
}
@@ -1586,7 +1581,7 @@ impl<'a> fmt::Display for Item<'a> {
1586
1581
}
1587
1582
}
1588
1583
write ! ( fmt, "<a class='{}' href=''>{}</a>" ,
1589
- item_type ( self . item) , self . item. name. as_ref( ) . unwrap( ) ) ?;
1584
+ self . item. type_ ( ) , self . item. name. as_ref( ) . unwrap( ) ) ?;
1590
1585
1591
1586
write ! ( fmt, "</span>" ) ?; // in-band
1592
1587
write ! ( fmt, "<span class='out-of-band'>" ) ?;
@@ -1739,8 +1734,8 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
1739
1734
}
1740
1735
1741
1736
fn cmp ( i1 : & clean:: Item , i2 : & clean:: Item , idx1 : usize , idx2 : usize ) -> Ordering {
1742
- let ty1 = item_type ( i1 ) ;
1743
- let ty2 = item_type ( i2 ) ;
1737
+ let ty1 = i1 . type_ ( ) ;
1738
+ let ty2 = i2 . type_ ( ) ;
1744
1739
if ty1 != ty2 {
1745
1740
return ( reorder ( ty1) , idx1) . cmp ( & ( reorder ( ty2) , idx2) )
1746
1741
}
@@ -1764,7 +1759,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
1764
1759
continue ;
1765
1760
}
1766
1761
1767
- let myty = Some ( item_type ( myitem) ) ;
1762
+ let myty = Some ( myitem. type_ ( ) ) ;
1768
1763
if curty == Some ( ItemType :: ExternCrate ) && myty == Some ( ItemType :: Import ) {
1769
1764
// Put `extern crate` and `use` re-exports in the same section.
1770
1765
curty = myty;
@@ -1851,9 +1846,9 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
1851
1846
name = * myitem. name. as_ref( ) . unwrap( ) ,
1852
1847
stab_docs = stab_docs,
1853
1848
docs = shorter( Some ( & Markdown ( doc_value) . to_string( ) ) ) ,
1854
- class = item_type ( myitem) ,
1849
+ class = myitem. type_ ( ) ,
1855
1850
stab = myitem. stability_class( ) ,
1856
- href = item_path( item_type ( myitem) , myitem. name. as_ref( ) . unwrap( ) ) ,
1851
+ href = item_path( myitem. type_ ( ) , myitem. name. as_ref( ) . unwrap( ) ) ,
1857
1852
title = full_path( cx, myitem) ) ?;
1858
1853
}
1859
1854
}
@@ -2059,7 +2054,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2059
2054
fn trait_item ( w : & mut fmt:: Formatter , cx : & Context , m : & clean:: Item , t : & clean:: Item )
2060
2055
-> fmt:: Result {
2061
2056
let name = m. name . as_ref ( ) . unwrap ( ) ;
2062
- let item_type = item_type ( m ) ;
2057
+ let item_type = m . type_ ( ) ;
2063
2058
let id = derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
2064
2059
let ns_id = derive_id ( format ! ( "{}.{}" , name, item_type. name_space( ) ) ) ;
2065
2060
write ! ( w, "<h3 id='{id}' class='method stab {stab}'>\
@@ -2145,7 +2140,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2145
2140
let ( ref path, _) = cache. external_paths[ & it. def_id] ;
2146
2141
path[ ..path. len( ) - 1 ] . join( "/" )
2147
2142
} ,
2148
- ty = item_type ( it ) . css_class( ) ,
2143
+ ty = it . type_ ( ) . css_class( ) ,
2149
2144
name = * it. name. as_ref( ) . unwrap( ) ) ?;
2150
2145
Ok ( ( ) )
2151
2146
}
@@ -2154,7 +2149,7 @@ fn naive_assoc_href(it: &clean::Item, link: AssocItemLink) -> String {
2154
2149
use html:: item_type:: ItemType :: * ;
2155
2150
2156
2151
let name = it. name . as_ref ( ) . unwrap ( ) ;
2157
- let ty = match item_type ( it ) {
2152
+ let ty = match it . type_ ( ) {
2158
2153
Typedef | AssociatedType => AssociatedType ,
2159
2154
s@_ => s,
2160
2155
} ;
@@ -2232,7 +2227,7 @@ fn render_assoc_item(w: &mut fmt::Formatter,
2232
2227
link : AssocItemLink )
2233
2228
-> fmt:: Result {
2234
2229
let name = meth. name . as_ref ( ) . unwrap ( ) ;
2235
- let anchor = format ! ( "#{}.{}" , item_type ( meth) , name) ;
2230
+ let anchor = format ! ( "#{}.{}" , meth. type_ ( ) , name) ;
2236
2231
let href = match link {
2237
2232
AssocItemLink :: Anchor ( Some ( ref id) ) => format ! ( "#{}" , id) ,
2238
2233
AssocItemLink :: Anchor ( None ) => anchor,
@@ -2740,7 +2735,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
2740
2735
link : AssocItemLink , render_mode : RenderMode ,
2741
2736
is_default_item : bool , outer_version : Option < & str > ,
2742
2737
trait_ : Option < & clean:: Trait > ) -> fmt:: Result {
2743
- let item_type = item_type ( item) ;
2738
+ let item_type = item. type_ ( ) ;
2744
2739
let name = item. name . as_ref ( ) . unwrap ( ) ;
2745
2740
2746
2741
let render_method_item: bool = match render_mode {
@@ -2932,7 +2927,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
2932
2927
relpath: '{path}'\
2933
2928
}};</script>",
2934
2929
name = it. name. as_ref( ) . map( |x| & x[ ..] ) . unwrap_or( "" ) ,
2935
- ty = item_type ( it ) . css_class( ) ,
2930
+ ty = it . type_ ( ) . css_class( ) ,
2936
2931
path = relpath) ?;
2937
2932
if parentlen == 0 {
2938
2933
// there is no sidebar-items.js beyond the crate root path
0 commit comments