Skip to content

Commit

Permalink
Ignore dead_code warnings for tuple structs
Browse files Browse the repository at this point in the history
```
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(());
  |                           ~~
```
  • Loading branch information
taiki-e committed Jan 8, 2024
1 parent 95d0bd0 commit 4ef4f09
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crossbeam-channel/benchmarks/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions crossbeam-epoch/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions crossbeam-utils/tests/atomic_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<usize>::is_lock_free());
assert!(AtomicCell::<isize>::is_lock_free());
Expand Down

0 comments on commit 4ef4f09

Please sign in to comment.