Skip to content

Commit d93fba7

Browse files
Add UI test for primitive_method_to_numeric_cast
1 parent ed1edf3 commit d93fba7

3 files changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![warn(clippy::primitive_method_to_numeric_cast)]
2+
3+
fn main() {
4+
let _ = u16::MAX as usize; //~ primitive_method_to_numeric_cast
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![warn(clippy::primitive_method_to_numeric_cast)]
2+
3+
fn main() {
4+
let _ = u16::max as usize; //~ primitive_method_to_numeric_cast
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: casting function pointer `u16::max` to `usize`
2+
--> tests/ui/primitive_method_to_numeric_cast.rs:4:13
3+
|
4+
LL | let _ = u16::max as usize;
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `-D clippy::primitive-method-to-numeric-cast` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::primitive_method_to_numeric_cast)]`
9+
help: did you mean to use the associated constant?
10+
|
11+
LL | let _ = u16::MAX as usize;
12+
| ~~~~~~~~~~~~~~~~~
13+
14+
error: aborting due to 1 previous error
15+

0 commit comments

Comments
 (0)