Skip to content

Commit

Permalink
Ignore dead_code warnings for tuple structs in tests
Browse files Browse the repository at this point in the history
We use Box to be able to catch memory leaks using miri/valgrind.

```
error: field `0` is never read
  --> tests/join.rs:29:24
   |
29 |             struct Fut(Box<i32>);
   |                    --- ^^^^^^^^
   |                    |
   |                    field in this struct
...
99 |     future!(f, POLL, DROP_F, DROP_T);
   |     -------------------------------- in this macro invocation
   |
   = note: `-D dead-code` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(dead_code)]`
   = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
   |
29 |             struct Fut(());
   |                        ~~

error: field `0` is never read
  --> tests/join.rs:47:24
   |
47 |             struct Out(Box<i32>, bool);
   |                    --- ^^^^^^^^
   |                    |
   |                    field in this struct
...
99 |     future!(f, POLL, DROP_F, DROP_T);
   |     -------------------------------- in this macro invocation
   |
   = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
   |
47 |             struct Out((), bool);
   |                        ~~

error: field `0` is never read
   --> tests/join.rs:75:26
    |
75  |             struct Guard(Box<i32>);
    |                    ----- ^^^^^^^^
    |                    |
    |                    field in this struct
...
100 |     schedule!(s, SCHEDULE, DROP_S);
    |     ------------------------------ in this macro invocation
    |
    = note: this error originates in the macro `schedule` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
75  |             struct Guard(());
    |                          ~~

error: field `0` is never read
   --> tests/join.rs:29:24
    |
29  |             struct Fut(Box<i32>);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
118 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
29  |             struct Fut(());
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:47:24
    |
47  |             struct Out(Box<i32>, bool);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
118 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
47  |             struct Out((), bool);
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:75:26
    |
75  |             struct Guard(Box<i32>);
    |                    ----- ^^^^^^^^
    |                    |
    |                    field in this struct
...
119 |     schedule!(s, SCHEDULE, DROP_S);
    |     ------------------------------ in this macro invocation
    |
    = note: this error originates in the macro `schedule` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
75  |             struct Guard(());
    |                          ~~

error: field `0` is never read
   --> tests/join.rs:29:24
    |
29  |             struct Fut(Box<i32>);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
137 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
29  |             struct Fut(());
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:47:24
    |
47  |             struct Out(Box<i32>, bool);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
137 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
47  |             struct Out((), bool);
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:75:26
    |
75  |             struct Guard(Box<i32>);
    |                    ----- ^^^^^^^^
    |                    |
    |                    field in this struct
...
138 |     schedule!(s, SCHEDULE, DROP_S);
    |     ------------------------------ in this macro invocation
    |
    = note: this error originates in the macro `schedule` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
75  |             struct Guard(());
    |                          ~~

error: field `0` is never read
   --> tests/join.rs:29:24
    |
29  |             struct Fut(Box<i32>);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
156 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
29  |             struct Fut(());
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:47:24
    |
47  |             struct Out(Box<i32>, bool);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
156 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
47  |             struct Out((), bool);
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:75:26
    |
75  |             struct Guard(Box<i32>);
    |                    ----- ^^^^^^^^
    |                    |
    |                    field in this struct
...
157 |     schedule!(s, SCHEDULE, DROP_S);
    |     ------------------------------ in this macro invocation
    |
    = note: this error originates in the macro `schedule` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
75  |             struct Guard(());
    |                          ~~

error: field `0` is never read
   --> tests/join.rs:29:24
    |
29  |             struct Fut(Box<i32>);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
185 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
29  |             struct Fut(());
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:47:24
    |
47  |             struct Out(Box<i32>, bool);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
185 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
47  |             struct Out((), bool);
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:75:26
    |
75  |             struct Guard(Box<i32>);
    |                    ----- ^^^^^^^^
    |                    |
    |                    field in this struct
...
186 |     schedule!(s, SCHEDULE, DROP_S);
    |     ------------------------------ in this macro invocation
    |
    = note: this error originates in the macro `schedule` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
75  |             struct Guard(());
    |                          ~~

error: field `0` is never read
   --> tests/join.rs:29:24
    |
29  |             struct Fut(Box<i32>);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
216 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
29  |             struct Fut(());
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:47:24
    |
47  |             struct Out(Box<i32>, bool);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
216 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
47  |             struct Out((), bool);
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:75:26
    |
