-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
cast_lossless
]: Suggest type alias instead of the aliased type
- Loading branch information
Showing
11 changed files
with
120 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,94 @@ | ||
error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:8:13 | ||
--> $DIR/cast_lossless_bool.rs:10:13 | ||
| | ||
LL | let _ = true as u8; | ||
| ^^^^^^^^^^ help: try: `u8::from(true)` | ||
| | ||
= note: `-D clippy::cast-lossless` implied by `-D warnings` | ||
|
||
error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:9:13 | ||
--> $DIR/cast_lossless_bool.rs:11:13 | ||
| | ||
LL | let _ = true as u16; | ||
| ^^^^^^^^^^^ help: try: `u16::from(true)` | ||
|
||
error: casting `bool` to `u32` is more cleanly stated with `u32::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:10:13 | ||
--> $DIR/cast_lossless_bool.rs:12:13 | ||
| | ||
LL | let _ = true as u32; | ||
| ^^^^^^^^^^^ help: try: `u32::from(true)` | ||
|
||
error: casting `bool` to `u64` is more cleanly stated with `u64::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:11:13 | ||
--> $DIR/cast_lossless_bool.rs:13:13 | ||
| | ||
LL | let _ = true as u64; | ||
| ^^^^^^^^^^^ help: try: `u64::from(true)` | ||
|
||
error: casting `bool` to `u128` is more cleanly stated with `u128::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:12:13 | ||
--> $DIR/cast_lossless_bool.rs:14:13 | ||
| | ||
LL | let _ = true as u128; | ||
| ^^^^^^^^^^^^ help: try: `u128::from(true)` | ||
|
||
error: casting `bool` to `usize` is more cleanly stated with `usize::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:13:13 | ||
--> $DIR/cast_lossless_bool.rs:15:13 | ||
| | ||
LL | let _ = true as usize; | ||
| ^^^^^^^^^^^^^ help: try: `usize::from(true)` | ||
|
||
error: casting `bool` to `i8` is more cleanly stated with `i8::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:15:13 | ||
--> $DIR/cast_lossless_bool.rs:17:13 | ||
| | ||
LL | let _ = true as i8; | ||
| ^^^^^^^^^^ help: try: `i8::from(true)` | ||
|
||
error: casting `bool` to `i16` is more cleanly stated with `i16::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:16:13 | ||
--> $DIR/cast_lossless_bool.rs:18:13 | ||
| | ||
LL | let _ = true as i16; | ||
| ^^^^^^^^^^^ help: try: `i16::from(true)` | ||
|
||
error: casting `bool` to `i32` is more cleanly stated with `i32::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:17:13 | ||
--> $DIR/cast_lossless_bool.rs:19:13 | ||
| | ||
LL | let _ = true as i32; | ||
| ^^^^^^^^^^^ help: try: `i32::from(true)` | ||
|
||
error: casting `bool` to `i64` is more cleanly stated with `i64::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:18:13 | ||
--> $DIR/cast_lossless_bool.rs:20:13 | ||
| | ||
LL | let _ = true as i64; | ||
| ^^^^^^^^^^^ help: try: `i64::from(true)` | ||
|
||
error: casting `bool` to `i128` is more cleanly stated with `i128::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:19:13 | ||
--> $DIR/cast_lossless_bool.rs:21:13 | ||
| | ||
LL | let _ = true as i128; | ||
| ^^^^^^^^^^^^ help: try: `i128::from(true)` | ||
|
||
error: casting `bool` to `isize` is more cleanly stated with `isize::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:20:13 | ||
--> $DIR/cast_lossless_bool.rs:22:13 | ||
| | ||
LL | let _ = true as isize; | ||
| ^^^^^^^^^^^^^ help: try: `isize::from(true)` | ||
|
||
error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:23:13 | ||
--> $DIR/cast_lossless_bool.rs:25:13 | ||
| | ||
LL | let _ = (true | false) as u16; | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::from(true | false)` | ||
|
||
error: casting `bool` to `U8` is more cleanly stated with `U8::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:27:13 | ||
| | ||
LL | let _ = true as U8; | ||
| ^^^^^^^^^^ help: try: `U8::from(true)` | ||
|
||
error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)` | ||
--> $DIR/cast_lossless_bool.rs:51:13 | ||
--> $DIR/cast_lossless_bool.rs:55:13 | ||
| | ||
LL | let _ = true as u8; | ||
| ^^^^^^^^^^ help: try: `u8::from(true)` | ||
|
||
error: aborting due to 14 previous errors | ||
error: aborting due to 15 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,82 @@ | ||
error: casting `i8` to `f32` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:9:13 | ||
--> $DIR/cast_lossless_float.rs:12:13 | ||
| | ||
LL | let _ = x0 as f32; | ||
| ^^^^^^^^^ help: try: `f32::from(x0)` | ||
| | ||
= note: `-D clippy::cast-lossless` implied by `-D warnings` | ||
|
||
error: casting `i8` to `f64` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:10:13 | ||
--> $DIR/cast_lossless_float.rs:13:13 | ||
| | ||
LL | let _ = x0 as f64; | ||
| ^^^^^^^^^ help: try: `f64::from(x0)` | ||
|
||
error: casting `i8` to `F32` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:14:13 | ||
| | ||
LL | let _ = x0 as F32; | ||
| ^^^^^^^^^ help: try: `F32::from(x0)` | ||
|
||
error: casting `i8` to `F64` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:15:13 | ||
| | ||
LL | let _ = x0 as F64; | ||
| ^^^^^^^^^ help: try: `F64::from(x0)` | ||
|
||
error: casting `u8` to `f32` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:12:13 | ||
--> $DIR/cast_lossless_float.rs:17:13 | ||
| | ||
LL | let _ = x1 as f32; | ||
| ^^^^^^^^^ help: try: `f32::from(x1)` | ||
|
||
error: casting `u8` to `f64` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:13:13 | ||
--> $DIR/cast_lossless_float.rs:18:13 | ||
| | ||
LL | let _ = x1 as f64; | ||
| ^^^^^^^^^ help: try: `f64::from(x1)` | ||
|
||
error: casting `i16` to `f32` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:15:13 | ||
--> $DIR/cast_lossless_float.rs:20:13 | ||
| | ||
LL | let _ = x2 as f32; | ||
| ^^^^^^^^^ help: try: `f32::from(x2)` | ||
|
||
error: casting `i16` to `f64` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:16:13 | ||
--> $DIR/cast_lossless_float.rs:21:13 | ||
| | ||
LL | let _ = x2 as f64; | ||
| ^^^^^^^^^ help: try: `f64::from(x2)` | ||
|
||
error: casting `u16` to `f32` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:18:13 | ||
--> $DIR/cast_lossless_float.rs:23:13 | ||
| | ||
LL | let _ = x3 as f32; | ||
| ^^^^^^^^^ help: try: `f32::from(x3)` | ||
|
||
error: casting `u16` to `f64` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:19:13 | ||
--> $DIR/cast_lossless_float.rs:24:13 | ||
| | ||
LL | let _ = x3 as f64; | ||
| ^^^^^^^^^ help: try: `f64::from(x3)` | ||
|
||
error: casting `i32` to `f64` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:21:13 | ||
--> $DIR/cast_lossless_float.rs:26:13 | ||
| | ||
LL | let _ = x4 as f64; | ||
| ^^^^^^^^^ help: try: `f64::from(x4)` | ||
|
||
error: casting `u32` to `f64` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:23:13 | ||
--> $DIR/cast_lossless_float.rs:28:13 | ||
| | ||
LL | let _ = x5 as f64; | ||
| ^^^^^^^^^ help: try: `f64::from(x5)` | ||
|
||
error: casting `f32` to `f64` may become silently lossy if you later change the type | ||
--> $DIR/cast_lossless_float.rs:26:13 | ||
--> $DIR/cast_lossless_float.rs:31:13 | ||
| | ||
LL | let _ = 1.0f32 as f64; | ||
| ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` | ||
|
||
error: aborting due to 11 previous errors | ||
error: aborting due to 13 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.