Skip to content

Commit c7d4445

Browse files
committed
Auto merge of #3888 - phansch:extract_mistyped_literal_suffix_tests_and_rustfix, r=flip1995
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
2 parents dc825a3 + 0452704 commit c7d4445

8 files changed

+160
-124
lines changed

tests/ui/literals.rs

-18
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,9 @@ fn main() {
3737
let ok16 = 0xFE_BAFE_ABAB_ABCD;
3838
let ok17 = 0x123_4567_8901_usize;
3939

40-
let fail9 = 0xabcdef;
41-
let fail10 = 0xBAFEBAFE;
42-
let fail11 = 0xabcdeff;
43-
let fail12 = 0xabcabcabcabcabcabc;
4440
let fail13 = 0x1_23456_78901_usize;
4541

46-
let fail14 = 2_32;
47-
let fail15 = 4_64;
48-
let fail16 = 7_8;
49-
let fail17 = 23_16;
50-
let ok18 = 23_128;
5142
let fail19 = 12_3456_21;
52-
let fail20 = 2__8;
53-
let fail21 = 4___16;
5443
let fail22 = 3__4___23;
5544
let fail23 = 3__16___23;
56-
57-
let fail24 = 12.34_64;
58-
let fail25 = 1E2_32;
59-
let fail26 = 43E7_64;
60-
let fail27 = 243E17_32;
61-
let fail28 = 241251235E723_64;
62-
let fail29 = 42279.911_32;
6345
}

tests/ui/literals.stderr

+5-105
Original file line numberDiff line numberDiff line change
@@ -86,133 +86,33 @@ help: if you mean to use an octal constant, use `0o`
8686
LL | let fail8 = 0o123;
8787
| ^^^^^
8888

89-
error: long literal lacking separators
90-
--> $DIR/literals.rs:40:17
91-
|
92-
LL | let fail9 = 0xabcdef;
93-
| ^^^^^^^^ help: consider: `0x00ab_cdef`
94-
|
95-
= note: `-D clippy::unreadable-literal` implied by `-D warnings`
96-
97-
error: long literal lacking separators
98-
--> $DIR/literals.rs:41:18
99-
|
100-
LL | let fail10 = 0xBAFEBAFE;
101-
| ^^^^^^^^^^ help: consider: `0xBAFE_BAFE`
102-
103-
error: long literal lacking separators
104-
--> $DIR/literals.rs:42:18
105-
|
106-
LL | let fail11 = 0xabcdeff;
107-
| ^^^^^^^^^ help: consider: `0x0abc_deff`
108-
109-
error: long literal lacking separators
110-
--> $DIR/literals.rs:43:18
111-
|
112-
LL | let fail12 = 0xabcabcabcabcabcabc;
113-
| ^^^^^^^^^^^^^^^^^^^^ help: consider: `0x00ab_cabc_abca_bcab_cabc`
114-
11589
error: digit groups should be smaller
116-
--> $DIR/literals.rs:44:18
90+
--> $DIR/literals.rs:40:18
11791
|
11892
LL | let fail13 = 0x1_23456_78901_usize;
11993
| ^^^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize`
12094
|
12195
= note: `-D clippy::large-digit-groups` implied by `-D warnings`
12296

123-
error: mistyped literal suffix
124-
--> $DIR/literals.rs:46:18
125-
|
126-
LL | let fail14 = 2_32;
127-
| ^^^^ help: did you mean to write: `2_i32`
128-
|
129-
= note: #[deny(clippy::mistyped_literal_suffixes)] on by default
130-
131-
error: mistyped literal suffix
132-
--> $DIR/literals.rs:47:18
133-
|
134-
LL | let fail15 = 4_64;
135-
| ^^^^ help: did you mean to write: `4_i64`
136-
137-
error: mistyped literal suffix
138-
--> $DIR/literals.rs:48:18
139-
|
140-
LL | let fail16 = 7_8;
141-
| ^^^ help: did you mean to write: `7_i8`
142-
143-
error: mistyped literal suffix
144-
--> $DIR/literals.rs:49:18
145-
|
146-
LL | let fail17 = 23_16;
147-
| ^^^^^ help: did you mean to write: `23_i16`
148-
14997
error: digits grouped inconsistently by underscores
150-
--> $DIR/literals.rs:51:18
98+
--> $DIR/literals.rs:42:18
15199
|
152100
LL | let fail19 = 12_3456_21;
153101
| ^^^^^^^^^^ help: consider: `12_345_621`
154102
|
155103
= note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings`
156104

157-
error: mistyped literal suffix
158-
--> $DIR/literals.rs:52:18
159-
|
160-
LL | let fail20 = 2__8;
161-
| ^^^^ help: did you mean to write: `2_i8`
162-
163-
error: mistyped literal suffix
164-
--> $DIR/literals.rs:53:18
165-
|
166-
LL | let fail21 = 4___16;
167-
| ^^^^^^ help: did you mean to write: `4_i16`
168-
169105
error: digits grouped inconsistently by underscores
170-
--> $DIR/literals.rs:54:18
106+
--> $DIR/literals.rs:43:18
171107
|
172108
LL | let fail22 = 3__4___23;
173109
| ^^^^^^^^^ help: consider: `3_423`
174110

