Skip to content

Commit

Permalink
Ignore warning on unused struct in test
Browse files Browse the repository at this point in the history
    warning: struct `OptSourceNoBacktrace` is never constructed
      --> tests/test_option.rs:10:16
       |
    10 |     pub struct OptSourceNoBacktrace {
       |                ^^^^^^^^^^^^^^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default

    warning: struct `OptSourceAlwaysBacktrace` is never constructed
      --> tests/test_option.rs:17:16
       |
    17 |     pub struct OptSourceAlwaysBacktrace {
       |                ^^^^^^^^^^^^^^^^^^^^^^^^

    warning: struct `NoSourceOptBacktrace` is never constructed
      --> tests/test_option.rs:25:16
       |
    25 |     pub struct NoSourceOptBacktrace {
       |                ^^^^^^^^^^^^^^^^^^^^

    warning: struct `AlwaysSourceOptBacktrace` is never constructed
      --> tests/test_option.rs:32:16
       |
    32 |     pub struct AlwaysSourceOptBacktrace {
       |                ^^^^^^^^^^^^^^^^^^^^^^^^

    warning: struct `OptSourceOptBacktrace` is never constructed
      --> tests/test_option.rs:40:16
       |
    40 |     pub struct OptSourceOptBacktrace {
       |                ^^^^^^^^^^^^^^^^^^^^^
  • Loading branch information
dtolnay committed Jun 8, 2024
1 parent f2824ae commit 4db08b1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ pub mod structs {

#[derive(Error, Debug)]
#[error("...")]
#[allow(dead_code)]
pub struct OptSourceNoBacktrace {
#[source]
source: Option<anyhow::Error>,
}

#[derive(Error, Debug)]
#[error("...")]
#[allow(dead_code)]
pub struct OptSourceAlwaysBacktrace {
#[source]
source: Option<anyhow::Error>,
Expand All @@ -22,13 +24,15 @@ pub mod structs {

#[derive(Error, Debug)]
#[error("...")]
#[allow(dead_code)]
pub struct NoSourceOptBacktrace {
#[backtrace]
backtrace: Option<Backtrace>,
}

#[derive(Error, Debug)]
#[error("...")]
#[allow(dead_code)]
pub struct AlwaysSourceOptBacktrace {
source: anyhow::Error,
#[backtrace]
Expand All @@ -37,6 +41,7 @@ pub mod structs {

#[derive(Error, Debug)]
#[error("...")]
#[allow(dead_code)]
pub struct OptSourceOptBacktrace {
#[source]
source: Option<anyhow::Error>,
Expand Down

0 comments on commit 4db08b1

Please sign in to comment.