Skip to content

Commit 4736908

Browse files
committed
Auto merge of #11404 - mojave2:issue-11368, r=matthiaskrgr
fix "derivable_impls: attributes are ignored" *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: [`derivable_impls`]: allow the lint when the trait-impl methods has any attribute.
2 parents 706c48b + 90fcc67 commit 4736908

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

clippy_lints/src/derivable_impls.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
217217
if let &Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind();
218218
if let attrs = cx.tcx.hir().attrs(item.hir_id());
219219
if !attrs.iter().any(|attr| attr.doc_str().is_some());
220-
if let child_attrs = cx.tcx.hir().attrs(impl_item_hir);
221-
if !child_attrs.iter().any(|attr| attr.doc_str().is_some());
220+
if cx.tcx.hir().attrs(impl_item_hir).is_empty();
222221

223222
then {
224223
if adt_def.is_struct() {

tests/ui/derivable_impls.fixed

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,17 @@ mod issue10158 {
287287
}
288288
}
289289

290+
mod issue11368 {
291+
pub struct A {
292+
a: u32,
293+
}
294+
295+
impl Default for A {
296+
#[track_caller]
297+
fn default() -> Self {
298+
Self { a: 0 }
299+
}
300+
}
301+
}
302+
290303
fn main() {}

tests/ui/derivable_impls.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,17 @@ mod issue10158 {
323323
}
324324
}
325325

326+
mod issue11368 {
327+
pub struct A {
328+
a: u32,
329+
}
330+
331+
impl Default for A {
332+
#[track_caller]
333+
fn default() -> Self {
334+
Self { a: 0 }
335+
}
336+
}
337+
}
338+
326339
fn main() {}

0 commit comments

Comments
 (0)