checked-conversions: make lint adhere to lint message convention

This commit is contained in:
Matthias Krüger 2020-07-23 16:58:20 +02:00
parent 40416c0fa8
commit 9b7ab1d38b
2 changed files with 17 additions and 17 deletions

View File

@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for CheckedConversions {
cx, cx,
CHECKED_CONVERSIONS, CHECKED_CONVERSIONS,
item.span, item.span,
"Checked cast can be simplified.", "checked cast can be simplified",
"try", "try",
format!("{}::try_from({}).is_ok()", to_type, snippet), format!("{}::try_from({}).is_ok()", to_type, snippet),
applicability, applicability,

View File

@ -1,4 +1,4 @@
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:17:13 --> $DIR/checked_conversions.rs:17:13
| |
LL | let _ = value <= (u32::max_value() as i64) && value >= 0; LL | let _ = value <= (u32::max_value() as i64) && value >= 0;
@ -6,91 +6,91 @@ LL | let _ = value <= (u32::max_value() as i64) && value >= 0;
| |
= note: `-D clippy::checked-conversions` implied by `-D warnings` = note: `-D clippy::checked-conversions` implied by `-D warnings`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:18:13 --> $DIR/checked_conversions.rs:18:13
| |
LL | let _ = value <= (u32::MAX as i64) && value >= 0; LL | let _ = value <= (u32::MAX as i64) && value >= 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:22:13 --> $DIR/checked_conversions.rs:22:13
| |
LL | let _ = value <= i64::from(u16::max_value()) && value >= 0; LL | let _ = value <= i64::from(u16::max_value()) && value >= 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:23:13 --> $DIR/checked_conversions.rs:23:13
| |
LL | let _ = value <= i64::from(u16::MAX) && value >= 0; LL | let _ = value <= i64::from(u16::MAX) && value >= 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:27:13 --> $DIR/checked_conversions.rs:27:13
| |
LL | let _ = value <= (u8::max_value() as isize) && value >= 0; LL | let _ = value <= (u8::max_value() as isize) && value >= 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:28:13 --> $DIR/checked_conversions.rs:28:13
| |
LL | let _ = value <= (u8::MAX as isize) && value >= 0; LL | let _ = value <= (u8::MAX as isize) && value >= 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:34:13 --> $DIR/checked_conversions.rs:34:13
| |
LL | let _ = value <= (i32::max_value() as i64) && value >= (i32::min_value() as i64); LL | let _ = value <= (i32::max_value() as i64) && value >= (i32::min_value() as i64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:35:13 --> $DIR/checked_conversions.rs:35:13
| |
LL | let _ = value <= (i32::MAX as i64) && value >= (i32::MIN as i64); LL | let _ = value <= (i32::MAX as i64) && value >= (i32::MIN as i64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:39:13 --> $DIR/checked_conversions.rs:39:13
| |
LL | let _ = value <= i64::from(i16::max_value()) && value >= i64::from(i16::min_value()); LL | let _ = value <= i64::from(i16::max_value()) && value >= i64::from(i16::min_value());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:40:13 --> $DIR/checked_conversions.rs:40:13
| |
LL | let _ = value <= i64::from(i16::MAX) && value >= i64::from(i16::MIN); LL | let _ = value <= i64::from(i16::MAX) && value >= i64::from(i16::MIN);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:46:13 --> $DIR/checked_conversions.rs:46:13
| |
LL | let _ = value <= i32::max_value() as u32; LL | let _ = value <= i32::max_value() as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:47:13 --> $DIR/checked_conversions.rs:47:13
| |
LL | let _ = value <= i32::MAX as u32; LL | let _ = value <= i32::MAX as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:51:13 --> $DIR/checked_conversions.rs:51:13
| |
LL | let _ = value <= isize::max_value() as usize && value as i32 == 5; LL | let _ = value <= isize::max_value() as usize && value as i32 == 5;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:52:13 --> $DIR/checked_conversions.rs:52:13
| |
LL | let _ = value <= isize::MAX as usize && value as i32 == 5; LL | let _ = value <= isize::MAX as usize && value as i32 == 5;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:56:13 --> $DIR/checked_conversions.rs:56:13
| |
LL | let _ = value <= u16::max_value() as u32 && value as i32 == 5; LL | let _ = value <= u16::max_value() as u32 && value as i32 == 5;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()`
error: Checked cast can be simplified. error: checked cast can be simplified
--> $DIR/checked_conversions.rs:57:13 --> $DIR/checked_conversions.rs:57:13
| |
LL | let _ = value <= u16::MAX as u32 && value as i32 == 5; LL | let _ = value <= u16::MAX as u32 && value as i32 == 5;