Skip to content

Commit 6f9b348

Browse files
committed
Use #[expect(...)] instead of #[allow(...)] in some places
Use the #[expect(...)] attribute instead of #[allow(...)] in a bunch of places where we only have the attribute to silence a lint. The former makes sure that the silenced issue is actually flagged, or prints a warning otherwise. Signed-off-by: Daniel Müller <[email protected]>
1 parent 79bf515 commit 6f9b348

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

examples/capable/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct Command {
113113
unsafe impl Plain for capable::types::event {}
114114

115115
fn print_banner(extra_fields: bool) {
116-
#[allow(clippy::print_literal)]
116+
#[expect(clippy::print_literal)]
117117
if extra_fields {
118118
println!(
119119
"{:9} {:6} {:6} {:6} {:16} {:4} {:20} {:6} {}",

libbpf-rs/src/perf_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub struct PerfBuffer<'b> {
202202
}
203203

204204
// TODO: Document methods.
205-
#[allow(missing_docs)]
205+
#[expect(missing_docs)]
206206
impl PerfBuffer<'_> {
207207
pub fn epoll_fd(&self) -> i32 {
208208
unsafe { libbpf_sys::perf_buffer__epoll_fd(self.ptr.as_ptr()) }

libbpf-rs/src/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub fn set_print(
123123
) -> Option<(PrintLevel, PrintCallback)> {
124124
// # Safety
125125
// outer_print_cb has the same function signature as libbpf_print_fn_t
126-
#[allow(clippy::missing_transmute_annotations)]
126+
#[expect(clippy::missing_transmute_annotations)]
127127
let real_cb: libbpf_sys::libbpf_print_fn_t =
128128
unsafe { Some(mem::transmute(outer_print_cb as *const ())) };
129129
let real_cb: libbpf_sys::libbpf_print_fn_t = callback.as_ref().and(real_cb);

libbpf-rs/src/program.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl<'obj> OpenProgramMut<'obj> {
290290
unsafe { libbpf_sys::bpf_program__set_autoattach(self.ptr.as_ptr(), autoattach) };
291291
}
292292

293-
#[allow(missing_docs)]
293+
#[expect(missing_docs)]
294294
pub fn set_attach_target(
295295
&mut self,
296296
attach_prog_fd: i32,
@@ -339,7 +339,7 @@ impl<T> AsRawLibbpf for OpenProgramImpl<'_, T> {
339339
#[repr(u32)]
340340
#[derive(Copy, Clone, Debug)]
341341
// TODO: Document variants.
342-
#[allow(missing_docs)]
342+
#[expect(missing_docs)]
343343
pub enum ProgramType {
344344
Unspec = 0,
345345
SocketFilter = libbpf_sys::BPF_PROG_TYPE_SOCKET_FILTER,
@@ -454,7 +454,7 @@ impl From<u32> for ProgramType {
454454
#[repr(u32)]
455455
#[derive(Clone, Debug)]
456456
// TODO: Document variants.
457-
#[allow(missing_docs)]
457+
#[expect(missing_docs)]
458458
pub enum ProgramAttachType {
459459
CgroupInetIngress = libbpf_sys::BPF_CGROUP_INET_INGRESS,
460460
CgroupInetEgress = libbpf_sys::BPF_CGROUP_INET_EGRESS,
@@ -687,7 +687,7 @@ impl<'obj> Program<'obj> {
687687
}
688688

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

706706
// TODO: Remove once 0.25 is cut.
707707
#[deprecated = "renamed to Program::id_from_fd"]
708-
#[allow(missing_docs)]
708+
#[expect(missing_docs)]
709709
#[inline]
710710
pub fn get_id_by_fd(fd: BorrowedFd<'_>) -> Result<u32> {
711711
Self::id_from_fd(fd)

libbpf-rs/src/ringbuf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl<'slf, 'cb: 'slf> RingBufferBuilder<'slf, 'cb> {
160160
#[derive(Debug)]
161161
pub struct RingBuffer<'cb> {
162162
ptr: NonNull<libbpf_sys::ring_buffer>,
163-
#[allow(clippy::vec_box)]
163+
#[expect(clippy::vec_box)]
164164
_cbs: Vec<Box<RingBufferCallback<'cb>>>,
165165
}
166166

libbpf-rs/src/skeleton.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct ProgSkelConfig {
4242
link: Box<*mut bpf_link>,
4343
}
4444

45-
#[allow(missing_docs)]
45+
#[expect(missing_docs)]
4646
#[derive(Debug)]
4747
pub struct ObjectSkeletonConfigBuilder<'dat> {
4848
data: &'dat [u8],
@@ -77,7 +77,7 @@ impl<'dat> ObjectSkeletonConfigBuilder<'dat> {
7777
}
7878
}
7979

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

183-
#[allow(missing_docs)]
183+
#[expect(missing_docs)]
184184
pub fn build(mut self) -> Result<ObjectSkeletonConfig<'dat>> {
185185
// Holds `CString`s alive so pointers to them stay valid
186186
let mut string_pool = Vec::new();

libbpf-rs/src/tc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ pub type TcFlags = libbpf_sys::bpf_tc_flags;
2020
pub const BPF_TC_F_REPLACE: TcFlags = libbpf_sys::BPF_TC_F_REPLACE;
2121

2222
// from kernel @ include/uapi/linux/pkt_sched.h
23-
#[allow(missing_docs)]
23+
#[expect(missing_docs)]
2424
pub const TC_H_INGRESS: u32 = 0xFFFFFFF1;
25-
#[allow(missing_docs)]
25+
#[expect(missing_docs)]
2626
pub const TC_H_CLSACT: u32 = TC_H_INGRESS;
27-
#[allow(missing_docs)]
27+
#[expect(missing_docs)]
2828
pub const TC_H_MIN_INGRESS: u32 = 0xFFF2;
29-
#[allow(missing_docs)]
29+
#[expect(missing_docs)]
3030
pub const TC_H_MIN_EGRESS: u32 = 0xFFF3;
3131
#[allow(missing_docs)]
3232
pub const TC_H_MAJ_MASK: u32 = 0xFFFF0000;

0 commit comments

Comments
 (0)