mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-16 05:58:41 +00:00
Auto merge of #7849 - ThibsG:SafetyDoc, r=llogiq
FIx FP in `missing_safety_doc` lint Fix FP where lint souldn't fire if any parent has `#[doc(hidden)]` attribute fixes: #7347 changelog: [`missing_safety_doc`] Fix FP if any parent has `#[doc(hidden)]` attribute
This commit is contained in:
commit
f11905af15
2 changed files with 22 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
use clippy_utils::attrs::is_doc_hidden;
|
||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_note};
|
||||
use clippy_utils::source::first_line_of_span;
|
||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||
|
@ -297,6 +298,17 @@ fn lint_for_missing_headers<'tcx>(
|
|||
if !cx.access_levels.is_exported(def_id) {
|
||||
return; // Private functions do not require doc comments
|
||||
}
|
||||
|
||||
// do not lint if any parent has `#[doc(hidden)]` attribute (#7347)
|
||||
if cx
|
||||
.tcx
|
||||
.hir()
|
||||
.parent_iter(cx.tcx.hir().local_def_id_to_hir_id(def_id))
|
||||
.any(|(id, _node)| is_doc_hidden(cx.tcx.hir().attrs(id)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if !headers.safety && sig.header.unsafety == hir::Unsafety::Unsafe {
|
||||
span_lint(
|
||||
cx,
|
||||
|
|
|
@ -115,3 +115,13 @@ fn main() {
|
|||
drive();
|
||||
}
|
||||
}
|
||||
|
||||
// do not lint if any parent has `#[doc(hidden)]` attribute
|
||||
// see #7347
|
||||
#[doc(hidden)]
|
||||
pub mod __macro {
|
||||
pub struct T;
|
||||
impl T {
|
||||
pub unsafe fn f() {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue