diff --git a/.github/workflows/build-aya-bpf.yml b/.github/workflows/build-aya-bpf.yml index a29d7c09a..1d134ca93 100644 --- a/.github/workflows/build-aya-bpf.yml +++ b/.github/workflows/build-aya-bpf.yml @@ -30,7 +30,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: nightly-2023-01-10 components: rust-src override: true diff --git a/.github/workflows/build-aya.yml b/.github/workflows/build-aya.yml index 991298fa4..0b9a0ef5e 100644 --- a/.github/workflows/build-aya.yml +++ b/.github/workflows/build-aya.yml @@ -57,7 +57,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: nightly-2023-01-10 components: rustfmt, clippy, rust-src target: x86_64-unknown-linux-musl override: true diff --git a/aya-obj/src/btf/types.rs b/aya-obj/src/btf/types.rs index 177b97a56..72474f7ef 100644 --- a/aya-obj/src/btf/types.rs +++ b/aya-obj/src/btf/types.rs @@ -799,9 +799,10 @@ impl DeclTag { } } -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] #[repr(u32)] pub enum BtfKind { + #[default] Unknown = 0, Int = 1, Ptr = 2, @@ -879,12 +880,6 @@ impl Display for BtfKind { } } -impl Default for BtfKind { - fn default() -> Self { - BtfKind::Unknown - } -} - unsafe fn read(data: &[u8]) -> Result { if mem::size_of::() > data.len() { return Err(BtfError::InvalidTypeInfo); diff --git a/aya-obj/src/maps.rs b/aya-obj/src/maps.rs index aa2d213c6..a6c3c96ca 100644 --- a/aya-obj/src/maps.rs +++ b/aya-obj/src/maps.rs @@ -81,9 +81,10 @@ pub struct BtfMapDef { /// Upon pinning a map, a file representation is created for the map, /// so that the map can be alive and retrievable across sessions. #[repr(u32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)] pub enum PinningType { /// No pinning + #[default] None = 0, /// Pin by the name ByName = 1, @@ -112,12 +113,6 @@ impl TryFrom for PinningType { } } -impl Default for PinningType { - fn default() -> Self { - PinningType::None - } -} - /// Map definition in legacy BPF map declaration style #[allow(non_camel_case_types)] #[repr(C)] diff --git a/aya-obj/src/obj.rs b/aya-obj/src/obj.rs index 239432364..72f13ed76 100644 --- a/aya-obj/src/obj.rs +++ b/aya-obj/src/obj.rs @@ -1463,7 +1463,6 @@ mod tests { map_flags: 5, id: 0, pinning: PinningType::None, - ..Default::default() }; assert_eq!( @@ -1482,7 +1481,6 @@ mod tests { map_flags: 5, id: 6, pinning: PinningType::ByName, - ..Default::default() }; assert_eq!(parse_map_def("foo", bytes_of(&def)).unwrap(), def); @@ -1498,7 +1496,6 @@ mod tests { map_flags: 5, id: 6, pinning: PinningType::ByName, - ..Default::default() }; let mut buf = [0u8; 128]; unsafe { ptr::write_unaligned(buf.as_mut_ptr() as *mut _, def) }; @@ -1529,7 +1526,6 @@ mod tests { map_flags: 5, id: 0, pinning: PinningType::None, - ..Default::default() }) ), "foo" @@ -1664,7 +1660,7 @@ mod tests { buf.extend(&map_data); buf.extend(&map_data); // throw in some padding - buf.extend(&[0, 0, 0, 0]); + buf.extend([0, 0, 0, 0]); buf.extend(&map_data); assert_matches!( obj.parse_section(fake_section(BpfSectionKind::Maps, "maps", buf.as_slice(),)), @@ -2198,7 +2194,6 @@ mod tests { map_flags: BPF_F_RDONLY_PROG, id: 1, pinning: PinningType::None, - ..Default::default() }, section_index: 1, symbol_index: 1, diff --git a/aya-obj/src/programs/cgroup_sock.rs b/aya-obj/src/programs/cgroup_sock.rs index ed470f8ae..b9194e245 100644 --- a/aya-obj/src/programs/cgroup_sock.rs +++ b/aya-obj/src/programs/cgroup_sock.rs @@ -7,26 +7,19 @@ use crate::{ }; /// Defines where to attach a `CgroupSock` program. -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Default)] pub enum CgroupSockAttachType { /// Called after the IPv4 bind events. PostBind4, /// Called after the IPv6 bind events. PostBind6, /// Attach to IPv4 connect events. + #[default] SockCreate, /// Attach to IPv6 connect events. SockRelease, } -impl Default for CgroupSockAttachType { - // The kernel checks for a 0 attach_type and sets it to sock_create - // We may as well do that here also - fn default() -> Self { - CgroupSockAttachType::SockCreate - } -} - impl From for bpf_attach_type { fn from(s: CgroupSockAttachType) -> bpf_attach_type { match s { diff --git a/netlify.toml b/netlify.toml index 3ad629123..8e0773eab 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,3 @@ [build] publish = "site" - command = "rustup toolchain install nightly -c rust-src && cargo xtask docs" + command = "rustup toolchain install nightly-2023-01-10 -c rust-src && cargo xtask docs" diff --git a/xtask/src/build_ebpf.rs b/xtask/src/build_ebpf.rs index 4f98febaa..cd5b92348 100644 --- a/xtask/src/build_ebpf.rs +++ b/xtask/src/build_ebpf.rs @@ -60,7 +60,7 @@ fn build_rust_ebpf(opts: &BuildEbpfOptions) -> anyhow::Result<()> { let target = format!("--target={}", opts.target); let mut args = vec![ - "+nightly", + "+nightly-2023-01-10", "build", "--verbose", target.as_str(), diff --git a/xtask/src/docs/mod.rs b/xtask/src/docs/mod.rs index bfeca3a99..b17ecb7ca 100644 --- a/xtask/src/docs/mod.rs +++ b/xtask/src/docs/mod.rs @@ -61,7 +61,7 @@ fn build_docs(working_dir: &PathBuf, abs_header_path: &Path) -> Result<(), anyho .expect("failed to replace logo"); assert!(replace.success()); - let args = vec!["+nightly", "doc", "--no-deps", "--all-features"]; + let args = vec!["+nightly-2023-01-10", "doc", "--no-deps", "--all-features"]; let status = Command::new("cargo") .current_dir(working_dir)