diff --git a/ebpf/aya-ebpf/Cargo.toml b/ebpf/aya-ebpf/Cargo.toml index cb48f183..3495ddf5 100644 --- a/ebpf/aya-ebpf/Cargo.toml +++ b/ebpf/aya-ebpf/Cargo.toml @@ -12,14 +12,6 @@ edition.workspace = true aya-ebpf-cty = { version = "^0.2.2", path = "../aya-ebpf-cty" } aya-ebpf-macros = { version = "^0.1.1", path = "../../aya-ebpf-macros" } aya-ebpf-bindings = { version = "^0.1.1", path = "../aya-ebpf-bindings" } -const-assert = { workspace = true, optional = true } [build-dependencies] rustversion = { workspace = true } - -[features] -default = [] -# TODO(https://github.com/rust-lang/rust/issues/76560): Always utilize the -# logic gated behind this feature. This is not currently possible because the -# underlying `const_generic_exprs` language feature is still incomplete. -const_assert = ["const-assert"] diff --git a/ebpf/aya-ebpf/src/lib.rs b/ebpf/aya-ebpf/src/lib.rs index e141bfe6..7766f8f4 100644 --- a/ebpf/aya-ebpf/src/lib.rs +++ b/ebpf/aya-ebpf/src/lib.rs @@ -8,11 +8,7 @@ html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg", html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg" )] -#![cfg_attr( - feature = "const_assert", - allow(incomplete_features), - feature(generic_const_exprs) -)] +#![cfg_attr(unstable, allow(incomplete_features), feature(generic_const_exprs))] #![cfg_attr(unstable, feature(never_type))] #![cfg_attr(target_arch = "bpf", feature(asm_experimental_arch))] #![allow(clippy::missing_safety_doc)] diff --git a/ebpf/aya-ebpf/src/maps/ring_buf.rs b/ebpf/aya-ebpf/src/maps/ring_buf.rs index ee544efe..679b65c8 100644 --- a/ebpf/aya-ebpf/src/maps/ring_buf.rs +++ b/ebpf/aya-ebpf/src/maps/ring_buf.rs @@ -5,9 +5,6 @@ use core::{ ops::{Deref, DerefMut}, }; -#[cfg(feature = "const_assert")] -use const_assert::{Assert, IsTrue}; - use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_RINGBUF}, helpers::{ @@ -17,6 +14,17 @@ use crate::{ maps::PinningType, }; +#[cfg(unstable)] +mod const_assert { + pub struct Assert {} + + pub trait IsTrue {} + + impl IsTrue for Assert {} +} +#[cfg(unstable)] +use const_assert::{Assert, IsTrue}; + #[repr(transparent)] pub struct RingBuf { def: UnsafeCell, @@ -93,7 +101,7 @@ impl RingBuf { /// Reserve memory in the ring buffer that can fit `T`. /// /// Returns `None` if the ring buffer is full. - #[cfg(feature = "const_assert")] + #[cfg(unstable)] pub fn reserve(&self, flags: u64) -> Option> where Assert<{ 8 % mem::align_of::() == 0 }>: IsTrue, @@ -109,7 +117,7 @@ impl RingBuf { /// be equal or smaller than 8. If you use this with a `T` that isn't properly aligned, this /// function will be compiled to a panic; depending on your panic_handler, this may make /// the eBPF program fail to load, or it may make it have undefined behavior. - #[cfg(not(feature = "const_assert"))] + #[cfg(not(unstable))] pub fn reserve(&self, flags: u64) -> Option> { assert_eq!(8 % mem::align_of::(), 0); self.reserve_impl(flags) diff --git a/xtask/public-api/aya-ebpf.txt b/xtask/public-api/aya-ebpf.txt index 7188dcb0..1fbaf3ba 100644 --- a/xtask/public-api/aya-ebpf.txt +++ b/xtask/public-api/aya-ebpf.txt @@ -469,7 +469,7 @@ impl aya_ebpf::maps::ring_buf::RingBuf pub fn aya_ebpf::maps::ring_buf::RingBuf::output(&self, data: &T, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::ring_buf::RingBuf::pinned(byte_size: u32, flags: u32) -> Self pub fn aya_ebpf::maps::ring_buf::RingBuf::query(&self, flags: u64) -> u64 -pub fn aya_ebpf::maps::ring_buf::RingBuf::reserve(&self, flags: u64) -> core::option::Option> where const_assert::Assert<{ _ }>: const_assert::IsTrue +pub fn aya_ebpf::maps::ring_buf::RingBuf::reserve(&self, flags: u64) -> core::option::Option> where Assert<{ _ }>: IsTrue pub const fn aya_ebpf::maps::ring_buf::RingBuf::with_byte_size(byte_size: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::ring_buf::RingBuf impl !core::marker::Freeze for aya_ebpf::maps::ring_buf::RingBuf @@ -1195,7 +1195,7 @@ impl aya_ebpf::maps::ring_buf::RingBuf pub fn aya_ebpf::maps::ring_buf::RingBuf::output(&self, data: &T, flags: u64) -> core::result::Result<(), i64> pub const fn aya_ebpf::maps::ring_buf::RingBuf::pinned(byte_size: u32, flags: u32) -> Self pub fn aya_ebpf::maps::ring_buf::RingBuf::query(&self, flags: u64) -> u64 -pub fn aya_ebpf::maps::ring_buf::RingBuf::reserve(&self, flags: u64) -> core::option::Option> where const_assert::Assert<{ _ }>: const_assert::IsTrue +pub fn aya_ebpf::maps::ring_buf::RingBuf::reserve(&self, flags: u64) -> core::option::Option> where Assert<{ _ }>: IsTrue pub const fn aya_ebpf::maps::ring_buf::RingBuf::with_byte_size(byte_size: u32, flags: u32) -> Self impl core::marker::Sync for aya_ebpf::maps::ring_buf::RingBuf impl !core::marker::Freeze for aya_ebpf::maps::ring_buf::RingBuf