Skip to content

Use #[expect(...)] instead of #[allow(...)] in some places #1073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/capable/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct Command {
unsafe impl Plain for capable::types::event {}

fn print_banner(extra_fields: bool) {
#[allow(clippy::print_literal)]
#[expect(clippy::print_literal)]
if extra_fields {
println!(
"{:9} {:6} {:6} {:6} {:16} {:4} {:20} {:6} {}",
Expand Down
2 changes: 1 addition & 1 deletion libbpf-rs/src/perf_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub struct PerfBuffer<'b> {
}

// TODO: Document methods.
#[allow(missing_docs)]
#[expect(missing_docs)]
impl PerfBuffer<'_> {
pub fn epoll_fd(&self) -> i32 {
unsafe { libbpf_sys::perf_buffer__epoll_fd(self.ptr.as_ptr()) }
Expand Down
2 changes: 1 addition & 1 deletion libbpf-rs/src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn set_print(
) -> Option<(PrintLevel, PrintCallback)> {
// # Safety
// outer_print_cb has the same function signature as libbpf_print_fn_t
#[allow(clippy::missing_transmute_annotations)]
#[expect(clippy::missing_transmute_annotations)]
let real_cb: libbpf_sys::libbpf_print_fn_t =
unsafe { Some(mem::transmute(outer_print_cb as *const ())) };
let real_cb: libbpf_sys::libbpf_print_fn_t = callback.as_ref().and(real_cb);
Expand Down
10 changes: 5 additions & 5 deletions libbpf-rs/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl<'obj> OpenProgramMut<'obj> {
unsafe { libbpf_sys::bpf_program__set_autoattach(self.ptr.as_ptr(), autoattach) };
}

#[allow(missing_docs)]
#[expect(missing_docs)]
pub fn set_attach_target(
&mut self,
attach_prog_fd: i32,
Expand Down Expand Up @@ -339,7 +339,7 @@ impl<T> AsRawLibbpf for OpenProgramImpl<'_, T> {
#[repr(u32)]
#[derive(Copy, Clone, Debug)]
// TODO: Document variants.
#[allow(missing_docs)]
#[expect(missing_docs)]
pub enum ProgramType {
Unspec = 0,
SocketFilter = libbpf_sys::BPF_PROG_TYPE_SOCKET_FILTER,
Expand Down Expand Up @@ -454,7 +454,7 @@ impl From<u32> for ProgramType {
#[repr(u32)]
#[derive(Clone, Debug)]
// TODO: Document variants.
#[allow(missing_docs)]
#[expect(missing_docs)]
pub enum ProgramAttachType {
CgroupInetIngress = libbpf_sys::BPF_CGROUP_INET_INGRESS,
CgroupInetEgress = libbpf_sys::BPF_CGROUP_INET_EGRESS,
Expand Down Expand Up @@ -687,7 +687,7 @@ impl<'obj> Program<'obj> {
}

#[deprecated = "renamed to Program::fd_from_id"]
#[allow(missing_docs)]
#[expect(missing_docs)]
#[inline]
pub fn get_fd_by_id(id: u32) -> Result<OwnedFd> {
Self::fd_from_id(id)
Expand All @@ -705,7 +705,7 @@ impl<'obj> Program<'obj> {

// TODO: Remove once 0.25 is cut.
#[deprecated = "renamed to Program::id_from_fd"]
#[allow(missing_docs)]
#[expect(missing_docs)]
#[inline]
pub fn get_id_by_fd(fd: BorrowedFd<'_>) -> Result<u32> {
Self::id_from_fd(fd)
Expand Down
2 changes: 1 addition & 1 deletion libbpf-rs/src/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl<'slf, 'cb: 'slf> RingBufferBuilder<'slf, 'cb> {
#[derive(Debug)]
pub struct RingBuffer<'cb> {
ptr: NonNull<libbpf_sys::ring_buffer>,
#[allow(clippy::vec_box)]
#[expect(clippy::vec_box)]
_cbs: Vec<Box<RingBufferCallback<'cb>>>,
}

Expand Down
6 changes: 3 additions & 3 deletions libbpf-rs/src/skeleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ProgSkelConfig {
link: Box<*mut bpf_link>,
}

#[allow(missing_docs)]
#[expect(missing_docs)]
#[derive(Debug)]
pub struct ObjectSkeletonConfigBuilder<'dat> {
data: &'dat [u8],
Expand Down Expand Up @@ -77,7 +77,7 @@ impl<'dat> ObjectSkeletonConfigBuilder<'dat> {
}
}

#[allow(missing_docs)]
#[expect(missing_docs)]
pub fn name<T: AsRef<str>>(&mut self, name: T) -> &mut Self {
self.name = Some(name.as_ref().to_string());
self
Expand Down Expand Up @@ -180,7 +180,7 @@ impl<'dat> ObjectSkeletonConfigBuilder<'dat> {
Some(layout)
}

#[allow(missing_docs)]
#[expect(missing_docs)]
pub fn build(mut self) -> Result<ObjectSkeletonConfig<'dat>> {
// Holds `CString`s alive so pointers to them stay valid
let mut string_pool = Vec::new();
Expand Down
8 changes: 4 additions & 4 deletions libbpf-rs/src/tc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ pub type TcFlags = libbpf_sys::bpf_tc_flags;
pub const BPF_TC_F_REPLACE: TcFlags = libbpf_sys::BPF_TC_F_REPLACE;

// from kernel @ include/uapi/linux/pkt_sched.h
#[allow(missing_docs)]
#[expect(missing_docs)]
pub const TC_H_INGRESS: u32 = 0xFFFFFFF1;
#[allow(missing_docs)]
#[expect(missing_docs)]
pub const TC_H_CLSACT: u32 = TC_H_INGRESS;
#[allow(missing_docs)]
#[expect(missing_docs)]
pub const TC_H_MIN_INGRESS: u32 = 0xFFF2;
#[allow(missing_docs)]
#[expect(missing_docs)]
pub const TC_H_MIN_EGRESS: u32 = 0xFFF3;
#[allow(missing_docs)]
pub const TC_H_MAJ_MASK: u32 = 0xFFFF0000;
Expand Down
Loading