From 4ef4f09a8963f2da3eaa0b1d1cee8b4a67116513 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sat, 6 Jan 2024 21:49:39 +0900 Subject: [PATCH] Ignore dead_code warnings for tuple structs ``` warning: field `0` is never read --> crossbeam-epoch/src/collector.rs:290:21 | 290 | struct Elem(i32); | ---- ^^^ | | | field in this struct | = note: `#[warn(dead_code)]` on by default help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 290 | struct Elem(()); | ~~ warning: field `0` is never read --> crossbeam-epoch/src/collector.rs:354:21 | 354 | struct Elem(i32); | ---- ^^^ | | | field in this struct | help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 354 | struct Elem(()); | ~~ warning: field `0` is never read --> crossbeam-epoch/src/collector.rs:431:21 | 431 | struct Elem(i32); | ---- ^^^ | | | field in this struct | help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 431 | struct Elem(()); | ~~ warning: field `0` is never read --> crossbeam-utils/tests/atomic_cell.rs:9:22 | 9 | struct UsizeWrap(usize); | --------- ^^^^^ | | | field in this struct | = note: `#[warn(dead_code)]` on by default help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 9 | struct UsizeWrap(()); | ~~ warning: field `0` is never read --> crossbeam-utils/tests/atomic_cell.rs:10:19 | 10 | struct U8Wrap(bool); | ------ ^^^^ | | | field in this struct | help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 10 | struct U8Wrap(()); | ~~ warning: field `0` is never read --> crossbeam-utils/tests/atomic_cell.rs:11:20 | 11 | struct I16Wrap(i16); | ------- ^^^ | | | field in this struct | help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 11 | struct I16Wrap(()); | ~~ warning: field `0` is never read --> crossbeam-utils/tests/atomic_cell.rs:13:22 | 13 | struct U64Align8(u64); | --------- ^^^ | | | field in this struct | help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 13 | struct U64Align8(()); | ~~ warning: field `0` is never read --> crossbeam-channel/benchmarks/message.rs:6:27 | 6 | pub(crate) struct Message(pub(crate) [usize; LEN]); | ------- ^^^^^^^^^^^^^^^^^^^^^^^ | | | field in this struct | = note: `Message` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis = note: `#[warn(dead_code)]` on by default help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 6 | pub(crate) struct Message(()); | ~~ ``` --- crossbeam-channel/benchmarks/message.rs | 2 +- crossbeam-epoch/src/collector.rs | 6 +++--- crossbeam-utils/tests/atomic_cell.rs | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crossbeam-channel/benchmarks/message.rs b/crossbeam-channel/benchmarks/message.rs index f8a921ec7..55c1697a2 100644 --- a/crossbeam-channel/benchmarks/message.rs +++ b/crossbeam-channel/benchmarks/message.rs @@ -3,7 +3,7 @@ use std::fmt; const LEN: usize = 1; #[derive(Clone, Copy)] -pub struct Message(pub [usize; LEN]); +pub struct Message(#[allow(dead_code)] [usize; LEN]); impl fmt::Debug for Message { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/crossbeam-epoch/src/collector.rs b/crossbeam-epoch/src/collector.rs index 5b0851184..efcf0fe8d 100644 --- a/crossbeam-epoch/src/collector.rs +++ b/crossbeam-epoch/src/collector.rs @@ -286,7 +286,7 @@ mod tests { const COUNT: usize = 100_000; static DROPS: AtomicUsize = AtomicUsize::new(0); - struct Elem(i32); + struct Elem(#[allow(dead_code)] i32); impl Drop for Elem { fn drop(&mut self) { @@ -350,7 +350,7 @@ mod tests { const COUNT: usize = 700; static DROPS: AtomicUsize = AtomicUsize::new(0); - struct Elem(i32); + struct Elem(#[allow(dead_code)] i32); impl Drop for Elem { fn drop(&mut self) { @@ -427,7 +427,7 @@ mod tests { const COUNT: usize = 100_000; static DROPS: AtomicUsize = AtomicUsize::new(0); - struct Elem(i32); + struct Elem(#[allow(dead_code)] i32); impl Drop for Elem { fn drop(&mut self) { diff --git a/crossbeam-utils/tests/atomic_cell.rs b/crossbeam-utils/tests/atomic_cell.rs index 7a2689d99..9fe69328d 100644 --- a/crossbeam-utils/tests/atomic_cell.rs +++ b/crossbeam-utils/tests/atomic_cell.rs @@ -6,11 +6,11 @@ use crossbeam_utils::atomic::AtomicCell; #[test] fn is_lock_free() { - struct UsizeWrap(usize); - struct U8Wrap(bool); - struct I16Wrap(i16); + struct UsizeWrap(#[allow(dead_code)] usize); + struct U8Wrap(#[allow(dead_code)] bool); + struct I16Wrap(#[allow(dead_code)] i16); #[repr(align(8))] - struct U64Align8(u64); + struct U64Align8(#[allow(dead_code)] u64); assert!(AtomicCell::::is_lock_free()); assert!(AtomicCell::::is_lock_free());