Rename lint into confusing_method_to_numeric_cast
This commit is contained in:
parent
c680419425
commit
06fa0452eb
10 changed files with 172 additions and 44 deletions
14
tests/ui/confusing_method_to_numeric_cast.fixed
Normal file
14
tests/ui/confusing_method_to_numeric_cast.fixed
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(float_minimum_maximum)]
|
||||
#![warn(clippy::confusing_method_to_numeric_cast)]
|
||||
|
||||
fn main() {
|
||||
let _ = u16::MAX as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = u16::MIN as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = u16::MAX as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = u16::MIN as usize; //~ confusing_method_to_numeric_cast
|
||||
|
||||
let _ = f32::MAX as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = f32::MAX as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = f32::MIN as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = f32::MIN as usize; //~ confusing_method_to_numeric_cast
|
||||
}
|
||||
14
tests/ui/confusing_method_to_numeric_cast.rs
Normal file
14
tests/ui/confusing_method_to_numeric_cast.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(float_minimum_maximum)]
|
||||
#![warn(clippy::confusing_method_to_numeric_cast)]
|
||||
|
||||
fn main() {
|
||||
let _ = u16::max as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = u16::min as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = u16::max_value as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = u16::min_value as usize; //~ confusing_method_to_numeric_cast
|
||||
|
||||
let _ = f32::maximum as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = f32::max as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = f32::minimum as usize; //~ confusing_method_to_numeric_cast
|
||||
let _ = f32::min as usize; //~ confusing_method_to_numeric_cast
|
||||
}
|
||||
100
tests/ui/confusing_method_to_numeric_cast.stderr
Normal file
100
tests/ui/confusing_method_to_numeric_cast.stderr
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
error: casting function pointer `u16::max` to `usize`
|
||||
--> tests/ui/confusing_method_to_numeric_cast.rs:5:13
|
||||
|
|
||||
LL | let _ = u16::max as usize;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::confusing-method-to-numeric-cast` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::confusing_method_to_numeric_cast)]`
|
||||
help: did you mean to use the associated constant?
|
||||
|
|
||||
LL - let _ = u16::max as usize;
|
||||
LL + let _ = u16::MAX as usize;
|
||||
|
|
||||
|
||||
error: casting function pointer `u16::min` to `usize`
|
||||
--> tests/ui/confusing_method_to_numeric_cast.rs:6:13
|
||||
|
|
||||
LL | let _ = u16::min as usize;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: did you mean to use the associated constant?
|
||||
|
|
||||
LL - let _ = u16::min as usize;
|
||||
LL + let _ = u16::MIN as usize;
|
||||
|
|
||||
|
||||
error: casting function pointer `u16::max_value` to `usize`
|
||||
--> tests/ui/confusing_method_to_numeric_cast.rs:7:13
|
||||
|
|
||||
LL | let _ = u16::max_value as usize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: did you mean to use the associated constant?
|
||||
|
|
||||
LL - let _ = u16::max_value as usize;
|
||||
LL + let _ = u16::MAX as usize;
|
||||
|
|
||||
|
||||
error: casting function pointer `u16::min_value` to `usize`
|
||||
--> tests/ui/confusing_method_to_numeric_cast.rs:8:13
|
||||
|
|
||||
LL | let _ = u16::min_value as usize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: did you mean to use the associated constant?
|
||||
|
|
||||
LL - let _ = u16::min_value as usize;
|
||||
LL + let _ = u16::MIN as usize;
|
||||
|
|
||||
|
||||
error: casting function pointer `f32::maximum` to `usize`
|
||||
--> tests/ui/confusing_method_to_numeric_cast.rs:10:13
|
||||
|
|
||||
LL | let _ = f32::maximum as usize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: did you mean to use the associated constant?
|
||||
|
|
||||
LL - let _ = f32::maximum as usize;
|
||||
LL + let _ = f32::MAX as usize;
|
||||
|
|
||||
|
||||
error: casting function pointer `f32::max` to `usize`
|
||||
--> tests/ui/confusing_method_to_numeric_cast.rs:11:13
|
||||
|
|
||||
LL | let _ = f32::max as usize;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: did you mean to use the associated constant?
|
||||
|
|
||||
LL - let _ = f32::max as usize;
|
||||
LL + let _ = f32::MAX as usize;
|
||||
|
|
||||
|
||||
error: casting function pointer `f32::minimum` to `usize`
|
||||
--> tests/ui/confusing_method_to_numeric_cast.rs:12:13
|
||||
|
|
||||
LL | let _ = f32::minimum as usize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: did you mean to use the associated constant?
|
||||
|
|
||||
LL - let _ = f32::minimum as usize;
|
||||
LL + let _ = f32::MIN as usize;
|
||||
|
|
||||
|
||||
error: casting function pointer `f32::min` to `usize`
|
||||
--> tests/ui/confusing_method_to_numeric_cast.rs:13:13
|
||||
|
|
||||
LL | let _ = f32::min as usize;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: did you mean to use the associated constant?
|
||||
|
|
||||
LL - let _ = f32::min as usize;
|
||||
LL + let _ = f32::MIN as usize;
|
||||
|
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#![warn(clippy::primitive_method_to_numeric_cast)]
|
||||
|
||||
fn main() {
|
||||
let _ = u16::MAX as usize; //~ primitive_method_to_numeric_cast
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#![warn(clippy::primitive_method_to_numeric_cast)]
|
||||
|
||||
fn main() {
|
||||
let _ = u16::max as usize; //~ primitive_method_to_numeric_cast
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue