diff --git a/clippy_lints/src/derivable_impls.rs b/clippy_lints/src/derivable_impls.rs index 9a85cc4ce..d2bfc4f8e 100644 --- a/clippy_lints/src/derivable_impls.rs +++ b/clippy_lints/src/derivable_impls.rs @@ -217,8 +217,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls { if let &Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind(); if let attrs = cx.tcx.hir().attrs(item.hir_id()); if !attrs.iter().any(|attr| attr.doc_str().is_some()); - if let child_attrs = cx.tcx.hir().attrs(impl_item_hir); - if !child_attrs.iter().any(|attr| attr.doc_str().is_some()); + if cx.tcx.hir().attrs(impl_item_hir).is_empty(); then { if adt_def.is_struct() { diff --git a/tests/ui/derivable_impls.fixed b/tests/ui/derivable_impls.fixed index 6cc202414..68c5a5c5c 100644 --- a/tests/ui/derivable_impls.fixed +++ b/tests/ui/derivable_impls.fixed @@ -287,4 +287,17 @@ mod issue10158 { } } +mod issue11368 { + pub struct A { + a: u32, + } + + impl Default for A { + #[track_caller] + fn default() -> Self { + Self { a: 0 } + } + } +} + fn main() {} diff --git a/tests/ui/derivable_impls.rs b/tests/ui/derivable_impls.rs index 0aa9acd75..21d73ba8b 100644 --- a/tests/ui/derivable_impls.rs +++ b/tests/ui/derivable_impls.rs @@ -323,4 +323,17 @@ mod issue10158 { } } +mod issue11368 { + pub struct A { + a: u32, + } + + impl Default for A { + #[track_caller] + fn default() -> Self { + Self { a: 0 } + } + } +} + fn main() {}