Skip to content

Commit

Permalink
Auto merge of #11404 - mojave2:issue-11368, r=matthiaskrgr
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Aug 26, 2023
2 parents 706c48b + 90fcc67 commit 4736908
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 1 addition & 2 deletions clippy_lints/src/derivable_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/derivable_impls.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
13 changes: 13 additions & 0 deletions tests/ui/derivable_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit 4736908

Please sign in to comment.