Skip to content

Commit 7170eb4

Browse files
committed
Split tests into two files
1 parent 388aa5d commit 7170eb4

6 files changed

+117
-58
lines changed

tests/compile-test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ const RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS: &[&str] = &[
242242
"eprint_with_newline.rs",
243243
"explicit_counter_loop.rs",
244244
"iter_skip_next_unfixable.rs",
245-
"legacy_numeric_constants.rs",
246245
"let_and_return.rs",
247246
"literals.rs",
248247
"map_flatten.rs",
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//@run-rustfix
2+
//@aux-build:proc_macros.rs:proc-macro
3+
#![allow(clippy::no_effect, deprecated, unused)]
4+
#![warn(clippy::legacy_numeric_constants)]
5+
6+
#[macro_use]
7+
extern crate proc_macros;
8+
9+
use std::u128 as _;
10+
pub mod a {
11+
pub use std::u128;
12+
}
13+
14+
fn main() {
15+
f32::EPSILON;
16+
u8::MIN;
17+
usize::MIN;
18+
u32::MAX;
19+
u32::MAX;
20+
use std::u32::MAX;
21+
u32::MAX;
22+
u32::MAX;
23+
u8::MAX;
24+
u8::MIN;
25+
::std::primitive::u8::MIN;
26+
::std::u8::MIN;
27+
::std::primitive::u8::MIN;
28+
std::primitive::u32::MAX;
29+
u128::MAX;
30+
// Don't lint
31+
use std::f64;
32+
f32::EPSILON;
33+
u8::MIN;
34+
std::f32::consts::E;
35+
f64::consts::E;
36+
external! {
37+
::std::primitive::u8::MIN;
38+
::std::u8::MIN;
39+
::std::primitive::u8::min_value();
40+
}
41+
}
42+
43+
#[clippy::msrv = "1.42.0"]
44+
fn msrv_too_low() {
45+
// FIXME: Why does this lint??
46+
u32::MAX;
47+
}
48+
49+
#[clippy::msrv = "1.43.0"]
50+
fn msrv_juust_right() {
51+
u32::MAX;
52+
}

tests/ui/legacy_numeric_constants.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//@aux-build:proc_macros.rs
1+
//@run-rustfix
2+
//@aux-build:proc_macros.rs:proc-macro
23
#![allow(clippy::no_effect, deprecated, unused)]
34
#![warn(clippy::legacy_numeric_constants)]
45

@@ -16,26 +17,21 @@ fn main() {
1617
std::usize::MIN;
1718
std::u32::MAX;
1819
core::u32::MAX;
19-
use std::u32;
2020
use std::u32::MAX;
2121
MAX;
22-
u32::MAX;
2322
u32::max_value();
2423
u8::max_value();
2524
u8::min_value();
2625
::std::primitive::u8::MIN;
2726
::std::u8::MIN;
2827
::std::primitive::u8::min_value();
2928
std::primitive::u32::max_value();
30-
use std::f64;
31-
f64::MAX;
3229
self::a::u128::MAX;
33-
u128::MAX;
3430
// Don't lint
31+
use std::f64;
3532
f32::EPSILON;
3633
u8::MIN;
3734
std::f32::consts::E;
38-
use std::f32;
3935
f64::consts::E;
4036
external! {
4137
::std::primitive::u8::MIN;
Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error: usage of a legacy numeric constant
2-
--> $DIR/legacy_numeric_constants.rs:14:5
2+
--> $DIR/legacy_numeric_constants.rs:15:5
33
|
44
LL | std::f32::EPSILON;
55
| ^^^^^^^^^^^^^^^^^ help: use the associated constant instead: `f32::EPSILON`
66
|
77
= note: `-D clippy::legacy-numeric-constants` implied by `-D warnings`
88

99
error: usage of a legacy numeric constant
10-
--> $DIR/legacy_numeric_constants.rs:15:5
10+
--> $DIR/legacy_numeric_constants.rs:16:5
1111
|
1212
LL | std::u8::MIN;
1313
| ^^^^^^^^^^^^ help: use the associated constant instead: `u8::MIN`
1414

1515
error: usage of a legacy numeric constant
16-
--> $DIR/legacy_numeric_constants.rs:16:5
16+
--> $DIR/legacy_numeric_constants.rs:17:5
1717
|
1818
LL | std::usize::MIN;
1919
| ^^^^^^^^^^^^^^^ help: use the associated constant instead: `usize::MIN`
2020

2121
error: usage of a legacy numeric constant
22-
--> $DIR/legacy_numeric_constants.rs:17:5
22+
--> $DIR/legacy_numeric_constants.rs:18:5
2323
|
2424
LL | std::u32::MAX;
2525
| ^^^^^^^^^^^^^ help: use the associated constant instead: `u32::MAX`
2626

2727
error: usage of a legacy numeric constant
28-
--> $DIR/legacy_numeric_constants.rs:18:5
28+
--> $DIR/legacy_numeric_constants.rs:19:5
2929
|
3030
LL | core::u32::MAX;
3131
| ^^^^^^^^^^^^^^ help: use the associated constant instead: `u32::MAX`
@@ -36,89 +36,53 @@ error: usage of a legacy numeric constant
3636
LL | MAX;
3737
| ^^^ help: use the associated constant instead: `u32::MAX`
3838

39-
error: usage of a legacy numeric constant
40-
--> $DIR/legacy_numeric_constants.rs:22:5
41-
|
42-
LL | u32::MAX;
43-
| ^^^^^^^^ help: use the associated constant instead: `u32::MAX`
44-
|
45-
note: you may need to remove one of the following `use` statements
46-
--> $DIR/legacy_numeric_constants.rs:20:5
47-
|
48-
LL | use std::u32::MAX;
49-
| ^^^^^^^^^^^^^^^^^^
50-
5139
error: usage of a legacy numeric method
52-
--> $DIR/legacy_numeric_constants.rs:23:10
40+
--> $DIR/legacy_numeric_constants.rs:22:10
5341
|
5442
LL | u32::max_value();
5543
| ^^^^^^^^^^^ help: use the associated constant instead: `MAX`
5644

5745
error: usage of a legacy numeric method
58-
--> $DIR/legacy_numeric_constants.rs:24:9
46+
--> $DIR/legacy_numeric_constants.rs:23:9
5947
|
6048
LL | u8::max_value();
6149
| ^^^^^^^^^^^ help: use the associated constant instead: `MAX`
6250

6351
error: usage of a legacy numeric method
64-
--> $DIR/legacy_numeric_constants.rs:25:9
52+
--> $DIR/legacy_numeric_constants.rs:24:9
6553
|
6654
LL | u8::min_value();
6755
| ^^^^^^^^^^^ help: use the associated constant instead: `MIN`
6856

6957
error: usage of a legacy numeric method
70-
--> $DIR/legacy_numeric_constants.rs:28:27
58+
--> $DIR/legacy_numeric_constants.rs:27:27
7159
|
7260
LL | ::std::primitive::u8::min_value();
7361
| ^^^^^^^^^^^ help: use the associated constant instead: `MIN`
7462

7563
error: usage of a legacy numeric method
76-
--> $DIR/legacy_numeric_constants.rs:29:26
64+
--> $DIR/legacy_numeric_constants.rs:28:26
7765
|
7866
LL | std::primitive::u32::max_value();
7967
| ^^^^^^^^^^^ help: use the associated constant instead: `MAX`
8068

8169
error: usage of a legacy numeric constant
82-
--> $DIR/legacy_numeric_constants.rs:31:5
83-
|
84-
LL | f64::MAX;
85-
| ^^^^^^^^ help: use the associated constant instead: `f64::MAX`
86-
|
87-
note: you may need to remove one of the following `use` statements
88-
--> $DIR/legacy_numeric_constants.rs:30:5
89-
|
90-
LL | use std::f64;
91-
| ^^^^^^^^^^^^^
92-
93-
error: usage of a legacy numeric constant
94-
--> $DIR/legacy_numeric_constants.rs:32:5
70+
--> $DIR/legacy_numeric_constants.rs:29:5
9571
|
9672
LL | self::a::u128::MAX;
9773
| ^^^^^^^^^^^^^^^^^^ help: use the associated constant instead: `u128::MAX`
9874

9975
error: usage of a legacy numeric constant
100-
--> $DIR/legacy_numeric_constants.rs:35:5
101-
|
102-
LL | f32::EPSILON;
103-
| ^^^^^^^^^^^^ help: use the associated constant instead: `f32::EPSILON`
104-
|
105-
note: you may need to remove one of the following `use` statements
106-
--> $DIR/legacy_numeric_constants.rs:38:5
107-
|
108-
LL | use std::f32;
109-
| ^^^^^^^^^^^^^
110-
111-
error: usage of a legacy numeric constant
112-
--> $DIR/legacy_numeric_constants.rs:50:5
76+
--> $DIR/legacy_numeric_constants.rs:46:5
11377
|
11478
LL | std::u32::MAX;
11579
| ^^^^^^^^^^^^^ help: use the associated constant instead: `u32::MAX`
11680

11781
error: usage of a legacy numeric constant
118-
--> $DIR/legacy_numeric_constants.rs:55:5
82+
--> $DIR/legacy_numeric_constants.rs:51:5
11983
|
12084
LL | std::u32::MAX;
12185
| ^^^^^^^^^^^^^ help: use the associated constant instead: `u32::MAX`
12286

123-
error: aborting due to 17 previous errors
87+
error: aborting due to 14 previous errors
12488

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@aux-build:proc_macros.rs
2+
#![allow(clippy::no_effect, deprecated, unused)]
3+
#![warn(clippy::legacy_numeric_constants)]
4+
5+
#[macro_use]
6+
extern crate proc_macros;
7+
8+
use std::u128 as _;
9+
10+
fn main() {
11+
use std::u32;
12+
u32::MAX;
13+
use std::f64;
14+
f64::MAX;
15+
u128::MAX;
16+
// Don't lint
17+
u8::MIN;
18+
std::f32::consts::E;
19+
use std::f32;
20+
f64::consts::E;
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error: usage of a legacy numeric constant
2+
--> $DIR/legacy_numeric_constants_non_rustfix.rs:12:5
3+
|
4+
LL | u32::MAX;
5+
| ^^^^^^^^ help: use the associated constant instead: `u32::MAX`
6+
|
7+
note: you may need to remove one of the following `use` statements
8+
--> $DIR/legacy_numeric_constants_non_rustfix.rs:11:5
9+
|
10+
LL | use std::u32;
11+
| ^^^^^^^^^^^^^
12+
= note: `-D clippy::legacy-numeric-constants` implied by `-D warnings`
13+
14+
error: usage of a legacy numeric constant
15+
--> $DIR/legacy_numeric_constants_non_rustfix.rs:14:5
16+
|
17+
LL | f64::MAX;
18+
| ^^^^^^^^ help: use the associated constant instead: `f64::MAX`
19+
|
20+
note: you may need to remove one of the following `use` statements
21+
--> $DIR/legacy_numeric_constants_non_rustfix.rs:13:5
22+
|
23+
LL | use std::f64;
24+
| ^^^^^^^^^^^^^
25+
26+
error: aborting due to 2 previous errors
27+

0 commit comments

Comments
 (0)