Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

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: field `b` is never read
      --> tests/test_error.rs:53:13
       |
    52 |     pub struct A {
       |                - field in this struct
    53 |         pub b: Vec<B>,
       |             ^
       |
       = note: `A` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
       = note: `#[warn(dead_code)]` on by default

    warning: field `0` is never read
      --> tests/test_error.rs:57:11
       |
    57 |         C(C),
       |         - ^
       |         |
       |         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
       |
    57 |         C(()),
       |           ~~

    warning: field `d` is never read
      --> tests/test_error.rs:61:13
       |
    60 |     pub struct C {
       |                - field in this struct
    61 |         pub d: bool,
       |             ^
       |
       = note: `C` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis

    warning: fields `v` and `w` are never read
      --> tests/test_error.rs:82:13
       |
    81 |     pub struct Basic {
       |                ----- fields in this struct
    82 |         pub v: bool,
       |             ^
    83 |         pub w: bool,
       |             ^
       |
       = note: `Basic` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis

    warning: field `c` is never read
       --> tests/test_error.rs:107:13
        |
    106 |     pub struct Wrapper {
        |                ------- field in this struct
    107 |         pub c: (),
        |             ^
        |
        = note: `Wrapper` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis

    warning: field `0` is never read
       --> tests/test_error.rs:160:11
        |
    160 |         V(usize),
        |         - ^^^^^
        |         |
        |         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
        |
    160 |         V(()),
        |           ~~

    warning: field `0` is never read
       --> tests/test_error.rs:212:15
        |
    212 |         Inner(Inner),
        |         ----- ^^^^^
        |         |
        |         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
        |
    212 |         Inner(()),
        |               ~~

    warning: field `0` is never read
       --> tests/test_error.rs:216:17
        |
    216 |         Variant(Vec<usize>),
        |         ------- ^^^^^^^^^^
        |         |
        |         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
        |
    216 |         Variant(()),
        |                 ~~

    warning: field `0` is never read
       --> tests/test_error.rs:245:11
        |
    245 |         V(usize),
        |         - ^^^^^
        |         |
        |         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
        |
    245 |         V(()),
        |           ~~

    warning: fields `x` and `y` are never read
       --> tests/test_error.rs:260:13
        |
    259 |     pub struct Struct {
        |                ------ fields in this struct
    260 |         pub x: usize,
        |             ^
    261 |         pub y: usize,
        |             ^
        |
        = note: `Struct` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis

    warning: field `x` is never read
       --> tests/test_error.rs:334:13
        |
    333 |     pub struct S {
        |                - field in this struct
    334 |         pub x: [i32; 1],
        |             ^
        |
        = note: `S` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis

    warning: field `x` is never read
       --> tests/test_error.rs:347:13
        |
    346 |     pub struct S {
        |                - field in this struct
    347 |         pub x: Option<Box<S>>,
        |             ^
        |
        = note: `S` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis

    warning: fields `0` and `1` are never read
       --> tests/test_error.rs:359:18
        |
    359 |     pub struct S(pub usize, pub Option<Box<S>>);
        |                - ^^^^^^^^^  ^^^^^^^^^^^^^^^^^^
        |                |
        |                fields in this struct
        |
        = note: `S` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
    help: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields
        |
    359 |     pub struct S((), ());
        |                  ~~  ~~

    warning: field `0` is never read
       --> tests/test_error.rs:370:18
        |
    370 |     pub struct S(pub Option<Box<S>>);
        |                - ^^^^^^^^^^^^^^^^^^
        |                |
        |                field in this struct
        |
        = note: `S` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
    help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
        |
    370 |     pub struct S(());
        |                  ~~

    warning: field `x` is never read
       --> tests/test_error.rs:382:13
        |
    381 |     pub struct S {
        |                - field in this struct
    382 |         pub x: Option<Box<S>>,
        |             ^
        |
        = note: `S` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis

    warning: fields `0` and `1` are never read
       --> tests/test_error.rs:394:18
        |
    394 |     pub struct S(pub usize, pub Option<Box<S>>);
        |                - ^^^^^^^^^  ^^^^^^^^^^^^^^^^^^
        |                |
        |                fields in this struct
        |
        = note: `S` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
    help: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields
        |
    394 |     pub struct S((), ());
        |                  ~~  ~~
  • Loading branch information
dtolnay committed Mar 24, 2024
1 parent f4c9ed9 commit 77236b0
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions tests/test_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ fn test_incorrect_type() {
fn test_incorrect_nested_type() {
#[derive(Deserialize, Debug)]
pub struct A {
#[allow(dead_code)]
pub b: Vec<B>,
}
#[derive(Deserialize, Debug)]
pub enum B {
C(C),
C(#[allow(dead_code)] C),
}
#[derive(Deserialize, Debug)]
pub struct C {
#[allow(dead_code)]
pub d: bool,
}
let yaml = indoc! {"
Expand All @@ -79,7 +81,9 @@ fn test_empty() {
fn test_missing_field() {
#[derive(Deserialize, Debug)]
pub struct Basic {
#[allow(dead_code)]
pub v: bool,
#[allow(dead_code)]
pub w: bool,
}
let yaml = indoc! {"
Expand All @@ -104,6 +108,7 @@ fn test_unknown_anchor() {
fn test_ignored_unknown_anchor() {
#[derive(Deserialize, Debug)]
pub struct Wrapper {
#[allow(dead_code)]
pub c: (),
}
let yaml = indoc! {"
Expand Down Expand Up @@ -157,7 +162,7 @@ fn test_second_document_syntax_error() {
fn test_missing_enum_tag() {
#[derive(Deserialize, Debug)]
pub enum E {
V(usize),
V(#[allow(dead_code)] usize),
}
let yaml = indoc! {r#"
"V": 16
Expand Down Expand Up @@ -209,11 +214,11 @@ fn test_serialize_nested_enum() {
fn test_deserialize_nested_enum() {
#[derive(Deserialize, Debug)]
pub enum Outer {
Inner(Inner),
Inner(#[allow(dead_code)] Inner),
}
#[derive(Deserialize, Debug)]
pub enum Inner {
Variant(Vec<usize>),
Variant(#[allow(dead_code)] Vec<usize>),
}

let yaml = indoc! {"
Expand Down Expand Up @@ -242,7 +247,7 @@ fn test_deserialize_nested_enum() {
fn test_variant_not_a_seq() {
#[derive(Deserialize, Debug)]
pub enum E {
V(usize),
V(#[allow(dead_code)] usize),
}
let yaml = indoc! {"
---
Expand All @@ -257,7 +262,9 @@ fn test_variant_not_a_seq() {
fn test_struct_from_sequence() {
#[derive(Deserialize, Debug)]
pub struct Struct {
#[allow(dead_code)]
pub x: usize,
#[allow(dead_code)]
pub y: usize,
}
let yaml = indoc! {"
Expand Down Expand Up @@ -331,6 +338,7 @@ fn test_long_tuple() {
fn test_invalid_scalar_type() {
#[derive(Deserialize, Debug)]
pub struct S {
#[allow(dead_code)]
pub x: [i32; 1],
}

Expand All @@ -344,6 +352,7 @@ fn test_invalid_scalar_type() {
fn test_infinite_recursion_objects() {
#[derive(Deserialize, Debug)]
pub struct S {
#[allow(dead_code)]
pub x: Option<Box<S>>,
}

Expand All @@ -356,7 +365,10 @@ fn test_infinite_recursion_objects() {
#[test]
fn test_infinite_recursion_arrays() {
#[derive(Deserialize, Debug)]
pub struct S(pub usize, pub Option<Box<S>>);
pub struct S(
#[allow(dead_code)] pub usize,
#[allow(dead_code)] pub Option<Box<S>>,
);

let yaml = "&a [0, *a]";
let expected = "recursion limit exceeded";
Expand All @@ -367,7 +379,7 @@ fn test_infinite_recursion_arrays() {
#[test]
fn test_infinite_recursion_newtype() {
#[derive(Deserialize, Debug)]
pub struct S(pub Option<Box<S>>);
pub struct S(#[allow(dead_code)] pub Option<Box<S>>);

let yaml = "&a [*a]";
let expected = "recursion limit exceeded";
Expand All @@ -379,6 +391,7 @@ fn test_infinite_recursion_newtype() {
fn test_finite_recursion_objects() {
#[derive(Deserialize, Debug)]
pub struct S {
#[allow(dead_code)]
pub x: Option<Box<S>>,
}

Expand All @@ -391,7 +404,10 @@ fn test_finite_recursion_objects() {
#[test]
fn test_finite_recursion_arrays() {
#[derive(Deserialize, Debug)]
pub struct S(pub usize, pub Option<Box<S>>);
pub struct S(
#[allow(dead_code)] pub usize,
#[allow(dead_code)] pub Option<Box<S>>,
);

let yaml = "[0, ".repeat(1_000) + &"]".repeat(1_000);
let expected = "recursion limit exceeded at line 1 column 513";
Expand Down

0 comments on commit 77236b0

Please sign in to comment.