Appease rustc dead_code lint

Some of these are legit, others are false positives. I've filed
https://github.com/rust-lang/rust/issues/120770 for the latter.
pull/884/head
Tamir Duberstein 9 months ago committed by Michal Rostecki
parent c31cce4a36
commit 963dd13219

@ -74,9 +74,11 @@ use bytes::BytesMut;
use log::{error, Log, Record};
use thiserror::Error;
#[allow(dead_code)] // TODO(https://github.com/rust-lang/rust/issues/120770): Remove when false positive is fixed.
#[derive(Copy, Clone)]
#[repr(transparent)]
struct RecordFieldWrapper(RecordField);
#[allow(dead_code)] // TODO(https://github.com/rust-lang/rust/issues/120770): Remove when false positive is fixed.
#[derive(Copy, Clone)]
#[repr(transparent)]
struct ArgumentWrapper(Argument);
@ -84,9 +86,9 @@ struct ArgumentWrapper(Argument);
#[repr(transparent)]
struct DisplayHintWrapper(DisplayHint);
unsafe impl aya::Pod for RecordFieldWrapper {}
unsafe impl aya::Pod for ArgumentWrapper {}
unsafe impl aya::Pod for DisplayHintWrapper {}
unsafe impl Pod for RecordFieldWrapper {}
unsafe impl Pod for ArgumentWrapper {}
unsafe impl Pod for DisplayHintWrapper {}
/// Log messages generated by `aya_log_ebpf` using the [log] crate.
///

@ -282,21 +282,6 @@ impl Drop for PerfBuffer {
}
}
#[derive(Debug)]
#[repr(C)]
struct Sample {
header: perf_event_header,
size: u32,
}
#[repr(C)]
#[derive(Debug)]
struct LostSamples {
header: perf_event_header,
id: u64,
count: u64,
}
#[cfg(test)]
mod tests {
use std::{fmt::Debug, mem};
@ -309,6 +294,13 @@ mod tests {
sys::{override_syscall, Syscall, TEST_MMAP_RET},
};
#[repr(C)]
#[derive(Debug)]
struct Sample {
header: perf_event_header,
size: u32,
}
const PAGE_SIZE: usize = 4096;
union MMappedBuf {
mmap_page: perf_event_mmap_page,
@ -375,6 +367,14 @@ mod tests {
};
fake_mmap(&mmapped_buf);
#[repr(C)]
#[derive(Debug)]
struct LostSamples {
header: perf_event_header,
id: u64,
count: u64,
}
let evt = LostSamples {
header: perf_event_header {
type_: PERF_RECORD_LOST as u32,

@ -62,6 +62,7 @@ pub(crate) fn lines(bytes: &[u8]) -> impl Iterator<Item = &OsStr> {
pub(crate) trait OsStringExt {
fn starts_with(&self, needle: &OsStr) -> bool;
#[allow(dead_code)] // Would be odd to have the others without this one.
fn ends_with(&self, needle: &OsStr) -> bool;
fn strip_prefix(&self, prefix: &OsStr) -> Option<&OsStr>;
fn strip_suffix(&self, suffix: &OsStr) -> Option<&OsStr>;

Loading…
Cancel
Save