diff options
| author | RunDevelopment <mitchi5000.ms@googlemail.com> | 2025-08-02 00:16:08 +0200 |
|---|---|---|
| committer | RunDevelopment <mitchi5000.ms@googlemail.com> | 2025-08-03 13:45:45 +0200 |
| commit | 0eb16ea97b5161da7874f772e20e49f02af20189 (patch) | |
| tree | 333eb9b0b6f925cbf937e4e9efe1637537442d01 | |
| parent | 064825e734e9472925664ad681e055602ea62397 (diff) | |
| download | rust-0eb16ea97b5161da7874f772e20e49f02af20189.tar.gz rust-0eb16ea97b5161da7874f772e20e49f02af20189.zip | |
Add test to ensure that suggestions are only emitted if MSRV supports it
| -rw-r--r-- | tests/ui/cast.rs | 13 | ||||
| -rw-r--r-- | tests/ui/cast.stderr | 14 |
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index 525be821650..fab02bf7b24 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -569,3 +569,16 @@ fn issue12721() { (255 % 999999u64) as u8; //~^ cast_possible_truncation } + +mod issue14150 { + #[clippy::msrv = "1.87"] + fn msrv_supports_cast_signed() { + _ = 1u8 as i8; + //~^ cast_possible_wrap + } + #[clippy::msrv = "1.86"] + fn msrv_doesnt_supports_cast_signed() { + _ = 1u8 as i8; + //~^ cast_possible_wrap + } +} diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 13e0a5583cd..f131369df24 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -752,5 +752,17 @@ LL - (255 % 999999u64) as u8; LL + u8::try_from(255 % 999999u64); | -error: aborting due to 92 previous errors +error: casting `u8` to `i8` may wrap around the value + --> tests/ui/cast.rs:576:13 + | +LL | _ = 1u8 as i8; + | ^^^^^^^^^ help: if this is intentional, consider using `cast_signed()` instead: `1u8.cast_signed()` + +error: casting `u8` to `i8` may wrap around the value + --> tests/ui/cast.rs:581:13 + | +LL | _ = 1u8 as i8; + | ^^^^^^^^^ + +error: aborting due to 94 previous errors |
