summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/invalid_upcast_comparisons.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /src/tools/clippy/tests/ui/invalid_upcast_comparisons.rs
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/invalid_upcast_comparisons.rs')
-rw-r--r--src/tools/clippy/tests/ui/invalid_upcast_comparisons.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/invalid_upcast_comparisons.rs b/src/tools/clippy/tests/ui/invalid_upcast_comparisons.rs
index 697416dce..a9db15f20 100644
--- a/src/tools/clippy/tests/ui/invalid_upcast_comparisons.rs
+++ b/src/tools/clippy/tests/ui/invalid_upcast_comparisons.rs
@@ -19,36 +19,61 @@ fn main() {
// always false, since no u8 can be > 300
(u8 as u32) > 300;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
+ //~| NOTE: `-D clippy::invalid-upcast-comparisons` implied by `-D warnings`
(u8 as i32) > 300;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
(u8 as u32) == 300;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
(u8 as i32) == 300;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
300 < (u8 as u32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
300 < (u8 as i32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
300 == (u8 as u32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
300 == (u8 as i32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
// inverted of the above
(u8 as u32) <= 300;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
(u8 as i32) <= 300;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
(u8 as u32) != 300;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
(u8 as i32) != 300;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
300 >= (u8 as u32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
300 >= (u8 as i32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
300 != (u8 as u32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
300 != (u8 as i32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
// always false, since u8 -> i32 doesn't wrap
(u8 as i32) < 0;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
-5 != (u8 as i32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
// inverted of the above
(u8 as i32) >= 0;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
-5 == (u8 as i32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
// always false, since no u8 can be 1337
1337 == (u8 as i32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
1337 == (u8 as u32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
// inverted of the above
1337 != (u8 as i32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
1337 != (u8 as u32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
// Those are Ok:
(u8 as u32) > 20;
@@ -63,7 +88,9 @@ fn main() {
(u8 as i8) == -1;
(u8 as i8) != -1;
(u8 as i32) > -1;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
(u8 as i32) < -1;
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
(u32 as i32) < -5;
(u32 as i32) < 10;
@@ -80,6 +107,7 @@ fn main() {
-5 > (u32 as i32);
-5 >= (u8 as i32);
+ //~^ ERROR: because of the numeric bounds on `u8` prior to casting, this expression is
-5 == (u32 as i32);
}