diff --git a/tests/ui/primitive_method_to_numeric_cast.fixed b/tests/ui/primitive_method_to_numeric_cast.fixed new file mode 100644 index 000000000000..1ebb52618f13 --- /dev/null +++ b/tests/ui/primitive_method_to_numeric_cast.fixed @@ -0,0 +1,5 @@ +#![warn(clippy::primitive_method_to_numeric_cast)] + +fn main() { + let _ = u16::MAX as usize; //~ primitive_method_to_numeric_cast +} diff --git a/tests/ui/primitive_method_to_numeric_cast.rs b/tests/ui/primitive_method_to_numeric_cast.rs new file mode 100644 index 000000000000..89b0bfa84fee --- /dev/null +++ b/tests/ui/primitive_method_to_numeric_cast.rs @@ -0,0 +1,5 @@ +#![warn(clippy::primitive_method_to_numeric_cast)] + +fn main() { + let _ = u16::max as usize; //~ primitive_method_to_numeric_cast +} diff --git a/tests/ui/primitive_method_to_numeric_cast.stderr b/tests/ui/primitive_method_to_numeric_cast.stderr new file mode 100644 index 000000000000..5515dc646ce7 --- /dev/null +++ b/tests/ui/primitive_method_to_numeric_cast.stderr @@ -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 +