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

Commit 77236b0

Browse files
committed
Ignore dead code lint in tests
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((), ()); | ~~ ~~
1 parent f4c9ed9 commit 77236b0

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

tests/test_error.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@ fn test_incorrect_type() {
5050
fn test_incorrect_nested_type() {
5151
#[derive(Deserialize, Debug)]
5252
pub struct A {
53+
#[allow(dead_code)]
5354
pub b: Vec<B>,
5455
}
5556
#[derive(Deserialize, Debug)]
5657
pub enum B {
57-
C(C),
58+
C(#[allow(dead_code)] C),
5859
}
5960
#[derive(Deserialize, Debug)]
6061
pub struct C {
62+
#[allow(dead_code)]
6163
pub d: bool,
6264
}
6365
let yaml = indoc! {"
@@ -79,7 +81,9 @@ fn test_empty() {
7981
fn test_missing_field() {
8082
#[derive(Deserialize, Debug)]
8183
pub struct Basic {
84+
#[allow(dead_code)]
8285
pub v: bool,
86+
#[allow(dead_code)]
8387
pub w: bool,
8488
}
8589
let yaml = indoc! {"
@@ -104,6 +108,7 @@ fn test_unknown_anchor() {
104108
fn test_ignored_unknown_anchor() {
105109
#[derive(Deserialize, Debug)]
106110
pub struct Wrapper {
111+
#[allow(dead_code)]
107112
pub c: (),
108113
}
109114
let yaml = indoc! {"
@@ -157,7 +162,7 @@ fn test_second_document_syntax_error() {
157162
fn test_missing_enum_tag() {
158163
#[derive(Deserialize, Debug)]
159164
pub enum E {
160-
V(usize),
165+
V(#[allow(dead_code)] usize),
161166
}
162167
let yaml = indoc! {r#"
163168
"V": 16
@@ -209,11 +214,11 @@ fn test_serialize_nested_enum() {
209214
fn test_deserialize_nested_enum() {
210215
#[derive(Deserialize, Debug)]
211216
pub enum Outer {
212-
Inner(Inner),
217+
Inner(#[allow(dead_code)] Inner),
213218
}
214219
#[derive(Deserialize, Debug)]
215220
pub enum Inner {
216-
Variant(Vec<usize>),
221+
Variant(#[allow(dead_code)] Vec<usize>),
217222
}
218223

219224
let yaml = indoc! {"
@@ -242,7 +247,7 @@ fn test_deserialize_nested_enum() {
242247
fn test_variant_not_a_seq() {
243248
#[derive(Deserialize, Debug)]
244249
pub enum E {
245-
V(usize),
250+
V(#[allow(dead_code)] usize),
246251
}
247252
let yaml = indoc! {"
248253
---
@@ -257,7 +262,9 @@ fn test_variant_not_a_seq() {
257262
fn test_struct_from_sequence() {
258263
#[derive(Deserialize, Debug)]
259264
pub struct Struct {
265+
#[allow(dead_code)]
260266
pub x: usize,
267+
#[allow(dead_code)]
261268
pub y: usize,
262269
}
263270
let yaml = indoc! {"
@@ -331,6 +338,7 @@ fn test_long_tuple() {
331338
fn test_invalid_scalar_type() {
332339
#[derive(Deserialize, Debug)]
333340
pub struct S {
341+
#[allow(dead_code)]
334342
pub x: [i32; 1],
335343
}
336344

@@ -344,6 +352,7 @@ fn test_invalid_scalar_type() {
344352
fn test_infinite_recursion_objects() {
345353
#[derive(Deserialize, Debug)]
346354
pub struct S {
355+
#[allow(dead_code)]
347356
pub x: Option<Box<S>>,
348357
}
349358

@@ -356,7 +365,10 @@ fn test_infinite_recursion_objects() {
356365
#[test]
357366
fn test_infinite_recursion_arrays() {
358367
#[derive(Deserialize, Debug)]
359-
pub struct S(pub usize, pub Option<Box<S>>);
368+
pub struct S(
369+
#[allow(dead_code)] pub usize,
370+
#[allow(dead_code)] pub Option<Box<S>>,
371+
);
360372

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

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

@@ -391,7 +404,10 @@ fn test_finite_recursion_objects() {
391404
#[test]
392405
fn test_finite_recursion_arrays() {
393406
#[derive(Deserialize, Debug)]
394-
pub struct S(pub usize, pub Option<Box<S>>);
407+
pub struct S(
408+
#[allow(dead_code)] pub usize,
409+
#[allow(dead_code)] pub Option<Box<S>>,
410+
);
395411

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

0 commit comments

Comments
 (0)