@@ -297,6 +297,26 @@ pub struct MissingDoc {
297
297
private_traits : FxHashSet < ast:: NodeId > ,
298
298
}
299
299
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
+
300
320
impl MissingDoc {
301
321
pub fn new ( ) -> MissingDoc {
302
322
MissingDoc {
@@ -335,26 +355,6 @@ impl MissingDoc {
335
355
}
336
356
}
337
357
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
-
358
358
let has_doc = attrs. iter ( ) . any ( |a| has_doc ( a) ) ;
359
359
if !has_doc {
360
360
cx. span_lint ( MISSING_DOCS ,
@@ -389,6 +389,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
389
389
390
390
fn check_crate ( & mut self , cx : & LateContext , krate : & hir:: Crate ) {
391
391
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
+ }
392
401
}
393
402
394
403
fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
0 commit comments