175111
error: digits grouped inconsistently by underscores
176-
--> $DIR/literals.rs:55:18
112+
--> $DIR/literals.rs:44:18
177113
|
178114
LL | let fail23 = 3__16___23;
179115
| ^^^^^^^^^^ help: consider: `31_623`
180116

181-
error: mistyped literal suffix
182-
--> $DIR/literals.rs:57:18
183-
|
184-
LL | let fail24 = 12.34_64;
185-
| ^^^^^^^^ help: did you mean to write: `12.34_f64`
186-
187-
error: mistyped literal suffix
188-
--> $DIR/literals.rs:58:18
189-
|
190-
LL | let fail25 = 1E2_32;
191-
| ^^^^^^ help: did you mean to write: `1E2_f32`
192-
193-
error: mistyped literal suffix
194-
--> $DIR/literals.rs:59:18
195-
|
196-
LL | let fail26 = 43E7_64;
197-
| ^^^^^^^ help: did you mean to write: `43E7_f64`
198-
199-
error: mistyped literal suffix
200-
--> $DIR/literals.rs:60:18
201-
|
202-
LL | let fail27 = 243E17_32;
203-
| ^^^^^^^^^ help: did you mean to write: `243E17_f32`
204-
205-
error: mistyped literal suffix
206-
--> $DIR/literals.rs:61:18
207-
|
208-
LL | let fail28 = 241251235E723_64;
209-
| ^^^^^^^^^^^^^^^^ help: did you mean to write: `241_251_235E723_f64`
210-
211-
error: mistyped literal suffix
212-
--> $DIR/literals.rs:62:18
213-
|
214-
LL | let fail29 = 42279.911_32;
215-
| ^^^^^^^^^^^^ help: did you mean to write: `42_279.911_f32`
216-
217-
error: aborting due to 31 previous errors
117+
error: aborting due to 15 previous errors
218118

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

tests/ui/mistyped_literal_suffix.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// run-rustfix
2+
3+
#![allow(dead_code, unused_variables, clippy::excessive_precision)]
4+
5+
fn main() {
6+
let fail14 = 2_32;
7+
let fail15 = 4_64;
8+
let fail16 = 7_8; //
9+
let fail17 = 23_16; //
10+
let ok18 = 23_128;
11+
12+
let fail20 = 2__8; //
13+
let fail21 = 4___16; //
14+
15+
let fail24 = 12.34_64;
16+
let fail25 = 1E2_32;
17+
let fail26 = 43E7_64;
18+
let fail27 = 243E17_32;
19+
#[allow(overflowing_literals)]
20+
let fail28 = 241251235E723_64;
21+
let fail29 = 42279.911_32;
22+
}
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
error: mistyped literal suffix
2+
--> $DIR/mistyped_literal_suffix.rs:6: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:7: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:8: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:9: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:12: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:13: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:15: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:16: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:17: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:18: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:20: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:21: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+

tests/ui/unreadable_literal.fixed

+5
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ fn main() {
1717
let bad = (0b11_0110_i64, 0x0123_4567_8901_usize, 123_456_f32, 1.234_567_f32);
1818
let good_sci = 1.1234e1;
1919
let bad_sci = 1.123_456e1;
20+
21+
let fail9 = 0x00ab_cdef;
22+
let fail10: u32 = 0xBAFE_BAFE;
23+
let fail11 = 0x0abc_deff;
24+
let fail12: i128 = 0x00ab_cabc_abca_bcab_cabc;
2025
}

tests/ui/unreadable_literal.rs

+5
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ fn main() {
1717
let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
1818
let good_sci = 1.1234e1;
1919
let bad_sci = 1.123456e1;
20+
21+
let fail9 = 0xabcdef;
22+
let fail10: u32 = 0xBAFEBAFE;
23+
let fail11 = 0xabcdeff;
24+
let fail12: i128 = 0xabcabcabcabcabcabc;
2025
}

tests/ui/unreadable_literal.stderr

+25-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,29 @@ error: long literal lacking separators
3030
LL | let bad_sci = 1.123456e1;
3131
| ^^^^^^^^^^ help: consider: `1.123_456e1`
3232

33-
error: aborting due to 5 previous errors
33+
error: long literal lacking separators
34+
--> $DIR/unreadable_literal.rs:21:17
35+
|
36+
LL | let fail9 = 0xabcdef;
37+
| ^^^^^^^^ help: consider: `0x00ab_cdef`
38+
39+
error: long literal lacking separators
40+
--> $DIR/unreadable_literal.rs:22:23
41+
|
42+
LL | let fail10: u32 = 0xBAFEBAFE;
43+
| ^^^^^^^^^^ help: consider: `0xBAFE_BAFE`
44+
45+
error: long literal lacking separators
46+
--> $DIR/unreadable_literal.rs:23:18
47+
|
48+
LL | let fail11 = 0xabcdeff;
49+
| ^^^^^^^^^ help: consider: `0x0abc_deff`
50+
51+
error: long literal lacking separators
52+
--> $DIR/unreadable_literal.rs:24:24
53+
|
54+
LL | let fail12: i128 = 0xabcabcabcabcabcabc;
55+
| ^^^^^^^^^^^^^^^^^^^^ help: consider: `0x00ab_cabc_abca_bcab_cabc`
56+
57+
error: aborting due to 9 previous errors
3458

0 commit comments

Comments
 (0)