@@ -5,15 +5,20 @@ use std::marker::PhantomData;
5
5
6
6
const LEN : usize = 4 ;
7
7
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
10
15
//~| NOTE: field in this struct
11
- //~| HELP: consider changing the field to be of unit type
16
+ //~| HELP: consider removing this field
12
17
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
15
20
//~| 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
17
22
18
23
struct GoodUnit ( ( ) ) ;
19
24
@@ -23,15 +28,19 @@ struct Void;
23
28
struct GoodVoid ( Void ) ;
24
29
25
30
fn 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 ;
29
39
30
- let m = MultipleUnused ( 42 , 3.14 , "def" . to_string ( ) , 4u8 ) ;
31
40
32
41
let gu = GoodUnit ( ( ) ) ;
33
42
let gp = GoodPhantom ( PhantomData ) ;
34
43
let gv = GoodVoid ( Void ) ;
35
44
36
- let _ = ( gu, gp, gv, m ) ;
45
+ let _ = ( gu, gp, gv) ;
37
46
}
0 commit comments