@@ -231,21 +231,14 @@ impl Clean<Item> for doctree::Module<'_> {
231
231
let mut items: Vec < Item > = vec ! [ ] ;
232
232
items. extend ( self . extern_crates . iter ( ) . flat_map ( |x| x. clean ( cx) ) ) ;
233
233
items. extend ( self . imports . iter ( ) . flat_map ( |x| x. clean ( cx) ) ) ;
234
- items. extend ( self . structs . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
235
- items. extend ( self . unions . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
236
- items. extend ( self . enums . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
237
234
items. extend ( self . fns . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
238
235
items. extend ( self . foreigns . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
239
236
items. extend ( self . mods . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
240
- items. extend ( self . typedefs . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
241
- items. extend ( self . opaque_tys . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
242
- items. extend ( self . statics . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
243
- items. extend ( self . constants . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
237
+ items. extend ( self . items . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
244
238
items. extend ( self . traits . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
245
239
items. extend ( self . impls . iter ( ) . flat_map ( |x| x. clean ( cx) ) ) ;
246
240
items. extend ( self . macros . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
247
241
items. extend ( self . proc_macros . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
248
- items. extend ( self . trait_aliases . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
249
242
250
243
// determine if we should display the inner contents or
251
244
// the outer `mod` item for the source code.
@@ -1020,20 +1013,6 @@ impl Clean<Item> for doctree::Trait<'_> {
1020
1013
}
1021
1014
}
1022
1015
1023
- impl Clean < Item > for doctree:: TraitAlias < ' _ > {
1024
- fn clean ( & self , cx : & DocContext < ' _ > ) -> Item {
1025
- Item :: from_hir_id_and_parts (
1026
- self . id ,
1027
- Some ( self . name ) ,
1028
- TraitAliasItem ( TraitAlias {
1029
- generics : self . generics . clean ( cx) ,
1030
- bounds : self . bounds . clean ( cx) ,
1031
- } ) ,
1032
- cx,
1033
- )
1034
- }
1035
- }
1036
-
1037
1016
impl Clean < bool > for hir:: IsAuto {
1038
1017
fn clean ( & self , _: & DocContext < ' _ > ) -> bool {
1039
1018
match * self {
@@ -1777,38 +1756,6 @@ impl Clean<Visibility> for ty::Visibility {
1777
1756
}
1778
1757
}
1779
1758
1780
- impl Clean < Item > for doctree:: Struct < ' _ > {
1781
- fn clean ( & self , cx : & DocContext < ' _ > ) -> Item {
1782
- Item :: from_hir_id_and_parts (
1783
- self . id ,
1784
- Some ( self . name ) ,
1785
- StructItem ( Struct {
1786
- struct_type : self . struct_type ,
1787
- generics : self . generics . clean ( cx) ,
1788
- fields : self . fields . clean ( cx) ,
1789
- fields_stripped : false ,
1790
- } ) ,
1791
- cx,
1792
- )
1793
- }
1794
- }
1795
-
1796
- impl Clean < Item > for doctree:: Union < ' _ > {
1797
- fn clean ( & self , cx : & DocContext < ' _ > ) -> Item {
1798
- Item :: from_hir_id_and_parts (
1799
- self . id ,
1800
- Some ( self . name ) ,
1801
- UnionItem ( Union {
1802
- struct_type : self . struct_type ,
1803
- generics : self . generics . clean ( cx) ,
1804
- fields : self . fields . clean ( cx) ,
1805
- fields_stripped : false ,
1806
- } ) ,
1807
- cx,
1808
- )
1809
- }
1810
- }
1811
-
1812
1759
impl Clean < VariantStruct > for rustc_hir:: VariantData < ' _ > {
1813
1760
fn clean ( & self , cx : & DocContext < ' _ > ) -> VariantStruct {
1814
1761
VariantStruct {
@@ -1819,21 +1766,6 @@ impl Clean<VariantStruct> for rustc_hir::VariantData<'_> {
1819
1766
}
1820
1767
}
1821
1768
1822
- impl Clean < Item > for doctree:: Enum < ' _ > {
1823
- fn clean ( & self , cx : & DocContext < ' _ > ) -> Item {
1824
- Item :: from_hir_id_and_parts (
1825
- self . id ,
1826
- Some ( self . name ) ,
1827
- EnumItem ( Enum {
1828
- variants : self . variants . iter ( ) . map ( |v| v. clean ( cx) ) . collect ( ) ,
1829
- generics : self . generics . clean ( cx) ,
1830
- variants_stripped : false ,
1831
- } ) ,
1832
- cx,
1833
- )
1834
- }
1835
- }
1836
-
1837
1769
impl Clean < Item > for doctree:: Variant < ' _ > {
1838
1770
fn clean ( & self , cx : & DocContext < ' _ > ) -> Item {
1839
1771
let what_rustc_thinks = Item :: from_hir_id_and_parts (
@@ -1981,33 +1913,6 @@ impl Clean<String> for Symbol {
1981
1913
}
1982
1914
}
1983
1915
1984
- impl Clean < Item > for doctree:: Typedef < ' _ > {
1985
- fn clean ( & self , cx : & DocContext < ' _ > ) -> Item {
1986
- let type_ = self . ty . clean ( cx) ;
1987
- let item_type = type_. def_id ( ) . and_then ( |did| inline:: build_ty ( cx, did) ) ;
1988
- Item :: from_hir_id_and_parts (
1989
- self . id ,
1990
- Some ( self . name ) ,
1991
- TypedefItem ( Typedef { type_, generics : self . gen . clean ( cx) , item_type } , false ) ,
1992
- cx,
1993
- )
1994
- }
1995
- }
1996
-
1997
- impl Clean < Item > for doctree:: OpaqueTy < ' _ > {
1998
- fn clean ( & self , cx : & DocContext < ' _ > ) -> Item {
1999
- Item :: from_hir_id_and_parts (
2000
- self . id ,
2001
- Some ( self . name ) ,
2002
- OpaqueTyItem ( OpaqueTy {
2003
- bounds : self . opaque_ty . bounds . clean ( cx) ,
2004
- generics : self . opaque_ty . generics . clean ( cx) ,
2005
- } ) ,
2006
- cx,
2007
- )
2008
- }
2009
- }
2010
-
2011
1916
impl Clean < BareFunctionDecl > for hir:: BareFnTy < ' _ > {
2012
1917
fn clean ( & self , cx : & DocContext < ' _ > ) -> BareFunctionDecl {
2013
1918
let ( generic_params, decl) = enter_impl_trait ( cx, || {
@@ -2017,37 +1922,75 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
2017
1922
}
2018
1923
}
2019
1924
2020
- impl Clean < Item > for doctree :: Static < ' _ > {
1925
+ impl Clean < Item > for ( & hir :: Item < ' _ > , Option < Ident > ) {
2021
1926
fn clean ( & self , cx : & DocContext < ' _ > ) -> Item {
2022
- debug ! ( "cleaning static {}: {:?}" , self . name. clean( cx) , self ) ;
2023
- Item :: from_hir_id_and_parts (
2024
- self . id ,
2025
- Some ( self . name ) ,
2026
- StaticItem ( Static {
2027
- type_ : self . type_ . clean ( cx) ,
2028
- mutability : self . mutability ,
2029
- expr : print_const_expr ( cx, self . expr ) ,
1927
+ use hir:: ItemKind ;
1928
+
1929
+ let ( item, renamed) = self ;
1930
+ let def_id = cx. tcx . hir ( ) . local_def_id ( item. hir_id ) . to_def_id ( ) ;
1931
+ let name = match renamed {
1932
+ Some ( ident) => ident. name ,
1933
+ None => cx. tcx . hir ( ) . name ( item. hir_id ) ,
1934
+ } ;
1935
+ let kind = match item. kind {
1936
+ ItemKind :: Static ( ty, mutability, body_id) => StaticItem ( Static {
1937
+ type_ : ty. clean ( cx) ,
1938
+ mutability,
1939
+ expr : print_const_expr ( cx, body_id) ,
2030
1940
} ) ,
2031
- cx,
2032
- )
1941
+ ItemKind :: Const ( ty, body_id) => ConstantItem ( Constant {
1942
+ type_ : ty. clean ( cx) ,
1943
+ expr : print_const_expr ( cx, body_id) ,
1944
+ value : print_evaluated_const ( cx, def_id) ,
1945
+ is_literal : is_literal_expr ( cx, body_id. hir_id ) ,
1946
+ } ) ,
1947
+ ItemKind :: OpaqueTy ( ref ty) => OpaqueTyItem ( OpaqueTy {
1948
+ bounds : ty. bounds . clean ( cx) ,
1949
+ generics : ty. generics . clean ( cx) ,
1950
+ } ) ,
1951
+ ItemKind :: TyAlias ( ty, ref generics) => {
1952
+ let rustdoc_ty = ty. clean ( cx) ;
1953
+ let item_type = rustdoc_ty. def_id ( ) . and_then ( |did| inline:: build_ty ( cx, did) ) ;
1954
+ TypedefItem (
1955
+ Typedef { type_ : rustdoc_ty, generics : generics. clean ( cx) , item_type } ,
1956
+ false ,
1957
+ )
1958
+ }
1959
+ ItemKind :: Enum ( ref def, ref generics) => EnumItem ( Enum {
1960
+ variants : def. variants . iter ( ) . map ( |v| v. clean ( cx) ) . collect ( ) ,
1961
+ generics : generics. clean ( cx) ,
1962
+ variants_stripped : false ,
1963
+ } ) ,
1964
+ ItemKind :: TraitAlias ( ref generics, bounds) => TraitAliasItem ( TraitAlias {
1965
+ generics : generics. clean ( cx) ,
1966
+ bounds : bounds. clean ( cx) ,
1967
+ } ) ,
1968
+ ItemKind :: Union ( ref variant_data, ref generics) => UnionItem ( Union {
1969
+ struct_type : doctree:: struct_type_from_def ( & variant_data) ,
1970
+ generics : generics. clean ( cx) ,
1971
+ fields : variant_data. fields ( ) . clean ( cx) ,
1972
+ fields_stripped : false ,
1973
+ } ) ,
1974
+ ItemKind :: Struct ( ref variant_data, ref generics) => StructItem ( Struct {
1975
+ struct_type : doctree:: struct_type_from_def ( & variant_data) ,
1976
+ generics : generics. clean ( cx) ,
1977
+ fields : variant_data. fields ( ) . clean ( cx) ,
1978
+ fields_stripped : false ,
1979
+ } ) ,
1980
+ _ => unreachable ! ( "not yet converted" ) ,
1981
+ } ;
1982
+
1983
+ Item :: from_def_id_and_parts ( def_id, Some ( name) , kind, cx)
2033
1984
}
2034
1985
}
2035
1986
2036
- impl Clean < Item > for doctree :: Constant < ' _ > {
1987
+ impl Clean < Item > for hir :: Variant < ' _ > {
2037
1988
fn clean ( & self , cx : & DocContext < ' _ > ) -> Item {
2038
- let def_id = cx. tcx . hir ( ) . local_def_id ( self . id ) . to_def_id ( ) ;
2039
-
2040
- Item :: from_def_id_and_parts (
2041
- def_id,
2042
- Some ( self . name ) ,
2043
- ConstantItem ( Constant {
2044
- type_ : self . type_ . clean ( cx) ,
2045
- expr : print_const_expr ( cx, self . expr ) ,
2046
- value : print_evaluated_const ( cx, def_id) ,
2047
- is_literal : is_literal_expr ( cx, self . expr . hir_id ) ,
2048
- } ) ,
2049
- cx,
2050
- )
1989
+ let kind = VariantItem ( Variant { kind : self . data . clean ( cx) } ) ;
1990
+ let what_rustc_thinks =
1991
+ Item :: from_hir_id_and_parts ( self . id , Some ( self . ident . name ) , kind, cx) ;
1992
+ // don't show `pub` for variants, which are always public
1993
+ Item { visibility : Inherited , ..what_rustc_thinks }
2051
1994
}
2052
1995
}
2053
1996
0 commit comments