Skip to content

Commit

Permalink
Auto merge of #8472 - Mastermindaxe:#8152_new-without-default_should_…
Browse files Browse the repository at this point in the history
…not_trigger_on_doc_hidden_items, r=flip1995

Disable ``[`new-without-default`]`` for new() methods that are marked…

… with '#[doc(hidden)]'

Fixes #8152

changelog: Disable ``[`new-without-default`]`` for new() methods that are marked with `#[doc(hidden)]`
  • Loading branch information
bors committed Feb 25, 2022
2 parents 7b2896a + 862211d commit 95897bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clippy_lints/src/new_without_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/new_without_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit 95897bf

Please sign in to comment.