]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/dead-code/tuple-struct-field.rs
Auto merge of #101138 - Rejyr:diagnostic-migration-rustc-lint-pt2, r=davidtwco
[rust.git] / tests / ui / lint / dead-code / tuple-struct-field.rs
1 #![deny(unused_tuple_struct_fields)]
2 //~^ NOTE: the lint level is defined here
3
4 use std::marker::PhantomData;
5
6 const LEN: usize = 4;
7
8 struct SingleUnused(i32, [u8; LEN], String);
9 //~^ ERROR: field `1` is never read
10 //~| NOTE: field in this struct
11 //~| HELP: consider changing the field to be of unit type
12
13 struct MultipleUnused(i32, f32, String, u8);
14 //~^ ERROR: fields `0`, `1`, `2`, and `3` are never read
15 //~| NOTE: fields in this struct
16 //~| HELP: consider changing the fields to be of unit type
17
18 struct GoodUnit(());
19
20 struct GoodPhantom(PhantomData<i32>);
21
22 struct Void;
23 struct GoodVoid(Void);
24
25 fn main() {
26     let w = SingleUnused(42, [0, 1, 2, 3], "abc".to_string());
27     let _ = w.0;
28     let _ = w.2;
29
30     let m = MultipleUnused(42, 3.14, "def".to_string(), 4u8);
31
32     let gu = GoodUnit(());
33     let gp = GoodPhantom(PhantomData);
34     let gv = GoodVoid(Void);
35
36     let _ = (gu, gp, gv, m);
37 }