75  |             struct Guard(Box<i32>);
    |                    ----- ^^^^^^^^
    |                    |
    |                    field in this struct
...
217 |     schedule!(s, SCHEDULE, DROP_S);
    |     ------------------------------ in this macro invocation
    |
    = note: this error originates in the macro `schedule` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
75  |             struct Guard(());
    |                          ~~

error: field `0` is never read
   --> tests/join.rs:29:24
    |
29  |             struct Fut(Box<i32>);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
247 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
29  |             struct Fut(());
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:47:24
    |
47  |             struct Out(Box<i32>, bool);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
247 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
47  |             struct Out((), bool);
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:75:26
    |
75  |             struct Guard(Box<i32>);
    |                    ----- ^^^^^^^^
    |                    |
    |                    field in this struct
...
248 |     schedule!(s, SCHEDULE, DROP_S);
    |     ------------------------------ in this macro invocation
    |
    = note: this error originates in the macro `schedule` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
75  |             struct Guard(());
    |                          ~~

error: field `0` is never read
   --> tests/join.rs:29:24
    |
29  |             struct Fut(Box<i32>);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
285 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
29  |             struct Fut(());
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:47:24
    |
47  |             struct Out(Box<i32>, bool);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
285 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
47  |             struct Out((), bool);
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:75:26
    |
75  |             struct Guard(Box<i32>);
    |                    ----- ^^^^^^^^
    |                    |
    |                    field in this struct
...
286 |     schedule!(s, SCHEDULE, DROP_S);
    |     ------------------------------ in this macro invocation
    |
    = note: this error originates in the macro `schedule` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
75  |             struct Guard(());
    |                          ~~

error: field `0` is never read
   --> tests/join.rs:29:24
    |
29  |             struct Fut(Box<i32>);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
319 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
29  |             struct Fut(());
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:47:24
    |
47  |             struct Out(Box<i32>, bool);
    |                    --- ^^^^^^^^
    |                    |
    |                    field in this struct
...
319 |     future!(f, POLL, DROP_F, DROP_T);
    |     -------------------------------- in this macro invocation
    |
    = note: this error originates in the macro `future` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
47  |             struct Out((), bool);
    |                        ~~

error: field `0` is never read
   --> tests/join.rs:75:26
    |
75  |             struct Guard(Box<i32>);
    |                    ----- ^^^^^^^^
    |                    |
    |                    field in this struct
...
320 |     schedule!(s, SCHEDULE, DROP_S);
    |     ------------------------------ in this macro invocation
    |
    = note: this error originates in the macro `schedule` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
75  |             struct Guard(());
    |                          ~~
