impl_lint_pass!(NewWithoutDefault => [NEW_WITHOUT_DEFAULT]);
impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
- #[allow(clippy::too_many_lines)]
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
if let hir::ItemKind::Impl(hir::Impl {
of_trait: None,
// can't be implemented for unsafe new
return;
}
- if clippy_utils::is_doc_hidden(cx.tcx.hir().attrs(id)) {
+ if cx.tcx.is_doc_hidden(impl_item.def_id) {
// shouldn't be implemented when it is hidden in docs
return;
}
- if impl_item
- .generics
- .params
- .iter()
- .any(|gen| matches!(gen.kind, hir::GenericParamKind::Type { .. }))
- {
- // when the result of `new()` depends on a type parameter we should not require
- // an
- // impl of `Default`
+ if !impl_item.generics.params.is_empty() {
+ // when the result of `new()` depends on a parameter we should not require
+ // an impl of `Default`
return;
}
if_chain! {