Skip to content

Commit f1d0858

Browse files
committed
Add rustfix tests for mistyped_literal_suffix lint
This moves all `mistyped_literal_suffix` tests to their own file and enables rustfix tests for them. cc #3603, #2038 Based on #3887
1 parent 4e51c98 commit f1d0858

5 files changed

+126
-92
lines changed

tests/ui/literals.rs

-14
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,7 @@ fn main() {
3939

4040
let fail13 = 0x1_23456_78901_usize;
4141

42-
let fail14 = 2_32;
43-
let fail15 = 4_64;
44-
let fail16 = 7_8;
45-
let fail17 = 23_16;
46-
let ok18 = 23_128;
4742
let fail19 = 12_3456_21;
48-
let fail20 = 2__8;
49-
let fail21 = 4___16;
5043
let fail22 = 3__4___23;
5144
let fail23 = 3__16___23;
52-
53-
let fail24 = 12.34_64;
54-
let fail25 = 1E2_32;
55-
let fail26 = 43E7_64;
56-
let fail27 = 243E17_32;
57-
let fail28 = 241251235E723_64;
58-
let fail29 = 42279.911_32;
5945
}

tests/ui/literals.stderr

+4-78
Original file line numberDiff line numberDiff line change
@@ -94,99 +94,25 @@ LL | let fail13 = 0x1_23456_78901_usize;
9494
|
9595
= note: `-D clippy::large-digit-groups` implied by `-D warnings`
9696

