Skip to content

Commit

Permalink
Use primitive type assoc consts in more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Apr 7, 2020
1 parent c2f67e1 commit b192f2c
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 41 deletions.
16 changes: 8 additions & 8 deletions tests/ui/absurd-extreme-comparisons.rs
Expand Up @@ -16,17 +16,17 @@ fn main() {
u < Z;
Z >= u;
Z > u;
u > std::u32::MAX;
u >= std::u32::MAX;
std::u32::MAX < u;
std::u32::MAX <= u;
u > u32::MAX;
u >= u32::MAX;
u32::MAX < u;
u32::MAX <= u;
1-1 > u;
u >= !0;
u <= 12 - 2*6;
let i: i8 = 0;
i < -127 - 1;
std::i8::MAX >= i;
3-7 < std::i32::MIN;
i8::MAX >= i;
3-7 < i32::MIN;
let b = false;
b >= true;
false > b;
Expand All @@ -52,10 +52,10 @@ impl PartialOrd<u32> for U {
}

pub fn foo(val: U) -> bool {
val > std::u32::MAX
val > u32::MAX
}

pub fn bar(len: u64) -> bool {
// This is OK as we are casting from target sized to fixed size
len >= std::usize::MAX as u64
len >= usize::MAX as u64
}
36 changes: 18 additions & 18 deletions tests/ui/absurd-extreme-comparisons.stderr
Expand Up @@ -42,34 +42,34 @@ LL | Z > u;
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:19:5
|
LL | u > std::u32::MAX;
| ^^^^^^^^^^^^^^^^^
LL | u > u32::MAX;
| ^^^^^^^^^^^^
|
= help: because `std::u32::MAX` is the maximum value for this type, this comparison is always false
= help: because `u32::MAX` is the maximum value for this type, this comparison is always false

error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:20:5
|
LL | u >= std::u32::MAX;
| ^^^^^^^^^^^^^^^^^^
LL | u >= u32::MAX;
| ^^^^^^^^^^^^^
|
= help: because `std::u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u == std::u32::MAX` instead
= help: because `u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u == u32::MAX` instead

error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:21:5
|
LL | std::u32::MAX < u;
| ^^^^^^^^^^^^^^^^^
LL | u32::MAX < u;
| ^^^^^^^^^^^^
|
= help: because `std::u32::MAX` is the maximum value for this type, this comparison is always false
= help: because `u32::MAX` is the maximum value for this type, this comparison is always false

error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:22:5
|
LL | std::u32::MAX <= u;
| ^^^^^^^^^^^^^^^^^^
LL | u32::MAX <= u;
| ^^^^^^^^^^^^^
|
= help: because `std::u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `std::u32::MAX == u` instead
= help: because `u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u32::MAX == u` instead

error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:23:5
Expand Down Expand Up @@ -106,18 +106,18 @@ LL | i < -127 - 1;
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:28:5
|
LL | std::i8::MAX >= i;
| ^^^^^^^^^^^^^^^^^
LL | i8::MAX >= i;
| ^^^^^^^^^^^^
|
= help: because `std::i8::MAX` is the maximum value for this type, this comparison is always true
= help: because `i8::MAX` is the maximum value for this type, this comparison is always true

error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:29:5
|
LL | 3-7 < std::i32::MIN;
| ^^^^^^^^^^^^^^^^^^^
LL | 3-7 < i32::MIN;
| ^^^^^^^^^^^^^^
|
= help: because `std::i32::MIN` is the minimum value for this type, this comparison is always false
= help: because `i32::MIN` is the minimum value for this type, this comparison is always false

error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:31:5
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/crashes/mut_mut_macro.rs
Expand Up @@ -16,7 +16,7 @@
const BAA: *const i32 = 0 as *const i32;
static mut BAR: *const i32 = BAA;
static mut FOO: *const i32 = 0 as *const i32;
static mut BUH: bool = 42.0 < std::f32::NAN;
static mut BUH: bool = 42.0 < f32::NAN;

#[allow(unused_variables, unused_mut)]
fn main() {
Expand All @@ -32,5 +32,5 @@ fn main() {
assert_eq!(*MUT_COUNT, 1);
*/
// FIXME: don't lint in array length, requires `check_body`
//let _ = [""; (42.0 < std::f32::NAN) as usize];
//let _ = [""; (42.0 < f32::NAN) as usize];
}
4 changes: 2 additions & 2 deletions tests/ui/enum_clike_unportable_variant.rs
Expand Up @@ -24,8 +24,8 @@ enum NonPortableSigned {
Y = 0x7FFF_FFFF,
Z = 0xFFFF_FFFF,
A = 0x1_0000_0000,
B = std::i32::MIN as isize,
C = (std::i32::MIN as isize) - 1,
B = i32::MIN as isize,
C = (i32::MIN as isize) - 1,
}

enum NonPortableSignedNoHint {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/enum_clike_unportable_variant.stderr
Expand Up @@ -33,8 +33,8 @@ LL | A = 0x1_0000_0000,
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:28:5
|
LL | C = (std::i32::MIN as isize) - 1,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | C = (i32::MIN as isize) - 1,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enum_clike_unportable_variant.rs:34:5
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/float_cmp.rs
Expand Up @@ -45,8 +45,8 @@ impl PartialEq for X {

fn main() {
ZERO == 0f32; //no error, comparison with zero is ok
1.0f32 != ::std::f32::INFINITY; // also comparison with infinity
1.0f32 != ::std::f32::NEG_INFINITY; // and negative infinity
1.0f32 != f32::INFINITY; // also comparison with infinity
1.0f32 != f32::NEG_INFINITY; // and negative infinity
ZERO == 0.0; //no error, comparison with zero is ok
ZERO + ZERO != 1.0; //no error, comparison with zero is ok

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/float_cmp_const.rs
Expand Up @@ -37,8 +37,8 @@ fn main() {
// no errors, zero and infinity values
ONE != 0f32;
TWO == 0f32;
ONE != ::std::f32::INFINITY;
ONE == ::std::f32::NEG_INFINITY;
ONE != f32::INFINITY;
ONE == f32::NEG_INFINITY;

// no errors, but will warn clippy::float_cmp if '#![allow(float_cmp)]' above is removed
let w = 1.1;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/if_same_then_else.rs
Expand Up @@ -78,7 +78,7 @@ fn if_same_then_else() {
let _ = if true { 0.0 } else { -0.0 };

// Different NaNs
let _ = if true { 0.0 / 0.0 } else { std::f32::NAN };
let _ = if true { 0.0 / 0.0 } else { f32::NAN };

if true {
foo();
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/if_same_then_else2.rs
Expand Up @@ -87,10 +87,10 @@ fn if_same_then_else2() -> Result<&'static str, ()> {

// Same NaNs
let _ = if true {
std::f32::NAN
f32::NAN
} else {
//~ ERROR same body as `if` block
std::f32::NAN
f32::NAN
};

if true {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/if_same_then_else2.stderr
Expand Up @@ -69,7 +69,7 @@ error: this `if` has identical blocks
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | std::f32::NAN
LL | | f32::NAN
LL | | };
| |_____^
|
Expand All @@ -78,7 +78,7 @@ note: same as this
|
LL | let _ = if true {
| _____________________^
LL | | std::f32::NAN
LL | | f32::NAN
LL | | } else {
| |_____^

Expand Down

0 comments on commit b192f2c

Please sign in to comment.