@@ -349,7 +349,8 @@ impl MissingDoc {
349
349
id : Option < hir:: HirId > ,
350
350
attrs : & [ ast:: Attribute ] ,
351
351
sp : Span ,
352
- desc : & str ,
352
+ article : & ' static str ,
353
+ desc : & ' static str ,
353
354
) {
354
355
// If we're building a test harness, then warning about
355
356
// documentation is probably not really relevant right now.
@@ -374,7 +375,7 @@ impl MissingDoc {
374
375
let has_doc = attrs. iter ( ) . any ( |a| has_doc ( a) ) ;
375
376
if !has_doc {
376
377
cx. struct_span_lint ( MISSING_DOCS , cx. tcx . sess . source_map ( ) . def_span ( sp) , |lint| {
377
- lint. build ( & format ! ( "missing documentation for {}" , desc) ) . emit ( )
378
+ lint. build ( & format ! ( "missing documentation for {} {}" , article , desc) ) . emit ( )
378
379
} ) ;
379
380
}
380
381
}
@@ -398,7 +399,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
398
399
}
399
400
400
401
fn check_crate ( & mut self , cx : & LateContext < ' _ , ' _ > , krate : & hir:: Crate < ' _ > ) {
401
- self . check_missing_docs_attrs ( cx, None , & krate. item . attrs , krate. item . span , "crate" ) ;
402
+ self . check_missing_docs_attrs ( cx, None , & krate. item . attrs , krate. item . span , "a" , " crate") ;
402
403
403
404
for macro_def in krate. exported_macros {
404
405
let has_doc = macro_def. attrs . iter ( ) . any ( |a| has_doc ( a) ) ;
@@ -455,13 +456,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
455
456
let def_id = cx. tcx . hir ( ) . local_def_id ( it. hir_id ) ;
456
457
let ( article, desc) = cx. tcx . article_and_description ( def_id) ;
457
458
458
- self . check_missing_docs_attrs (
459
- cx,
460
- Some ( it. hir_id ) ,
461
- & it. attrs ,
462
- it. span ,
463
- & format ! ( "{} {}" , article, desc) ,
464
- ) ;
459
+ self . check_missing_docs_attrs ( cx, Some ( it. hir_id ) , & it. attrs , it. span , article, desc) ;
465
460
}
466
461
467
462
fn check_trait_item ( & mut self , cx : & LateContext < ' _ , ' _ > , trait_item : & hir:: TraitItem < ' _ > ) {
@@ -477,7 +472,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
477
472
Some ( trait_item. hir_id ) ,
478
473
& trait_item. attrs ,
479
474
trait_item. span ,
480
- & format ! ( "{} {}" , article, desc) ,
475
+ article,
476
+ desc,
481
477
) ;
482
478
}
483
479
@@ -494,18 +490,26 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
494
490
Some ( impl_item. hir_id ) ,
495
491
& impl_item. attrs ,
496
492
impl_item. span ,
497
- & format ! ( "{} {}" , article, desc) ,
493
+ article,
494
+ desc,
498
495
) ;
499
496
}
500
497
501
498
fn check_struct_field ( & mut self , cx : & LateContext < ' _ , ' _ > , sf : & hir:: StructField < ' _ > ) {
502
499
if !sf. is_positional ( ) {
503
- self . check_missing_docs_attrs ( cx, Some ( sf. hir_id ) , & sf. attrs , sf. span , "a struct field" )
500
+ self . check_missing_docs_attrs (
501
+ cx,
502
+ Some ( sf. hir_id ) ,
503
+ & sf. attrs ,
504
+ sf. span ,
505
+ "a" ,
506
+ "struct field" ,
507
+ )
504
508
}
505
509
}
506
510
507
511
fn check_variant ( & mut self , cx : & LateContext < ' _ , ' _ > , v : & hir:: Variant < ' _ > ) {
508
- self . check_missing_docs_attrs ( cx, Some ( v. id ) , & v. attrs , v. span , "a variant" ) ;
512
+ self . check_missing_docs_attrs ( cx, Some ( v. id ) , & v. attrs , v. span , "a" , " variant") ;
509
513
}
510
514
}
511
515
0 commit comments