1
Fork 0

Rollup merge of #111150 - mj10021:issue-111025-fix, r=petrochenkov

added TraitAlias to check_item() for missing_docs

As in issue #111025 the `missing_docs` was not being triggered for trait aliases.  I added `TraitAlias` to the pattern match for check_item(), and the lint seems to be behaving appropriately
This commit is contained in:
Yuki Okushi 2023-05-07 14:12:15 +09:00 committed by GitHub
commit 61115cd753
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 49 deletions

View file

@ -547,32 +547,13 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
}
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
match it.kind {
hir::ItemKind::Trait(..) => {
// Issue #11592: traits are always considered exported, even when private.
if cx.tcx.visibility(it.owner_id)
== ty::Visibility::Restricted(
cx.tcx.parent_module_from_def_id(it.owner_id.def_id).to_def_id(),
)
{
return;
}
}
hir::ItemKind::TyAlias(..)
| hir::ItemKind::Fn(..)
| hir::ItemKind::Macro(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::Enum(..)
| hir::ItemKind::Struct(..)
| hir::ItemKind::Union(..)
| hir::ItemKind::Const(..)
| hir::ItemKind::Static(..) => {}
_ => return,
};
// Previously the Impl and Use types have been excluded from missing docs,
// so we will continue to exclude them for compatibility
if let hir::ItemKind::Impl(..) | hir::ItemKind::Use(..) = it.kind {
return;
}
let (article, desc) = cx.tcx.article_and_description(it.owner_id.to_def_id());
self.check_missing_docs_attrs(cx, it.owner_id.def_id, article, desc);
}