Work around dead_code warning in tests

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

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

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

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

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

    warning: fields `0` and `1` are never read
       --> tests/test_error.rs:367:14
        |
    367 |     struct S(usize, 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
        |
    367 |     struct S((), ());
        |              ~~  ~~

    warning: field `0` is never read
       --> tests/test_error.rs:378:14
        |
    378 |     struct S(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
        |
    378 |     struct S(());
        |              ~~

    warning: fields `0` and `1` are never read
       --> tests/test_error.rs:403:14
        |
    403 |     struct S(usize, 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
        |
    403 |     struct S((), ());
        |              ~~  ~~
This commit is contained in:
David Tolnay 2024-01-05 18:39:48 -08:00
parent 09ee25156f
commit 8b26413e33
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 30 additions and 39 deletions

View File

@ -15,13 +15,13 @@ rust-version = "1.64"
indexmap = "2"
itoa = "1.0"
ryu = "1.0"
serde = "1.0.194"
serde = "1.0.195"
unsafe-libyaml = "0.2.10"
[dev-dependencies]
anyhow = "1.0.79"
indoc = "2.0"
serde_derive = "1.0.194"
serde_derive = "1.0.195"
[lib]
doc-scrape-examples = false

View File

@ -49,18 +49,16 @@ fn test_incorrect_type() {
#[test]
fn test_incorrect_nested_type() {
#[derive(Deserialize, Debug)]
struct A {
#[allow(dead_code)]
b: Vec<B>,
pub struct A {
pub b: Vec<B>,
}
#[derive(Deserialize, Debug)]
enum B {
pub enum B {
C(C),
}
#[derive(Deserialize, Debug)]
struct C {
#[allow(dead_code)]
d: bool,
pub struct C {
pub d: bool,
}
let yaml = indoc! {"
b:
@ -80,11 +78,9 @@ fn test_empty() {
#[test]
fn test_missing_field() {
#[derive(Deserialize, Debug)]
struct Basic {
#[allow(dead_code)]
v: bool,
#[allow(dead_code)]
w: bool,
pub struct Basic {
pub v: bool,
pub w: bool,
}
let yaml = indoc! {"
---
@ -107,9 +103,8 @@ fn test_unknown_anchor() {
#[test]
fn test_ignored_unknown_anchor() {
#[derive(Deserialize, Debug)]
struct Wrapper {
#[allow(dead_code)]
c: (),
pub struct Wrapper {
pub c: (),
}
let yaml = indoc! {"
b: [*a]
@ -161,7 +156,7 @@ fn test_second_document_syntax_error() {
#[test]
fn test_missing_enum_tag() {
#[derive(Deserialize, Debug)]
enum E {
pub enum E {
V(usize),
}
let yaml = indoc! {r#"
@ -175,11 +170,11 @@ fn test_missing_enum_tag() {
#[test]
fn test_serialize_nested_enum() {
#[derive(Serialize, Debug)]
enum Outer {
pub enum Outer {
Inner(Inner),
}
#[derive(Serialize, Debug)]
enum Inner {
pub enum Inner {
Newtype(usize),
Tuple(usize, usize),
Struct { x: usize },
@ -213,11 +208,11 @@ fn test_serialize_nested_enum() {
#[test]
fn test_deserialize_nested_enum() {
#[derive(Deserialize, Debug)]
enum Outer {
pub enum Outer {
Inner(Inner),
}
#[derive(Deserialize, Debug)]
enum Inner {
pub enum Inner {
Variant(Vec<usize>),
}
@ -246,7 +241,7 @@ fn test_deserialize_nested_enum() {
#[test]
fn test_variant_not_a_seq() {
#[derive(Deserialize, Debug)]
enum E {
pub enum E {
V(usize),
}
let yaml = indoc! {"
@ -260,11 +255,10 @@ fn test_variant_not_a_seq() {
#[test]
fn test_struct_from_sequence() {
#[allow(dead_code)]
#[derive(Deserialize, Debug)]
struct Struct {
x: usize,
y: usize,
pub struct Struct {
pub x: usize,
pub y: usize,
}
let yaml = indoc! {"
[0, 0]
@ -336,9 +330,8 @@ fn test_long_tuple() {
#[test]
fn test_invalid_scalar_type() {
#[derive(Deserialize, Debug)]
struct S {
#[allow(dead_code)]
x: [i32; 1],
pub struct S {
pub x: [i32; 1],
}
let yaml = "x: ''\n";
@ -350,9 +343,8 @@ fn test_invalid_scalar_type() {
#[test]
fn test_infinite_recursion_objects() {
#[derive(Deserialize, Debug)]
struct S {
#[allow(dead_code)]
x: Option<Box<S>>,
pub struct S {
pub x: Option<Box<S>>,
}
let yaml = "&a {'x': *a}";
@ -364,7 +356,7 @@ fn test_infinite_recursion_objects() {
#[test]
fn test_infinite_recursion_arrays() {
#[derive(Deserialize, Debug)]
struct S(usize, Option<Box<S>>);
pub struct S(pub usize, pub Option<Box<S>>);
let yaml = "&a [0, *a]";
let expected = "recursion limit exceeded";
@ -375,7 +367,7 @@ fn test_infinite_recursion_arrays() {
#[test]
fn test_infinite_recursion_newtype() {
#[derive(Deserialize, Debug)]
struct S(Option<Box<S>>);
pub struct S(pub Option<Box<S>>);
let yaml = "&a [*a]";
let expected = "recursion limit exceeded";
@ -386,9 +378,8 @@ fn test_infinite_recursion_newtype() {
#[test]
fn test_finite_recursion_objects() {
#[derive(Deserialize, Debug)]
struct S {
#[allow(dead_code)]
x: Option<Box<S>>,
pub struct S {
pub x: Option<Box<S>>,
}
let yaml = "{'x':".repeat(1_000) + &"}".repeat(1_000);
@ -400,7 +391,7 @@ fn test_finite_recursion_objects() {
#[test]
fn test_finite_recursion_arrays() {
#[derive(Deserialize, Debug)]
struct S(usize, Option<Box<S>>);
pub struct S(pub usize, pub Option<Box<S>>);
let yaml = "[0, ".repeat(1_000) + &"]".repeat(1_000);
let expected = "recursion limit exceeded at line 1 column 513";