```
  • Loading branch information
taiki-e committed Jan 7, 2024
1 parent 8f2c088 commit b5f4978
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ macro_rules! future {
static $drop: AtomicUsize = AtomicUsize::new(0);

let $name = {
struct Fut(Box<i32>);
struct Fut(#[allow(dead_code)] Box<i32>);

impl Future for Fut {
type Output = Box<i32>;
Expand Down Expand Up @@ -56,7 +56,7 @@ macro_rules! schedule {
static $sched: AtomicUsize = AtomicUsize::new(0);

let $name = {
struct Guard(Box<i32>);
struct Guard(#[allow(dead_code)] Box<i32>);

impl Drop for Guard {
fn drop(&mut self) {
Expand Down
6 changes: 3 additions & 3 deletions tests/cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ macro_rules! future {
static $drop_t: AtomicUsize = AtomicUsize::new(0);

let $name = {
struct Fut(Box<i32>);
struct Fut(#[allow(dead_code)] Box<i32>);

impl Future for Fut {
type Output = Out;
Expand All @@ -43,7 +43,7 @@ macro_rules! future {
}

#[derive(Default)]
struct Out(Box<i32>, bool);
struct Out(#[allow(dead_code)] Box<i32>, bool);

impl Drop for Out {
fn drop(&mut self) {
Expand Down Expand Up @@ -71,7 +71,7 @@ macro_rules! schedule {
static $sched: AtomicUsize = AtomicUsize::new(0);

let $name = {
struct Guard(Box<i32>);
struct Guard(#[allow(dead_code)] Box<i32>);

impl Drop for Guard {
fn drop(&mut self) {
Expand Down
6 changes: 3 additions & 3 deletions tests/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ macro_rules! future {
static $drop_t: AtomicUsize = AtomicUsize::new(0);

let $name = {
struct Fut(Box<i32>);
struct Fut(#[allow(dead_code)] Box<i32>);

impl Future for Fut {
type Output = Out;
Expand All @@ -44,7 +44,7 @@ macro_rules! future {
}

#[derive(Default)]
struct Out(Box<i32>, bool);
struct Out(#[allow(dead_code)] Box<i32>, bool);

impl Drop for Out {
fn drop(&mut self) {
Expand Down Expand Up @@ -72,7 +72,7 @@ macro_rules! schedule {
static $sched: AtomicUsize = AtomicUsize::new(0);

let $name = {
struct Guard(Box<i32>);
struct Guard(#[allow(dead_code)] Box<i32>);

impl Drop for Guard {
fn drop(&mut self) {
Expand Down
4 changes: 2 additions & 2 deletions tests/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ macro_rules! future {
static $drop: AtomicUsize = AtomicUsize::new(0);

let $name = {
struct Fut(Box<i32>);
struct Fut(#[allow(dead_code)] Box<i32>);

impl Future for Fut {
type Output = ();
Expand Down Expand Up @@ -59,7 +59,7 @@ macro_rules! schedule {
static $sched: AtomicUsize = AtomicUsize::new(0);

let $name = {
struct Guard(Box<i32>);
struct Guard(#[allow(dead_code)] Box<i32>);

impl Drop for Guard {
fn drop(&mut self) {
Expand Down
6 changes: 3 additions & 3 deletions tests/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ macro_rules! future {
static $drop_t: AtomicUsize = AtomicUsize::new(0);

let $name = {
struct Fut(Box<i32>);
struct Fut(#[allow(dead_code)] Box<i32>);

impl Future for Fut {
type Output = Out;
Expand All @@ -43,7 +43,7 @@ macro_rules! future {
}

#[derive(Default)]
struct Out(Box<i32>, bool);
struct Out(#[allow(dead_code)] Box<i32>, bool);

impl Drop for Out {
fn drop(&mut self) {
Expand Down Expand Up @@ -71,7 +71,7 @@ macro_rules! schedule {
static $sched: AtomicUsize = AtomicUsize::new(0);

let $name = {
struct Guard(Box<i32>);
struct Guard(#[allow(dead_code)] Box<i32>);

impl Drop for Guard {
fn drop(&mut self) {
Expand Down
4 changes: 2 additions & 2 deletions tests/waker_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ macro_rules! future {
static WAKER: AtomicWaker = AtomicWaker::new();

let ($name, $get_waker) = {
struct Fut(Cell<bool>, Box<i32>);
struct Fut(Cell<bool>, #[allow(dead_code)] Box<i32>);

impl Future for Fut {
type Output = ();
Expand Down Expand Up @@ -76,7 +76,7 @@ macro_rules! schedule {
let ($name, $chan) = {
let (s, r) = flume::unbounded();

struct Guard(Box<i32>);
struct Guard(#[allow(dead_code)] Box<i32>);

impl Drop for Guard {
fn drop(&mut self) {
Expand Down
4 changes: 2 additions & 2 deletions tests/waker_pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ macro_rules! future {
static WAKER: AtomicWaker = AtomicWaker::new();

let ($name, $get_waker) = {
struct Fut(Box<i32>);
struct Fut(#[allow(dead_code)] Box<i32>);

impl Future for Fut {
type Output = ();
Expand Down Expand Up @@ -67,7 +67,7 @@ macro_rules! schedule {
let ($name, $chan) = {
let (s, r) = flume::unbounded();

struct Guard(Box<i32>);
struct Guard(#[allow(dead_code)] Box<i32>);

impl Drop for Guard {
fn drop(&mut self) {
Expand Down
4 changes: 2 additions & 2 deletions tests/waker_ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ macro_rules! future {
static WAKER: AtomicWaker = AtomicWaker::new();

let ($name, $get_waker) = {
struct Fut(Cell<bool>, Box<i32>);
struct Fut(Cell<bool>, #[allow(dead_code)] Box<i32>);

impl Future for Fut {
type Output = Box<i32>;
Expand Down Expand Up @@ -73,7 +73,7 @@ macro_rules! schedule {
let ($name, $chan) = {
let (s, r) = flume::unbounded();

struct Guard(Box<i32>);
struct Guard(#[allow(dead_code)] Box<i32>);

impl Drop for Guard {
fn drop(&mut self) {
Expand Down

0 comments on commit b5f4978

Please sign in to comment.