Skip to content

Commit

Permalink
Split tests into two files
Browse files Browse the repository at this point in the history
  • Loading branch information
Centri3 committed Jun 27, 2023
1 parent 388aa5d commit 7170eb4
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 58 deletions.
1 change: 0 additions & 1 deletion tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ const RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS: &[&str] = &[
"eprint_with_newline.rs",
"explicit_counter_loop.rs",
"iter_skip_next_unfixable.rs",
"legacy_numeric_constants.rs",
"let_and_return.rs",
"literals.rs",
"map_flatten.rs",
Expand Down
52 changes: 52 additions & 0 deletions tests/ui/legacy_numeric_constants.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//@run-rustfix
//@aux-build:proc_macros.rs:proc-macro
#![allow(clippy::no_effect, deprecated, unused)]
#![warn(clippy::legacy_numeric_constants)]

#[macro_use]
extern crate proc_macros;

use std::u128 as _;
pub mod a {
pub use std::u128;
}

fn main() {
f32::EPSILON;
u8::MIN;
usize::MIN;
u32::MAX;
u32::MAX;
use std::u32::MAX;
u32::MAX;
u32::MAX;
u8::MAX;
u8::MIN;
::std::primitive::u8::MIN;
::std::u8::MIN;
::std::primitive::u8::MIN;
std::primitive::u32::MAX;
u128::MAX;
// Don't lint
use std::f64;
f32::EPSILON;
u8::MIN;
std::f32::consts::E;
f64::consts::E;
external! {
::std::primitive::u8::MIN;
::std::u8::MIN;
::std::primitive::u8::min_value();
}
}

#[clippy::msrv = "1.42.0"]
fn msrv_too_low() {
// FIXME: Why does this lint??
u32::MAX;
}

#[clippy::msrv = "1.43.0"]
fn msrv_juust_right() {
u32::MAX;
}
10 changes: 3 additions & 7 deletions tests/ui/legacy_numeric_constants.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@aux-build:proc_macros.rs
//@run-rustfix
//@aux-build:proc_macros.rs:proc-macro
#![allow(clippy::no_effect, deprecated, unused)]
#![warn(clippy::legacy_numeric_constants)]

Expand All @@ -16,26 +17,21 @@ fn main() {
std::usize::MIN;
std::u32::MAX;
core::u32::MAX;
use std::u32;
use std::u32::MAX;
MAX;
u32::MAX;
u32::max_value();
u8::max_value();
u8::min_value();
::std::primitive::u8::MIN;
::std::u8::MIN;
::std::primitive::u8::min_value();
std::primitive::u32::max_value();
use std::f64;
f64::MAX;
self::a::u128::MAX;
u128::MAX;
// Don't lint
use std::f64;
f32::EPSILON;
u8::MIN;
std::f32::consts::E;
use std::f32;
f64::consts::E;
external! {
::std::primitive::u8::MIN;
Expand Down
64 changes: 14 additions & 50 deletions tests/ui/legacy_numeric_constants.stderr
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
error: usage of a legacy numeric constant
--> $DIR/legacy_numeric_constants.rs:14:5
--> $DIR/legacy_numeric_constants.rs:15:5
|
LL | std::f32::EPSILON;
| ^^^^^^^^^^^^^^^^^ help: use the associated constant instead: `f32::EPSILON`
|
= note: `-D clippy::legacy-numeric-constants` implied by `-D warnings`

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

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

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

error: usage of a legacy numeric constant
--> $DIR/legacy_numeric_constants.rs:18:5
--> $DIR/legacy_numeric_constants.rs:19:5
|
LL | core::u32::MAX;
| ^^^^^^^^^^^^^^ help: use the associated constant instead: `u32::MAX`
Expand All @@ -36,89 +36,53 @@ error: usage of a legacy numeric constant
LL | MAX;
| ^^^ help: use the associated constant instead: `u32::MAX`

error: usage of a legacy numeric constant
--> $DIR/legacy_numeric_constants.rs:22:5
|
LL | u32::MAX;
| ^^^^^^^^ help: use the associated constant instead: `u32::MAX`
|
note: you may need to remove one of the following `use` statements
--> $DIR/legacy_numeric_constants.rs:20:5
|
LL | use std::u32::MAX;
| ^^^^^^^^^^^^^^^^^^

error: usage of a legacy numeric method
--> $DIR/legacy_numeric_constants.rs:23:10
--> $DIR/legacy_numeric_constants.rs:22:10
|
LL | u32::max_value();
| ^^^^^^^^^^^ help: use the associated constant instead: `MAX`

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

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

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

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

error: usage of a legacy numeric constant
--> $DIR/legacy_numeric_constants.rs:31:5
|
LL | f64::MAX;
| ^^^^^^^^ help: use the associated constant instead: `f64::MAX`
|
note: you may need to remove one of the following `use` statements
--> $DIR/legacy_numeric_constants.rs:30:5
|
LL | use std::f64;
| ^^^^^^^^^^^^^

error: usage of a legacy numeric constant
--> $DIR/legacy_numeric_constants.rs:32:5
--> $DIR/legacy_numeric_constants.rs:29:5
|
LL | self::a::u128::MAX;
| ^^^^^^^^^^^^^^^^^^ help: use the associated constant instead: `u128::MAX`

error: usage of a legacy numeric constant
--> $DIR/legacy_numeric_constants.rs:35:5
|
LL | f32::EPSILON;
| ^^^^^^^^^^^^ help: use the associated constant instead: `f32::EPSILON`
|
note: you may need to remove one of the following `use` statements
--> $DIR/legacy_numeric_constants.rs:38:5
|
LL | use std::f32;
| ^^^^^^^^^^^^^

error: usage of a legacy numeric constant
--> $DIR/legacy_numeric_constants.rs:50:5
--> $DIR/legacy_numeric_constants.rs:46:5
|
LL | std::u32::MAX;
| ^^^^^^^^^^^^^ help: use the associated constant instead: `u32::MAX`

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

error: aborting due to 17 previous errors
error: aborting due to 14 previous errors

21 changes: 21 additions & 0 deletions tests/ui/legacy_numeric_constants_non_rustfix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@aux-build:proc_macros.rs
#![allow(clippy::no_effect, deprecated, unused)]
#![warn(clippy::legacy_numeric_constants)]

#[macro_use]
extern crate proc_macros;

use std::u128 as _;

fn main() {
use std::u32;
u32::MAX;
use std::f64;
f64::MAX;
u128::MAX;
// Don't lint
u8::MIN;
std::f32::consts::E;
use std::f32;
f64::consts::E;
}
27 changes: 27 additions & 0 deletions tests/ui/legacy_numeric_constants_non_rustfix.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error: usage of a legacy numeric constant
--> $DIR/legacy_numeric_constants_non_rustfix.rs:12:5
|
LL | u32::MAX;
| ^^^^^^^^ help: use the associated constant instead: `u32::MAX`
|
note: you may need to remove one of the following `use` statements
--> $DIR/legacy_numeric_constants_non_rustfix.rs:11:5
|
LL | use std::u32;
| ^^^^^^^^^^^^^
= note: `-D clippy::legacy-numeric-constants` implied by `-D warnings`

error: usage of a legacy numeric constant
--> $DIR/legacy_numeric_constants_non_rustfix.rs:14:5
|
LL | f64::MAX;
| ^^^^^^^^ help: use the associated constant instead: `f64::MAX`
|
note: you may need to remove one of the following `use` statements
--> $DIR/legacy_numeric_constants_non_rustfix.rs:13:5
|
LL | use std::f64;
| ^^^^^^^^^^^^^

error: aborting due to 2 previous errors

0 comments on commit 7170eb4

Please sign in to comment.