diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 47121ad84..b40425bb6 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -85,6 +85,10 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault { // can't be implemented for unsafe new return; } + if clippy_utils::is_doc_hidden(cx.tcx.hir().attrs(id)) { + // shouldn't be implemented when it is hidden in docs + return; + } if impl_item .generics .params diff --git a/tests/ui/new_without_default.rs b/tests/ui/new_without_default.rs index c76e3b424..e94f99c95 100644 --- a/tests/ui/new_without_default.rs +++ b/tests/ui/new_without_default.rs @@ -201,4 +201,14 @@ pub mod issue7220 { } } +// see issue #8152 +// This should not create any lints +pub struct DocHidden; +impl DocHidden { + #[doc(hidden)] + pub fn new() -> Self { + DocHidden + } +} + fn main() {}