2019-08-04 06:24:23 +00:00
|
|
|
#![warn(clippy::unnecessary_cast)]
|
|
|
|
#![allow(clippy::no_effect)]
|
|
|
|
|
2022-01-25 14:19:19 +00:00
|
|
|
#[rustfmt::skip]
|
2019-08-04 06:24:23 +00:00
|
|
|
fn main() {
|
|
|
|
// Test cast_unnecessary
|
|
|
|
1i32 as i32;
|
|
|
|
1f32 as f32;
|
|
|
|
false as bool;
|
|
|
|
&1i32 as &i32;
|
|
|
|
|
2022-01-25 14:19:19 +00:00
|
|
|
-1_i32 as i32;
|
|
|
|
- 1_i32 as i32;
|
|
|
|
-1f32 as f32;
|
|
|
|
1_i32 as i32;
|
|
|
|
1_f32 as f32;
|
|
|
|
|
2019-08-04 06:24:23 +00:00
|
|
|
// macro version
|
|
|
|
macro_rules! foo {
|
|
|
|
($a:ident, $b:ident) => {
|
|
|
|
#[allow(unused)]
|
|
|
|
pub fn $a() -> $b {
|
|
|
|
1 as $b
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
foo!(a, i32);
|
|
|
|
foo!(b, f32);
|
|
|
|
foo!(c, f64);
|
2020-11-23 01:21:01 +00:00
|
|
|
|
|
|
|
// do not lint cast to cfg-dependant type
|
|
|
|
1 as std::os::raw::c_char;
|
2022-03-28 04:09:01 +00:00
|
|
|
|
|
|
|
// do not lint cast to alias type
|
|
|
|
1 as I32Alias;
|
|
|
|
&1 as &I32Alias;
|
2019-08-04 06:24:23 +00:00
|
|
|
}
|
2022-03-28 04:09:01 +00:00
|
|
|
|
|
|
|
type I32Alias = i32;
|