@@ -1824,44 +1824,36 @@ pub(crate) fn clean_visibility(vis: ty::Visibility) -> Visibility {
1824
1824
}
1825
1825
}
1826
1826
1827
+ pub ( crate ) fn clean_variant_def < ' tcx > ( variant : & ty:: VariantDef , cx : & mut DocContext < ' tcx > ) -> Item {
1828
+ let kind = match variant. ctor_kind {
1829
+ CtorKind :: Const => Variant :: CLike ,
1830
+ CtorKind :: Fn => Variant :: Tuple (
1831
+ variant. fields . iter ( ) . map ( |field| clean_middle_field ( field, cx) ) . collect ( ) ,
1832
+ ) ,
1833
+ CtorKind :: Fictive => Variant :: Struct ( VariantStruct {
1834
+ struct_type : CtorKind :: Fictive ,
1835
+ fields : variant. fields . iter ( ) . map ( |field| clean_middle_field ( field, cx) ) . collect ( ) ,
1836
+ } ) ,
1837
+ } ;
1838
+ let what_rustc_thinks =
1839
+ Item :: from_def_id_and_parts ( variant. def_id , Some ( variant. name ) , VariantItem ( kind) , cx) ;
1840
+ // don't show `pub` for variants, which always inherit visibility
1841
+ Item { visibility : Inherited , ..what_rustc_thinks }
1842
+ }
1843
+
1827
1844
fn clean_variant_data < ' tcx > (
1828
1845
variant : & hir:: VariantData < ' tcx > ,
1829
1846
cx : & mut DocContext < ' tcx > ,
1830
- ) -> VariantStruct {
1831
- VariantStruct {
1832
- struct_type : CtorKind :: from_hir ( variant) ,
1833
- fields : variant. fields ( ) . iter ( ) . map ( |x| clean_field ( x, cx) ) . collect ( ) ,
1834
- }
1835
- }
1836
-
1837
- impl < ' tcx > Clean < ' tcx , Item > for ty:: VariantDef {
1838
- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Item {
1839
- let kind = match self . ctor_kind {
1840
- CtorKind :: Const => Variant :: CLike ,
1841
- CtorKind :: Fn => Variant :: Tuple (
1842
- self . fields . iter ( ) . map ( |field| clean_middle_field ( field, cx) ) . collect ( ) ,
1843
- ) ,
1844
- CtorKind :: Fictive => Variant :: Struct ( VariantStruct {
1845
- struct_type : CtorKind :: Fictive ,
1846
- fields : self . fields . iter ( ) . map ( |field| clean_middle_field ( field, cx) ) . collect ( ) ,
1847
- } ) ,
1848
- } ;
1849
- let what_rustc_thinks =
1850
- Item :: from_def_id_and_parts ( self . def_id , Some ( self . name ) , VariantItem ( kind) , cx) ;
1851
- // don't show `pub` for variants, which always inherit visibility
1852
- Item { visibility : Inherited , ..what_rustc_thinks }
1853
- }
1854
- }
1855
-
1856
- impl < ' tcx > Clean < ' tcx , Variant > for hir:: VariantData < ' tcx > {
1857
- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Variant {
1858
- match self {
1859
- hir:: VariantData :: Struct ( ..) => Variant :: Struct ( clean_variant_data ( self , cx) ) ,
1860
- hir:: VariantData :: Tuple ( ..) => {
1861
- Variant :: Tuple ( self . fields ( ) . iter ( ) . map ( |x| clean_field ( x, cx) ) . collect ( ) )
1862
- }
1863
- hir:: VariantData :: Unit ( ..) => Variant :: CLike ,
1847
+ ) -> Variant {
1848
+ match variant {
1849
+ hir:: VariantData :: Struct ( ..) => Variant :: Struct ( VariantStruct {
1850
+ struct_type : CtorKind :: from_hir ( variant) ,
1851
+ fields : variant. fields ( ) . iter ( ) . map ( |x| clean_field ( x, cx) ) . collect ( ) ,
1852
+ } ) ,
1853
+ hir:: VariantData :: Tuple ( ..) => {
1854
+ Variant :: Tuple ( variant. fields ( ) . iter ( ) . map ( |x| clean_field ( x, cx) ) . collect ( ) )
1864
1855
}
1856
+ hir:: VariantData :: Unit ( ..) => Variant :: CLike ,
1865
1857
}
1866
1858
}
1867
1859
@@ -2009,7 +2001,7 @@ fn clean_maybe_renamed_item<'tcx>(
2009
2001
2010
2002
impl < ' tcx > Clean < ' tcx , Item > for hir:: Variant < ' tcx > {
2011
2003
fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Item {
2012
- let kind = VariantItem ( self . data . clean ( cx) ) ;
2004
+ let kind = VariantItem ( clean_variant_data ( & self . data , cx) ) ;
2013
2005
let what_rustc_thinks =
2014
2006
Item :: from_hir_id_and_parts ( self . id , Some ( self . ident . name ) , kind, cx) ;
2015
2007
// don't show `pub` for variants, which are always public
0 commit comments