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

Commit 8b26413

Browse files
committed
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((), ()); | ~~ ~~
1 parent 09ee251 commit 8b26413

File tree

2 files changed

+30
-39
lines changed

2 files changed

+30
-39
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ rust-version = "1.64"
1515
indexmap = "2"
1616
itoa = "1.0"
1717
ryu = "1.0"
18-
serde = "1.0.194"
18+
serde = "1.0.195"
1919
unsafe-libyaml = "0.2.10"
2020

2121
[dev-dependencies]
2222
anyhow = "1.0.79"
2323
indoc = "2.0"
24-
serde_derive = "1.0.194"
24+
serde_derive = "1.0.195"
2525

2626
[lib]
2727
doc-scrape-examples = false

tests/test_error.rs

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,16 @@ fn test_incorrect_type() {
4949
#[test]
5050
fn test_incorrect_nested_type() {
5151
#[derive(Deserialize, Debug)]
52-
struct A {
53-
#[allow(dead_code)]
54-
b: Vec<B>,
52+
pub struct A {
53+
pub b: Vec<B>,
5554
}
5655
#[derive(Deserialize, Debug)]
57-
enum B {
56+
pub enum B {
5857
C(C),
5958
}
6059
#[derive(Deserialize, Debug)]
61-
struct C {
62-
#[allow(dead_code)]
63-
d: bool,
60+
pub struct C {
61+
pub d: bool,
6462
}
6563
let yaml = indoc! {"
6664
b:
@@ -80,11 +78,9 @@ fn test_empty() {
8078
#[test]
8179
fn test_missing_field() {
8280
#[derive(Deserialize, Debug)]
83-
struct Basic {
84-
#[allow(dead_code)]
85-
v: bool,
86-
#[allow(dead_code)]
87-
w: bool,
81+
pub struct Basic {
82+
pub v: bool,
83+
pub w: bool,
8884
}
8985
let yaml = indoc! {"
9086
---
@@ -107,9 +103,8 @@ fn test_unknown_anchor() {
107103
#[test]
108104
fn test_ignored_unknown_anchor() {
109105
#[derive(Deserialize, Debug)]
110-
struct Wrapper {
111-
#[allow(dead_code)]
112-
c: (),
106+
pub struct Wrapper {
107+
pub c: (),
113108
}
114109
let yaml = indoc! {"
115110
b: [*a]
@@ -161,7 +156,7 @@ fn test_second_document_syntax_error() {
161156
#[test]
162157
fn test_missing_enum_tag() {
163158
#[derive(Deserialize, Debug)]
164-
enum E {
159+
pub enum E {
165160
V(usize),
166161
}
167162
let yaml = indoc! {r#"
@@ -175,11 +170,11 @@ fn test_missing_enum_tag() {
175170
#[test]
176171
fn test_serialize_nested_enum() {
177172
#[derive(Serialize, Debug)]
178-
enum Outer {
173+
pub enum Outer {
179174
Inner(Inner),
180175
}
181176
#[derive(Serialize, Debug)]
182-
enum Inner {
177+
pub enum Inner {
183178
Newtype(usize),
184179
Tuple(usize, usize),
185180
Struct { x: usize },
@@ -213,11 +208,11 @@ fn test_serialize_nested_enum() {
213208
#[test]
214209
fn test_deserialize_nested_enum() {
215210
#[derive(Deserialize, Debug)]
216-
enum Outer {
211+
pub enum Outer {
217212
Inner(Inner),
218213
}
219214
#[derive(Deserialize, Debug)]
220-
enum Inner {
215+
pub enum Inner {
221216
Variant(Vec<usize>),
222217
}
223218

@@ -246,7 +241,7 @@ fn test_deserialize_nested_enum() {
246241
#[test]
247242
fn test_variant_not_a_seq() {
248243
#[derive(Deserialize, Debug)]
249-
enum E {
244+
pub enum E {
250245
V(usize),
251246
}
252247
let yaml = indoc! {"
@@ -260,11 +255,10 @@ fn test_variant_not_a_seq() {
260255

261256
#[test]
262257
fn test_struct_from_sequence() {
263-
#[allow(dead_code)]
264258
#[derive(Deserialize, Debug)]
265-
struct Struct {
266-
x: usize,
267-
y: usize,
259+
pub struct Struct {
260+
pub x: usize,
261+
pub y: usize,
268262
}
269263
let yaml = indoc! {"
270264
[0, 0]
@@ -336,9 +330,8 @@ fn test_long_tuple() {
336330
#[test]
337331
fn test_invalid_scalar_type() {
338332
#[derive(Deserialize, Debug)]
339-
struct S {
340-
#[allow(dead_code)]
341-
x: [i32; 1],
333+
pub struct S {
334+
pub x: [i32; 1],
342335
}
343336

344337
let yaml = "x: ''\n";
@@ -350,9 +343,8 @@ fn test_invalid_scalar_type() {
350343
#[test]
351344
fn test_infinite_recursion_objects() {
352345
#[derive(Deserialize, Debug)]
353-
struct S {
354-
#[allow(dead_code)]
355-
x: Option<Box<S>>,
346+
pub struct S {
347+
pub x: Option<Box<S>>,
356348
}
357349

358350
let yaml = "&a {'x': *a}";
@@ -364,7 +356,7 @@ fn test_infinite_recursion_objects() {
364356
#[test]
365357
fn test_infinite_recursion_arrays() {
366358
#[derive(Deserialize, Debug)]
367-
struct S(usize, Option<Box<S>>);
359+
pub struct S(pub usize, pub Option<Box<S>>);
368360

369361
let yaml = "&a [0, *a]";
370362
let expected = "recursion limit exceeded";
@@ -375,7 +367,7 @@ fn test_infinite_recursion_arrays() {
375367
#[test]
376368
fn test_infinite_recursion_newtype() {
377369
#[derive(Deserialize, Debug)]
378-
struct S(Option<Box<S>>);
370+
pub struct S(pub Option<Box<S>>);
379371

380372
let yaml = "&a [*a]";
381373
let expected = "recursion limit exceeded";
@@ -386,9 +378,8 @@ fn test_infinite_recursion_newtype() {
386378
#[test]
387379
fn test_finite_recursion_objects() {
388380
#[derive(Deserialize, Debug)]
389-
struct S {
390-
#[allow(dead_code)]
391-
x: Option<Box<S>>,
381+
pub struct S {
382+
pub x: Option<Box<S>>,
392383
}
393384

394385
let yaml = "{'x':".repeat(1_000) + &"}".repeat(1_000);
@@ -400,7 +391,7 @@ fn test_finite_recursion_objects() {
400391
#[test]
401392
fn test_finite_recursion_arrays() {
402393
#[derive(Deserialize, Debug)]
403-
struct S(usize, Option<Box<S>>);
394+
pub struct S(pub usize, pub Option<Box<S>>);
404395

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

0 commit comments

Comments
 (0)