Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check implementing type for #[doc(hidden)] #89987

Merged
merged 1 commit into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,24 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
return;
}

// If the method is an impl for an item with docs_hidden, don't doc.
if method_context(cx, impl_item.hir_id()) == MethodLateContext::PlainImpl {
let parent = cx.tcx.hir().get_parent_did(impl_item.hir_id());
let impl_ty = cx.tcx.type_of(parent);
let outerdef = match impl_ty.kind() {
ty::Adt(def, _) => Some(def.did),
ty::Foreign(def_id) => Some(*def_id),
_ => None,
};
let is_hidden = match outerdef {
Some(id) => cx.tcx.is_doc_hidden(id),
None => false,
};
pierwill marked this conversation as resolved.
Show resolved Hide resolved
if is_hidden {
return;
}
}

let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
self.check_missing_docs_attrs(cx, impl_item.def_id, impl_item.span, article, desc);
}
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/hidden-doc-associated-item.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// check-pass
// See issue #85526.
// This test should produce no warnings.

#![deny(missing_docs)]
//! Crate docs

#[doc(hidden)]
pub struct Foo;

impl Foo {
pub fn bar() {}
}

fn main() {}