From e063f0c31b3f5e6232b7dd3cdeec190f7aae471a Mon Sep 17 00:00:00 2001 From: Michael Mullin Date: Thu, 26 Jan 2023 12:57:48 -0500 Subject: [PATCH] Ignore clippy lint warning for derive default Rust version 1.62 made it possible to use #[derive(Default)] on enums. (see: https://github.com/rust-lang/rust/pull/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 --- libbpf-cargo/src/btf/btf.rs | 3 +++ libbpf-cargo/src/test.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/libbpf-cargo/src/btf/btf.rs b/libbpf-cargo/src/btf/btf.rs index 42eedee4..57740dbe 100644 --- a/libbpf-cargo/src/btf/btf.rs +++ b/libbpf-cargo/src/btf/btf.rs @@ -988,6 +988,9 @@ impl Btf { // write an impl Default for this enum if !t.values.is_empty() { + // TODO: remove #[allow(clippy::derivable_impls)] + // once minimum rust at 1.62+ + writeln!(def, r#"#[allow(clippy::derivable_impls)]"#)?; writeln!(def, r#"impl Default for {name} {{"#, name = t.name)?; writeln!(def, r#" fn default() -> Self {{"#)?; writeln!( diff --git a/libbpf-cargo/src/test.rs b/libbpf-cargo/src/test.rs index 38228f6a..83570a69 100644 --- a/libbpf-cargo/src/test.rs +++ b/libbpf-cargo/src/test.rs @@ -1480,6 +1480,7 @@ pub enum Foo { One = 1, seven = 7, } +#[allow(clippy::derivable_impls)] impl Default for Foo { fn default() -> Self { Foo::Zero @@ -2075,6 +2076,7 @@ pub struct Foo { pub enum __anon_1 { FOO = 1, } +#[allow(clippy::derivable_impls)] impl Default for __anon_1 { fn default() -> Self { __anon_1::FOO