@@ -297,6 +297,26 @@ pub struct MissingDoc {
297297 private_traits : FxHashSet < ast:: NodeId > ,
298298}
299299
300+ fn has_doc ( attr : & ast:: Attribute ) -> bool {
301+ if !attr. check_name ( "doc" ) {
302+ return false ;
303+ }
304+
305+ if attr. is_value_str ( ) {
306+ return true ;
307+ }
308+
309+ if let Some ( list) = attr. meta_item_list ( ) {
310+ for meta in list {
311+ if meta. check_name ( "include" ) || meta. check_name ( "hidden" ) {
312+ return true ;
313+ }
314+ }
315+ }
316+
317+ false
318+ }
319+
300320impl MissingDoc {
301321 pub fn new ( ) -> MissingDoc {
302322 MissingDoc {
@@ -335,26 +355,6 @@ impl MissingDoc {
335355 }
336356 }
337357
338- fn has_doc ( attr : & ast:: Attribute ) -> bool {
339- if !attr. check_name ( "doc" ) {
340- return false ;
341- }
342-
343- if attr. is_value_str ( ) {
344- return true ;
345- }
346-
347- if let Some ( list) = attr. meta_item_list ( ) {
348- for meta in list {
349- if meta. check_name ( "include" ) {
350- return true ;
351- }
352- }
353- }
354-
355- false
356- }
357-
358358 let has_doc = attrs. iter ( ) . any ( |a| has_doc ( a) ) ;
359359 if !has_doc {
360360 cx. span_lint ( MISSING_DOCS ,
@@ -389,6 +389,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
389389
390390 fn check_crate ( & mut self , cx : & LateContext , krate : & hir:: Crate ) {
391391 self . check_missing_docs_attrs ( cx, None , & krate. attrs , krate. span , "crate" ) ;
392+
393+ for macro_def in & krate. exported_macros {
394+ let has_doc = macro_def. attrs . iter ( ) . any ( |a| has_doc ( a) ) ;
395+ if !has_doc {
396+ cx. span_lint ( MISSING_DOCS ,
397+ cx. tcx . sess . source_map ( ) . def_span ( macro_def. span ) ,
398+ "missing documentation for macro" ) ;
399+ }
400+ }
392401 }
393402
394403 fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
0 commit comments