@@ -5,15 +5,20 @@ use std::marker::PhantomData;
55
66const LEN : usize = 4 ;
77
8- struct SingleUnused ( i32 , [ u8 ; LEN ] , String ) ;
9- //~^ ERROR: field `1` is never read
8+ struct UnusedAtTheEnd ( i32 , f32 , [ u8 ; LEN ] , String , u8 ) ;
9+ //~^ ERROR:fields `1`, `2`, `3`, and `4` are never read
10+ //~| NOTE: fields in this struct
11+ //~| HELP: consider removing these fields
12+
13+ struct UnusedJustOneField ( i32 ) ;
14+ //~^ ERROR: field `0` is never read
1015//~| NOTE: field in this struct
11- //~| HELP: consider changing the field to be of unit type
16+ //~| HELP: consider removing this field
1217
13- struct MultipleUnused ( i32 , f32 , String , u8 ) ;
14- //~^ ERROR: fields `0`, ` 1`, `2`, and `3 ` are never read
18+ struct UnusedInTheMiddle ( i32 , f32 , String , u8 , u32 ) ;
19+ //~^ ERROR: fields `1`, `2`, and `4 ` are never read
1520//~| NOTE: fields in this struct
16- //~| HELP: consider changing the fields to be of unit type
21+ //~| HELP: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields
1722
1823struct GoodUnit ( ( ) ) ;
1924
@@ -23,15 +28,19 @@ struct Void;
2328struct GoodVoid ( Void ) ;
2429
2530fn main ( ) {
26- let w = SingleUnused ( 42 , [ 0 , 1 , 2 , 3 ] , "abc" . to_string ( ) ) ;
27- let _ = w. 0 ;
28- let _ = w. 2 ;
31+ let u1 = UnusedAtTheEnd ( 42 , 3.14 , [ 0 , 1 , 2 , 3 ] , "def" . to_string ( ) , 4u8 ) ;
32+ let _ = u1. 0 ;
33+
34+ let _ = UnusedJustOneField ( 42 ) ;
35+
36+ let u2 = UnusedInTheMiddle ( 42 , 3.14 , "def" . to_string ( ) , 4u8 , 5 ) ;
37+ let _ = u2. 0 ;
38+ let _ = u2. 3 ;
2939
30- let m = MultipleUnused ( 42 , 3.14 , "def" . to_string ( ) , 4u8 ) ;
3140
3241 let gu = GoodUnit ( ( ) ) ;
3342 let gp = GoodPhantom ( PhantomData ) ;
3443 let gv = GoodVoid ( Void ) ;
3544
36- let _ = ( gu, gp, gv, m ) ;
45+ let _ = ( gu, gp, gv) ;
3746}
0 commit comments