Skip to content

Commit

Permalink
Ignore dead code lint in tests
Browse files Browse the repository at this point in the history
New in nightly-2024-03-24 from rust-lang/rust#119552.

    warning: fields `nested` and `string` are never read
      --> test_suite/tests/regression/issue2371.rs:10:9
       |
    8  |     Flatten {
       |     ------- fields in this variant
    9  |         #[serde(flatten)]
    10 |         nested: Nested,
       |         ^^^^^^
    11 |         string: &'static str,
       |         ^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default

    warning: fields `nested` and `string` are never read
      --> test_suite/tests/regression/issue2371.rs:20:9
       |
    18 |     Flatten {
       |     ------- fields in this variant
    19 |         #[serde(flatten)]
    20 |         nested: Nested,
       |         ^^^^^^
    21 |         string: &'static str,
       |         ^^^^^^

    warning: fields `nested` and `string` are never read
      --> test_suite/tests/regression/issue2371.rs:30:9
       |
    28 |     Flatten {
       |     ------- fields in this variant
    29 |         #[serde(flatten)]
    30 |         nested: Nested,
       |         ^^^^^^
    31 |         string: &'static str,
       |         ^^^^^^

    warning: fields `nested` and `string` are never read
      --> test_suite/tests/regression/issue2371.rs:40:9
       |
    38 |     Flatten {
       |     ------- fields in this variant
    39 |         #[serde(flatten)]
    40 |         nested: Nested,
       |         ^^^^^^
    41 |         string: &'static str,
       |         ^^^^^^

    warning: field `0` is never read
       --> test_suite/tests/test_gen.rs:690:33
        |
    690 |         Single(#[serde(borrow)] RelObject<'a>),
        |         ------                  ^^^^^^^^^^^^^
        |         |
        |         field in this variant
        |
        = 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
        |
    690 |         Single(#[serde(borrow)] ()),
        |                                 ~~

    warning: field `0` is never read
       --> test_suite/tests/test_gen.rs:691:31
        |
    691 |         Many(#[serde(borrow)] Vec<RelObject<'a>>),
        |         ----                  ^^^^^^^^^^^^^^^^^^
        |         |
        |         field in this variant
        |
    help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
        |
    691 |         Many(#[serde(borrow)] ()),
        |                               ~~
  • Loading branch information
dtolnay committed Mar 24, 2024
1 parent 9f8c579 commit 364cd8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions test_suite/tests/regression/issue2371.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ pub struct Nested;
pub enum ExternallyTagged {
Flatten {
#[serde(flatten)]
#[allow(dead_code)]
nested: Nested,
#[allow(dead_code)]
string: &'static str,
},
}
Expand All @@ -17,7 +19,9 @@ pub enum ExternallyTagged {
pub enum InternallyTagged {
Flatten {
#[serde(flatten)]
#[allow(dead_code)]
nested: Nested,
#[allow(dead_code)]
string: &'static str,
},
}
Expand All @@ -27,7 +31,9 @@ pub enum InternallyTagged {
pub enum AdjacentlyTagged {
Flatten {
#[serde(flatten)]
#[allow(dead_code)]
nested: Nested,
#[allow(dead_code)]
string: &'static str,
},
}
Expand All @@ -37,7 +43,9 @@ pub enum AdjacentlyTagged {
pub enum UntaggedWorkaround {
Flatten {
#[serde(flatten)]
#[allow(dead_code)]
nested: Nested,
#[allow(dead_code)]
string: &'static str,
},
}
12 changes: 10 additions & 2 deletions test_suite/tests/test_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,16 @@ fn test_gen() {
#[derive(Deserialize)]
#[serde(untagged)]
pub enum UntaggedWithBorrow<'a> {
Single(#[serde(borrow)] RelObject<'a>),
Many(#[serde(borrow)] Vec<RelObject<'a>>),
Single(
#[serde(borrow)]
#[allow(dead_code)]
RelObject<'a>,
),
Many(
#[serde(borrow)]
#[allow(dead_code)]
Vec<RelObject<'a>>,
),
}

#[derive(Deserialize)]
Expand Down

0 comments on commit 364cd8d

Please sign in to comment.