mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
Use primitive type assoc consts in more tests
This commit is contained in:
parent
c2f67e1e19
commit
b192f2cd15
@ -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;
|
||||
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
@ -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
|
||||
|
@ -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() {
|
||||
@ -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];
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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 {
|
||||
|
@ -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 | | };
|
||||
| |_____^
|
||||
|
|
||||
@ -78,7 +78,7 @@ note: same as this
|
||||
|
|
||||
LL | let _ = if true {
|
||||
| _____________________^
|
||||
LL | | std::f32::NAN
|
||||
LL | | f32::NAN
|
||||
LL | | } else {
|
||||
| |_____^
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user