Skip to content

Commit e063f0c

Browse files
mimullin-bbrymasmullin2000
authored andcommitted
Ignore clippy lint warning for derive default
Rust version 1.62 made it possible to use #[derive(Default)] on enums. (see: rust-lang/rust#94457) As of rust version 1.68, the default clippy configuration will print a warning for manually impl Derive on enums. As such, users of libbpf-cargo will begin to experience clippy warnings when they migrate to version 1.68. libbpf-cargo's minimum rust version is 1.58, thus the recommended method to remove the clippy warnings, is not yet an option for the project. Add a #[allow(clippy::derivable_impls)], to suppress the clippy warning on all generated skeletons. Add a TODO to remove this once the project moves to a minimum rust version of 1.62 Signed-off-by: Michael Mullin <[email protected]>
1 parent 1a8155f commit e063f0c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

libbpf-cargo/src/btf/btf.rs

+3
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,9 @@ impl Btf {
988988

989989
// write an impl Default for this enum
990990
if !t.values.is_empty() {
991+
// TODO: remove #[allow(clippy::derivable_impls)]
992+
// once minimum rust at 1.62+
993+
writeln!(def, r#"#[allow(clippy::derivable_impls)]"#)?;
991994
writeln!(def, r#"impl Default for {name} {{"#, name = t.name)?;
992995
writeln!(def, r#" fn default() -> Self {{"#)?;
993996
writeln!(

libbpf-cargo/src/test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ pub enum Foo {
14801480
One = 1,
14811481
seven = 7,
14821482
}
1483+
#[allow(clippy::derivable_impls)]
14831484
impl Default for Foo {
14841485
fn default() -> Self {
14851486
Foo::Zero
@@ -2075,6 +2076,7 @@ pub struct Foo {
20752076
pub enum __anon_1 {
20762077
FOO = 1,
20772078
}
2079+
#[allow(clippy::derivable_impls)]
20782080
impl Default for __anon_1 {
20792081
fn default() -> Self {
20802082
__anon_1::FOO

0 commit comments

Comments
 (0)