97-
error: mistyped literal suffix
98-
--> $DIR/literals.rs:42:18
99-
|
100-
LL | let fail14 = 2_32;
101-
| ^^^^ help: did you mean to write: `2_i32`
102-
|
103-
= note: #[deny(clippy::mistyped_literal_suffixes)] on by default
104-
105-
error: mistyped literal suffix
106-
--> $DIR/literals.rs:43:18
107-
|
108-
LL | let fail15 = 4_64;
109-
| ^^^^ help: did you mean to write: `4_i64`
110-
111-
error: mistyped literal suffix
112-
--> $DIR/literals.rs:44:18
113-
|
114-
LL | let fail16 = 7_8;
115-
| ^^^ help: did you mean to write: `7_i8`
116-
117-
error: mistyped literal suffix
118-
--> $DIR/literals.rs:45:18
119-
|
120-
LL | let fail17 = 23_16;
121-
| ^^^^^ help: did you mean to write: `23_i16`
122-
12397
error: digits grouped inconsistently by underscores
124-
--> $DIR/literals.rs:47:18
98+
--> $DIR/literals.rs:42:18
12599
|
126100
LL | let fail19 = 12_3456_21;
127101
| ^^^^^^^^^^ help: consider: `12_345_621`
128102
|
129103
= note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings`
130104

131-
error: mistyped literal suffix
132-
--> $DIR/literals.rs:48:18
133-
|
134-
LL | let fail20 = 2__8;
135-
| ^^^^ help: did you mean to write: `2_i8`
136-
137-
error: mistyped literal suffix
138-
--> $DIR/literals.rs:49:18
139-
|
140-
LL | let fail21 = 4___16;
141-
| ^^^^^^ help: did you mean to write: `4_i16`
142-
143105
error: digits grouped inconsistently by underscores
144-
--> $DIR/literals.rs:50:18
106+
--> $DIR/literals.rs:43:18
145107
|
146108
LL | let fail22 = 3__4___23;
147109
| ^^^^^^^^^ help: consider: `3_423`
148110

149111
error: digits grouped inconsistently by underscores
150-
--> $DIR/literals.rs:51:18
112+
--> $DIR/literals.rs:44:18
151113
|
152114
LL | let fail23 = 3__16___23;
153115
| ^^^^^^^^^^ help: consider: `31_623`
154116

155-
error: mistyped literal suffix
156-
--> $DIR/literals.rs:53:18
157-
|
158-
LL | let fail24 = 12.34_64;
159-
| ^^^^^^^^ help: did you mean to write: `12.34_f64`
160-
161-
error: mistyped literal suffix
162-
--> $DIR/literals.rs:54:18
163-
|
164-
LL | let fail25 = 1E2_32;
165-
| ^^^^^^ help: did you mean to write: `1E2_f32`
166-
167-
error: mistyped literal suffix
168-
--> $DIR/literals.rs:55:18
169-
|
170-
LL | let fail26 = 43E7_64;
171-
| ^^^^^^^ help: did you mean to write: `43E7_f64`
172-
173-
error: mistyped literal suffix
174-
--> $DIR/literals.rs:56:18
175-
|
176-
LL | let fail27 = 243E17_32;
177-
| ^^^^^^^^^ help: did you mean to write: `243E17_f32`
178-
179-
error: mistyped literal suffix
180-
--> $DIR/literals.rs:57:18
181-
|
182-
LL | let fail28 = 241251235E723_64;
183-
| ^^^^^^^^^^^^^^^^ help: did you mean to write: `241_251_235E723_f64`
184-
185-
error: mistyped literal suffix
186-
--> $DIR/literals.rs:58:18
187-
|
188-
LL | let fail29 = 42279.911_32;
189-
| ^^^^^^^^^^^^ help: did you mean to write: `42_279.911_f32`
190-
191-
error: aborting due to 27 previous errors
117+
error: aborting due to 15 previous errors
192118

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// run-rustfix
2+
3+
#![allow(dead_code, unused_variables, clippy::excessive_precision)]
4+
5+
6+
fn main() {
7+
let fail14 = 2_i32;
8+
let fail15 = 4_i64;
9+
let fail16 = 7_i8; //
10+
let fail17 = 23_i16; //
11+
let ok18 = 23_128;
12+
13+
let fail20 = 2_i8; //
14+
let fail21 = 4_i16; //
15+
16+
let fail24 = 12.34_f64;
17+
let fail25 = 1E2_f32;
18+
let fail26 = 43E7_f64;
19+
let fail27 = 243E17_f32;
20+
#[allow(overflowing_literals)]
21+
let fail28 = 241_251_235E723_f64;
22+
let fail29 = 42_279.911_f32;
23+
}

tests/ui/mistyped_literal_suffix.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// run-rustfix
2+
3+
#![allow(dead_code, unused_variables, clippy::excessive_precision)]
4+
5+
6+
fn main() {
7+
let fail14 = 2_32;
8+
let fail15 = 4_64;
9+
let fail16 = 7_8; //
10+
let fail17 = 23_16; //
11+
let ok18 = 23_128;
12+
13+
let fail20 = 2__8; //
14+
let fail21 = 4___16; //
15+
16+
let fail24 = 12.34_64;
17+
let fail25 = 1E2_32;
18+
let fail26 = 43E7_64;
19+
let fail27 = 243E17_32;
20+
#[allow(overflowing_literals)]
21+
let fail28 = 241251235E723_64;
22+
let fail29 = 42279.911_32;
23+
}
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
error: mistyped literal suffix
2+
--> $DIR/mistyped_literal_suffix.rs:7:18
3+
|
4+
LL | let fail14 = 2_32;
5+
| ^^^^ help: did you mean to write: `2_i32`
6+
|
7+
= note: #[deny(clippy::mistyped_literal_suffixes)] on by default
8+
9+
error: mistyped literal suffix
10+
--> $DIR/mistyped_literal_suffix.rs:8:18
11+
|
12+
LL | let fail15 = 4_64;
13+
| ^^^^ help: did you mean to write: `4_i64`
14+
15+
error: mistyped literal suffix
16+
--> $DIR/mistyped_literal_suffix.rs:9:18
17+
|
18+
LL | let fail16 = 7_8; //
19+
| ^^^ help: did you mean to write: `7_i8`
20+
21+
error: mistyped literal suffix
22+
--> $DIR/mistyped_literal_suffix.rs:10:18
23+
|
24+
LL | let fail17 = 23_16; //
25+
| ^^^^^ help: did you mean to write: `23_i16`
26+
27+
error: mistyped literal suffix
28+
--> $DIR/mistyped_literal_suffix.rs:13:18
29+
|
30+
LL | let fail20 = 2__8; //
31+
| ^^^^ help: did you mean to write: `2_i8`
32+
33+
error: mistyped literal suffix
34+
--> $DIR/mistyped_literal_suffix.rs:14:18
35+
|
36+
LL | let fail21 = 4___16; //
37+
| ^^^^^^ help: did you mean to write: `4_i16`
38+
39+
error: mistyped literal suffix
40+
--> $DIR/mistyped_literal_suffix.rs:16:18
41+
|
42+
LL | let fail24 = 12.34_64;
43+
| ^^^^^^^^ help: did you mean to write: `12.34_f64`
44+
45+
error: mistyped literal suffix
46+
--> $DIR/mistyped_literal_suffix.rs:17:18
47+
|
48+
LL | let fail25 = 1E2_32;
49+
| ^^^^^^ help: did you mean to write: `1E2_f32`
50+
51+
error: mistyped literal suffix
52+
--> $DIR/mistyped_literal_suffix.rs:18:18
53+
|
54+
LL | let fail26 = 43E7_64;
55+
| ^^^^^^^ help: did you mean to write: `43E7_f64`
56+
57+
error: mistyped literal suffix
58+
--> $DIR/mistyped_literal_suffix.rs:19:18
59+
|
60+
LL | let fail27 = 243E17_32;
61+
| ^^^^^^^^^ help: did you mean to write: `243E17_f32`
62+
63+
error: mistyped literal suffix
64+
--> $DIR/mistyped_literal_suffix.rs:21:18
65+
|
66+
LL | let fail28 = 241251235E723_64;
67+
| ^^^^^^^^^^^^^^^^ help: did you mean to write: `241_251_235E723_f64`
68+
69+
error: mistyped literal suffix
70+
--> $DIR/mistyped_literal_suffix.rs:22:18
71+
|
72+
LL | let fail29 = 42279.911_32;
73+
| ^^^^^^^^^^^^ help: did you mean to write: `42_279.911_f32`
74+
75+
error: aborting due to 12 previous errors
76+

0 commit comments

Comments
 (0)