mirror of
https://github.com/rust-lang/rust
synced 2024-10-16 21:43:43 +00:00
Rollup merge of #89987 - pierwill:fix-85526-docs-hidden-assoc, r=GuillaumeGomez
Check implementing type for `#[doc(hidden)]` Closes #85526.
This commit is contained in:
commit
cd72393566
|
@ -657,6 +657,24 @@ fn check_impl_item(&mut self, cx: &LateContext<'_>, impl_item: &hir::ImplItem<'_
|
||||||
return;
|
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,
|
||||||
|
};
|
||||||
|
if is_hidden {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
|
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);
|
self.check_missing_docs_attrs(cx, impl_item.def_id, impl_item.span, article, desc);
|
||||||
}
|
}
|
||||||
|
|
15
src/test/ui/hidden-doc-associated-item.rs
Normal file
15
src/test/ui/hidden-doc-associated-item.rs
Normal file
|
@ -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() {}
|
Loading…
Reference in a new issue