@@ -1402,6 +1402,9 @@ pub struct MissingDoc {
14021402 /// Stack of IDs of struct definitions.
14031403 struct_def_stack : Vec < ast:: NodeId > ,
14041404
1405+ /// True if inside variant definition
1406+ in_variant : bool ,
1407+
14051408 /// Stack of whether #[doc(hidden)] is set
14061409 /// at each level which has lint attributes.
14071410 doc_hidden_stack : Vec < bool > ,
@@ -1411,6 +1414,7 @@ impl MissingDoc {
14111414 pub fn new ( ) -> MissingDoc {
14121415 MissingDoc {
14131416 struct_def_stack : vec ! ( ) ,
1417+ in_variant : false ,
14141418 doc_hidden_stack : vec ! ( false ) ,
14151419 }
14161420 }
@@ -1525,7 +1529,7 @@ impl LintPass for MissingDoc {
15251529
15261530 fn check_struct_field ( & mut self , cx : & Context , sf : & ast:: StructField ) {
15271531 match sf. node . kind {
1528- ast:: NamedField ( _, vis) if vis == ast:: Public => {
1532+ ast:: NamedField ( _, vis) if vis == ast:: Public || self . in_variant => {
15291533 let cur_struct_def = * self . struct_def_stack . last ( )
15301534 . expect ( "empty struct_def_stack" ) ;
15311535 self . check_missing_docs_attrs ( cx, Some ( cur_struct_def) ,
@@ -1539,6 +1543,13 @@ impl LintPass for MissingDoc {
15391543 fn check_variant ( & mut self , cx : & Context , v : & ast:: Variant , _: & ast:: Generics ) {
15401544 self . check_missing_docs_attrs ( cx, Some ( v. node . id ) , v. node . attrs . as_slice ( ) ,
15411545 v. span , "a variant" ) ;
1546+ assert ! ( !self . in_variant) ;
1547+ self . in_variant = true ;
1548+ }
1549+
1550+ fn check_variant_post ( & mut self , _: & Context , _: & ast:: Variant , _: & ast:: Generics ) {
1551+ assert ! ( self . in_variant) ;
1552+ self . in_variant = false ;
15421553 }
15431554}
15441555
0 commit comments