Add test to ensure that suggestions are only emitted if MSRV supports it

This commit is contained in:
RunDevelopment 2025-08-02 00:16:08 +02:00
parent 064825e734
commit 0eb16ea97b
2 changed files with 26 additions and 1 deletions

View file

@ -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
}
}

View file

@ -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