mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 16:39:26 +00:00
202 lines
6 KiB
Text
202 lines
6 KiB
Text
error: casting integer literal to `i32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:17:5
|
|
|
|
|
LL | 1i32 as i32;
|
|
| ^^^^^^^^^^^ help: try: `1_i32`
|
|
|
|
|
= note: `-D clippy::unnecessary-cast` implied by `-D warnings`
|
|
|
|
error: casting float literal to `f32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:18:5
|
|
|
|
|
LL | 1f32 as f32;
|
|
| ^^^^^^^^^^^ help: try: `1_f32`
|
|
|
|
error: casting to the same type is unnecessary (`bool` -> `bool`)
|
|
--> $DIR/unnecessary_cast.rs:19:5
|
|
|
|
|
LL | false as bool;
|
|
| ^^^^^^^^^^^^^ help: try: `false`
|
|
|
|
error: casting integer literal to `i32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:22:5
|
|
|
|
|
LL | -1_i32 as i32;
|
|
| ^^^^^^^^^^^^^ help: try: `-1_i32`
|
|
|
|
error: casting integer literal to `i32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:23:5
|
|
|
|
|
LL | - 1_i32 as i32;
|
|
| ^^^^^^^^^^^^^^ help: try: `- 1_i32`
|
|
|
|
error: casting float literal to `f32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:24:5
|
|
|
|
|
LL | -1f32 as f32;
|
|
| ^^^^^^^^^^^^ help: try: `-1_f32`
|
|
|
|
error: casting integer literal to `i32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:25:5
|
|
|
|
|
LL | 1_i32 as i32;
|
|
| ^^^^^^^^^^^^ help: try: `1_i32`
|
|
|
|
error: casting float literal to `f32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:26:5
|
|
|
|
|
LL | 1_f32 as f32;
|
|
| ^^^^^^^^^^^^ help: try: `1_f32`
|
|
|
|
error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`)
|
|
--> $DIR/unnecessary_cast.rs:28:5
|
|
|
|
|
LL | [1u8, 2].as_ptr() as *const u8;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()`
|
|
|
|
error: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`)
|
|
--> $DIR/unnecessary_cast.rs:30:5
|
|
|
|
|
LL | [1u8, 2].as_mut_ptr() as *mut u8;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_mut_ptr()`
|
|
|
|
error: casting integer literal to `f32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:78:9
|
|
|
|
|
LL | 100 as f32;
|
|
| ^^^^^^^^^^ help: try: `100_f32`
|
|
|
|
error: casting integer literal to `f64` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:79:9
|
|
|
|
|
LL | 100 as f64;
|
|
| ^^^^^^^^^^ help: try: `100_f64`
|
|
|
|
error: casting integer literal to `f64` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:80:9
|
|
|
|
|
LL | 100_i32 as f64;
|
|
| ^^^^^^^^^^^^^^ help: try: `100_f64`
|
|
|
|
error: casting integer literal to `f32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:81:17
|
|
|
|
|
LL | let _ = -100 as f32;
|
|
| ^^^^^^^^^^^ help: try: `-100_f32`
|
|
|
|
error: casting integer literal to `f64` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:82:17
|
|
|
|
|
LL | let _ = -100 as f64;
|
|
| ^^^^^^^^^^^ help: try: `-100_f64`
|
|
|
|
error: casting integer literal to `f64` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:83:17
|
|
|
|
|
LL | let _ = -100_i32 as f64;
|
|
| ^^^^^^^^^^^^^^^ help: try: `-100_f64`
|
|
|
|
error: casting float literal to `f32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:84:9
|
|
|
|
|
LL | 100. as f32;
|
|
| ^^^^^^^^^^^ help: try: `100_f32`
|
|
|
|
error: casting float literal to `f64` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:85:9
|
|
|
|
|
LL | 100. as f64;
|
|
| ^^^^^^^^^^^ help: try: `100_f64`
|
|
|
|
error: casting integer literal to `u32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:97:9
|
|
|
|
|
LL | 1 as u32;
|
|
| ^^^^^^^^ help: try: `1_u32`
|
|
|
|
error: casting integer literal to `i32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:98:9
|
|
|
|
|
LL | 0x10 as i32;
|
|
| ^^^^^^^^^^^ help: try: `0x10_i32`
|
|
|
|
error: casting integer literal to `usize` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:99:9
|
|
|
|
|
LL | 0b10 as usize;
|
|
| ^^^^^^^^^^^^^ help: try: `0b10_usize`
|
|
|
|
error: casting integer literal to `u16` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:100:9
|
|
|
|
|
LL | 0o73 as u16;
|
|
| ^^^^^^^^^^^ help: try: `0o73_u16`
|
|
|
|
error: casting integer literal to `u32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:101:9
|
|
|
|
|
LL | 1_000_000_000 as u32;
|
|
| ^^^^^^^^^^^^^^^^^^^^ help: try: `1_000_000_000_u32`
|
|
|
|
error: casting float literal to `f64` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:103:9
|
|
|
|
|
LL | 1.0 as f64;
|
|
| ^^^^^^^^^^ help: try: `1.0_f64`
|
|
|
|
error: casting float literal to `f32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:104:9
|
|
|
|
|
LL | 0.5 as f32;
|
|
| ^^^^^^^^^^ help: try: `0.5_f32`
|
|
|
|
error: casting integer literal to `i32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:108:17
|
|
|
|
|
LL | let _ = -1 as i32;
|
|
| ^^^^^^^^^ help: try: `-1_i32`
|
|
|
|
error: casting float literal to `f32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:109:17
|
|
|
|
|
LL | let _ = -1.0 as f32;
|
|
| ^^^^^^^^^^^ help: try: `-1.0_f32`
|
|
|
|
error: casting to the same type is unnecessary (`i32` -> `i32`)
|
|
--> $DIR/unnecessary_cast.rs:115:18
|
|
|
|
|
LL | let _ = &(x as i32);
|
|
| ^^^^^^^^^^ help: try: `{ x }`
|
|
|
|
error: casting integer literal to `i32` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:121:22
|
|
|
|
|
LL | let _: i32 = -(1) as i32;
|
|
| ^^^^^^^^^^^ help: try: `-1_i32`
|
|
|
|
error: casting integer literal to `i64` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:123:22
|
|
|
|
|
LL | let _: i64 = -(1) as i64;
|
|
| ^^^^^^^^^^^ help: try: `-1_i64`
|
|
|
|
error: casting float literal to `f64` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:130:22
|
|
|
|
|
LL | let _: f64 = (-8.0 as f64).exp();
|
|
| ^^^^^^^^^^^^^ help: try: `(-8.0_f64)`
|
|
|
|
error: casting float literal to `f64` is unnecessary
|
|
--> $DIR/unnecessary_cast.rs:132:23
|
|
|
|
|
LL | let _: f64 = -(8.0 as f64).exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior
|
|
| ^^^^^^^^^^^^ help: try: `8.0_f64`
|
|
|
|
error: casting to the same type is unnecessary (`f32` -> `f32`)
|
|
--> $DIR/unnecessary_cast.rs:140:20
|
|
|
|
|
LL | let _num = foo() as f32;
|
|
| ^^^^^^^^^^^^ help: try: `foo()`
|
|
|
|
error: aborting due to 33 previous errors
|
|
|