Skip to content

Commit 862211d

Browse files
committed
Disable `[new-without-default]` for new() methods that are marked with '#[doc(hidden)]'
Fixes issue rust-lang#8152
1 parent 7b2896a commit 862211d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

clippy_lints/src/new_without_default.rs

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
8585
// can't be implemented for unsafe new
8686
return;
8787
}
88+
if clippy_utils::is_doc_hidden(cx.tcx.hir().attrs(id)) {
89+
// shouldn't be implemented when it is hidden in docs
90+
return;
91+
}
8892
if impl_item
8993
.generics
9094
.params

tests/ui/new_without_default.rs

+10
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,14 @@ pub mod issue7220 {
201201
}
202202
}
203203

204+
// see issue #8152
205+
// This should not create any lints
206+
pub struct DocHidden;
207+
impl DocHidden {
208+
#[doc(hidden)]
209+
pub fn new() -> Self {
210+
DocHidden
211+
}
212+
}
213+
204214
fn main() {}

0 commit comments

Comments
 (0)