Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {}