Skip to content

Commit 2645cda

Browse files
committedFeb 8, 2024
Appease rustc dead_code lint
Some of these are legit, others are false positives. I've filed rust-lang/rust#120770 for the latter.
1 parent c31cce4 commit 2645cda

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed
 

‎aya-log/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,21 @@ use bytes::BytesMut;
7474
use log::{error, Log, Record};
7575
use thiserror::Error;
7676

77+
#[allow(dead_code)] // TODO(https://github.com/rust-lang/rust/issues/120770): Remove when false positive is fixed.
7778
#[derive(Copy, Clone)]
7879
#[repr(transparent)]
7980
struct RecordFieldWrapper(RecordField);
81+
#[allow(dead_code)] // TODO(https://github.com/rust-lang/rust/issues/120770): Remove when false positive is fixed.
8082
#[derive(Copy, Clone)]
8183
#[repr(transparent)]
8284
struct ArgumentWrapper(Argument);
8385
#[derive(Copy, Clone)]
8486
#[repr(transparent)]
8587
struct DisplayHintWrapper(DisplayHint);
8688

87-
unsafe impl aya::Pod for RecordFieldWrapper {}
88-
unsafe impl aya::Pod for ArgumentWrapper {}
89-
unsafe impl aya::Pod for DisplayHintWrapper {}
89+
unsafe impl Pod for RecordFieldWrapper {}
90+
unsafe impl Pod for ArgumentWrapper {}
91+
unsafe impl Pod for DisplayHintWrapper {}
9092

9193
/// Log messages generated by `aya_log_ebpf` using the [log] crate.
9294
///

‎aya/src/maps/perf/perf_buffer.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,6 @@ impl Drop for PerfBuffer {
282282
}
283283
}
284284

285-
#[derive(Debug)]
286-
#[repr(C)]
287-
struct Sample {
288-
header: perf_event_header,
289-
size: u32,
290-
}
291-
292-
#[repr(C)]
293-
#[derive(Debug)]
294-
struct LostSamples {
295-
header: perf_event_header,
296-
id: u64,
297-
count: u64,
298-
}
299-
300285
#[cfg(test)]
301286
mod tests {
302287
use std::{fmt::Debug, mem};
@@ -309,6 +294,13 @@ mod tests {
309294
sys::{override_syscall, Syscall, TEST_MMAP_RET},
310295
};
311296

297+
#[repr(C)]
298+
#[derive(Debug)]
299+
struct Sample {
300+
header: perf_event_header,
301+
size: u32,
302+
}
303+
312304
const PAGE_SIZE: usize = 4096;
313305
union MMappedBuf {
314306
mmap_page: perf_event_mmap_page,
@@ -375,6 +367,14 @@ mod tests {
375367
};
376368
fake_mmap(&mmapped_buf);
377369

370+
#[repr(C)]
371+
#[derive(Debug)]
372+
struct LostSamples {
373+
header: perf_event_header,
374+
id: u64,
375+
count: u64,
376+
}
377+
378378
let evt = LostSamples {
379379
header: perf_event_header {
380380
type_: PERF_RECORD_LOST as u32,

‎aya/src/programs/probe.rs

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub(crate) fn lines(bytes: &[u8]) -> impl Iterator<Item = &OsStr> {
6262

6363
pub(crate) trait OsStringExt {
6464
fn starts_with(&self, needle: &OsStr) -> bool;
65+
#[allow(dead_code)] // Would be odd to have the others without this one.
6566
fn ends_with(&self, needle: &OsStr) -> bool;
6667
fn strip_prefix(&self, prefix: &OsStr) -> Option<&OsStr>;
6768
fn strip_suffix(&self, suffix: &OsStr) -> Option<&OsStr>;

0 commit comments

Comments
 (0)