Add UI test for primitive_method_to_numeric_cast

This commit is contained in:
Guillaume Gomez 2025-01-10 17:44:58 +01:00
parent be40534457
commit c680419425
3 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,5 @@
#![warn(clippy::primitive_method_to_numeric_cast)]
fn main() {
let _ = u16::MAX as usize; //~ primitive_method_to_numeric_cast
}

View file

@ -0,0 +1,5 @@
#![warn(clippy::primitive_method_to_numeric_cast)]
fn main() {
let _ = u16::max as usize; //~ primitive_method_to_numeric_cast
}

View file

@ -0,0 +1,15 @@
error: casting function pointer `u16::max` to `usize`
--> tests/ui/primitive_method_to_numeric_cast.rs:4:13
|
LL | let _ = u16::max as usize;
| ^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::primitive-method-to-numeric-cast` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::primitive_method_to_numeric_cast)]`
help: did you mean to use the associated constant?
|
LL | let _ = u16::MAX as usize;
| ~~~~~~~~~~~~~~~~~
error: aborting due to 1 previous error