@@ -349,7 +349,7 @@ impl MissingDoc {
349349 id : Option < hir:: HirId > ,
350350 attrs : & [ ast:: Attribute ] ,
351351 sp : Span ,
352- desc : & ' static str ,
352+ desc : & str ,
353353 ) {
354354 // If we're building a test harness, then warning about
355355 // documentation is probably not really relevant right now.
@@ -413,12 +413,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
413413 }
414414
415415 fn check_item ( & mut self , cx : & LateContext < ' _ , ' _ > , it : & hir:: Item < ' _ > ) {
416- let desc = match it. kind {
417- hir:: ItemKind :: Fn ( ..) => "a function" ,
418- hir:: ItemKind :: Mod ( ..) => "a module" ,
419- hir:: ItemKind :: Enum ( ..) => "an enum" ,
420- hir:: ItemKind :: Struct ( ..) => "a struct" ,
421- hir:: ItemKind :: Union ( ..) => "a union" ,
416+ match it. kind {
422417 hir:: ItemKind :: Trait ( .., trait_item_refs) => {
423418 // Issue #11592: traits are always considered exported, even when private.
424419 if let hir:: VisibilityKind :: Inherited = it. vis . node {
@@ -428,33 +423,45 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
428423 }
429424 return ;
430425 }
431- "a trait"
432426 }
433- hir:: ItemKind :: TyAlias ( ..) => "a type alias" ,
434427 hir:: ItemKind :: Impl { of_trait : Some ( ref trait_ref) , items, .. } => {
435428 // If the trait is private, add the impl items to `private_traits` so they don't get
436429 // reported for missing docs.
437430 let real_trait = trait_ref. path . res . def_id ( ) ;
438431 if let Some ( hir_id) = cx. tcx . hir ( ) . as_local_hir_id ( real_trait) {
439- match cx. tcx . hir ( ) . find ( hir_id) {
440- Some ( Node :: Item ( item) ) => {
441- if let hir:: VisibilityKind :: Inherited = item. vis . node {
442- for impl_item_ref in items {
443- self . private_traits . insert ( impl_item_ref. id . hir_id ) ;
444- }
432+ if let Some ( Node :: Item ( item) ) = cx. tcx . hir ( ) . find ( hir_id) {
433+ if let hir:: VisibilityKind :: Inherited = item. vis . node {
434+ for impl_item_ref in items {
435+ self . private_traits . insert ( impl_item_ref. id . hir_id ) ;
445436 }
446437 }
447- _ => { }
448438 }
449439 }
450440 return ;
451441 }
452- hir:: ItemKind :: Const ( ..) => "a constant" ,
453- hir:: ItemKind :: Static ( ..) => "a static" ,
442+
443+ hir:: ItemKind :: TyAlias ( ..)
444+ | hir:: ItemKind :: Fn ( ..)
445+ | hir:: ItemKind :: Mod ( ..)
446+ | hir:: ItemKind :: Enum ( ..)
447+ | hir:: ItemKind :: Struct ( ..)
448+ | hir:: ItemKind :: Union ( ..)
449+ | hir:: ItemKind :: Const ( ..)
450+ | hir:: ItemKind :: Static ( ..) => { }
451+
454452 _ => return ,
455453 } ;
456454
457- self . check_missing_docs_attrs ( cx, Some ( it. hir_id ) , & it. attrs , it. span , desc) ;
455+ let def_id = cx. tcx . hir ( ) . local_def_id ( it. hir_id ) ;
456+ let ( article, desc) = cx. tcx . article_and_description ( def_id) ;
457+
458+ self . check_missing_docs_attrs (
459+ cx,
460+ Some ( it. hir_id ) ,
461+ & it. attrs ,
462+ it. span ,
463+ & format ! ( "{} {}" , article, desc) ,
464+ ) ;
458465 }
459466
460467 fn check_trait_item ( & mut self , cx : & LateContext < ' _ , ' _ > , trait_item : & hir:: TraitItem < ' _ > ) {
0 commit comments