Add error-annotations in tests for unnecessary_fallible_conversions
This commit is contained in:
parent
094ce3de3e
commit
1cce757672
@ -1,18 +1,43 @@
|
|||||||
#![warn(clippy::unnecessary_fallible_conversions)]
|
#![warn(clippy::unnecessary_fallible_conversions)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// --- TryFromMethod `T::try_from(u)` ---
|
||||||
|
|
||||||
let _: i64 = 0i32.into();
|
let _: i64 = 0i32.into();
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
let _: i64 = 0i32.into();
|
let _: i64 = 0i32.into();
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
|
// --- TryFromFunction `T::try_from(U)` ---
|
||||||
|
|
||||||
let _ = i64::from(0i32);
|
let _ = i64::from(0i32);
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
let _ = i64::from(0i32);
|
let _ = i64::from(0i32);
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
|
// --- TryIntoFunction `U::try_into(t)` ---
|
||||||
|
|
||||||
let _: i64 = i32::into(0);
|
let _: i64 = i32::into(0);
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
let _: i64 = i32::into(0i32);
|
let _: i64 = i32::into(0i32);
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
|
// --- TryFromFunction `<T as TryFrom<U>>::try_from(U)` ---
|
||||||
|
|
||||||
let _ = <i64 as From<i32>>::from(0);
|
let _ = <i64 as From<i32>>::from(0);
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
let _ = <i64 as From<i32>>::from(0);
|
let _ = <i64 as From<i32>>::from(0);
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
|
// --- TryIntoFunction `<U as TryInto<_>>::try_into(U)` ---
|
||||||
|
|
||||||
let _: i64 = <i32 as Into<_>>::into(0);
|
let _: i64 = <i32 as Into<_>>::into(0);
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
let _: i64 = <i32 as Into<_>>::into(0);
|
let _: i64 = <i32 as Into<_>>::into(0);
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,43 @@
|
|||||||
#![warn(clippy::unnecessary_fallible_conversions)]
|
#![warn(clippy::unnecessary_fallible_conversions)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// --- TryFromMethod `T::try_from(u)` ---
|
||||||
|
|
||||||
let _: i64 = 0i32.try_into().unwrap();
|
let _: i64 = 0i32.try_into().unwrap();
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
let _: i64 = 0i32.try_into().expect("can't happen");
|
let _: i64 = 0i32.try_into().expect("can't happen");
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
|
// --- TryFromFunction `T::try_from(U)` ---
|
||||||
|
|
||||||
let _ = i64::try_from(0i32).unwrap();
|
let _ = i64::try_from(0i32).unwrap();
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
let _ = i64::try_from(0i32).expect("can't happen");
|
let _ = i64::try_from(0i32).expect("can't happen");
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
|
// --- TryIntoFunction `U::try_into(t)` ---
|
||||||
|
|
||||||
let _: i64 = i32::try_into(0).unwrap();
|
let _: i64 = i32::try_into(0).unwrap();
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
let _: i64 = i32::try_into(0i32).expect("can't happen");
|
let _: i64 = i32::try_into(0i32).expect("can't happen");
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
|
// --- TryFromFunction `<T as TryFrom<U>>::try_from(U)` ---
|
||||||
|
|
||||||
let _ = <i64 as TryFrom<i32>>::try_from(0).unwrap();
|
let _ = <i64 as TryFrom<i32>>::try_from(0).unwrap();
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
let _ = <i64 as TryFrom<i32>>::try_from(0).expect("can't happen");
|
let _ = <i64 as TryFrom<i32>>::try_from(0).expect("can't happen");
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
|
// --- TryIntoFunction `<U as TryInto<_>>::try_into(U)` ---
|
||||||
|
|
||||||
let _: i64 = <i32 as TryInto<_>>::try_into(0).unwrap();
|
let _: i64 = <i32 as TryInto<_>>::try_into(0).unwrap();
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
|
|
||||||
let _: i64 = <i32 as TryInto<_>>::try_into(0).expect("can't happen");
|
let _: i64 = <i32 as TryInto<_>>::try_into(0).expect("can't happen");
|
||||||
|
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error: use of a fallible conversion when an infallible one could be used
|
error: use of a fallible conversion when an infallible one could be used
|
||||||
--> $DIR/unnecessary_fallible_conversions.rs:4:23
|
--> $DIR/unnecessary_fallible_conversions.rs:6:23
|
||||||
|
|
|
|
||||||
LL | let _: i64 = 0i32.try_into().unwrap();
|
LL | let _: i64 = 0i32.try_into().unwrap();
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
@ -14,7 +14,7 @@ LL + let _: i64 = 0i32.into();
|
|||||||
|
|
|
|
||||||
|
|
||||||
error: use of a fallible conversion when an infallible one could be used
|
error: use of a fallible conversion when an infallible one could be used
|
||||||
--> $DIR/unnecessary_fallible_conversions.rs:5:23
|
--> $DIR/unnecessary_fallible_conversions.rs:9:23
|
||||||
|
|
|
|
||||||
LL | let _: i64 = 0i32.try_into().expect("can't happen");
|
LL | let _: i64 = 0i32.try_into().expect("can't happen");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -27,7 +27,7 @@ LL + let _: i64 = 0i32.into();
|
|||||||
|
|
|
|
||||||
|
|
||||||
error: use of a fallible conversion when an infallible one could be used
|
error: use of a fallible conversion when an infallible one could be used
|
||||||
--> $DIR/unnecessary_fallible_conversions.rs:7:13
|
--> $DIR/unnecessary_fallible_conversions.rs:14:13
|
||||||
|
|
|
|
||||||
LL | let _ = i64::try_from(0i32).unwrap();
|
LL | let _ = i64::try_from(0i32).unwrap();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -40,7 +40,7 @@ LL + let _ = i64::from(0i32);
|
|||||||
|
|
|
|
||||||
|
|
||||||
error: use of a fallible conversion when an infallible one could be used
|
error: use of a fallible conversion when an infallible one could be used
|
||||||
--> $DIR/unnecessary_fallible_conversions.rs:8:13
|
--> $DIR/unnecessary_fallible_conversions.rs:17:13
|
||||||
|
|
|
|
||||||
LL | let _ = i64::try_from(0i32).expect("can't happen");
|
LL | let _ = i64::try_from(0i32).expect("can't happen");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -53,7 +53,7 @@ LL + let _ = i64::from(0i32);
|
|||||||
|
|
|
|
||||||
|
|
||||||
error: use of a fallible conversion when an infallible one could be used
|
error: use of a fallible conversion when an infallible one could be used
|
||||||
--> $DIR/unnecessary_fallible_conversions.rs:10:18
|
--> $DIR/unnecessary_fallible_conversions.rs:22:18
|
||||||
|
|
|
|
||||||
LL | let _: i64 = i32::try_into(0).unwrap();
|
LL | let _: i64 = i32::try_into(0).unwrap();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -66,7 +66,7 @@ LL + let _: i64 = i32::into(0);
|
|||||||
|
|
|
|
||||||
|
|
||||||
error: use of a fallible conversion when an infallible one could be used
|
error: use of a fallible conversion when an infallible one could be used
|
||||||
--> $DIR/unnecessary_fallible_conversions.rs:11:18
|
--> $DIR/unnecessary_fallible_conversions.rs:25:18
|
||||||
|
|
|
|
||||||
LL | let _: i64 = i32::try_into(0i32).expect("can't happen");
|
LL | let _: i64 = i32::try_into(0i32).expect("can't happen");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -79,7 +79,7 @@ LL + let _: i64 = i32::into(0i32);
|
|||||||
|
|
|
|
||||||
|
|
||||||
error: use of a fallible conversion when an infallible one could be used
|
error: use of a fallible conversion when an infallible one could be used
|
||||||
--> $DIR/unnecessary_fallible_conversions.rs:13:13
|
--> $DIR/unnecessary_fallible_conversions.rs:30:13
|
||||||
|
|
|
|
||||||
LL | let _ = <i64 as TryFrom<i32>>::try_from(0).unwrap();
|
LL | let _ = <i64 as TryFrom<i32>>::try_from(0).unwrap();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -92,7 +92,7 @@ LL + let _ = <i64 as From<i32>>::from(0);
|
|||||||
|
|
|
|
||||||
|
|
||||||
error: use of a fallible conversion when an infallible one could be used
|
error: use of a fallible conversion when an infallible one could be used
|
||||||
--> $DIR/unnecessary_fallible_conversions.rs:14:13
|
--> $DIR/unnecessary_fallible_conversions.rs:33:13
|
||||||
|
|
|
|
||||||
LL | let _ = <i64 as TryFrom<i32>>::try_from(0).expect("can't happen");
|
LL | let _ = <i64 as TryFrom<i32>>::try_from(0).expect("can't happen");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -105,7 +105,7 @@ LL + let _ = <i64 as From<i32>>::from(0);
|
|||||||
|
|
|
|
||||||
|
|
||||||
error: use of a fallible conversion when an infallible one could be used
|
error: use of a fallible conversion when an infallible one could be used
|
||||||
--> $DIR/unnecessary_fallible_conversions.rs:16:18
|
--> $DIR/unnecessary_fallible_conversions.rs:38:18
|
||||||
|
|
|
|
||||||
LL | let _: i64 = <i32 as TryInto<_>>::try_into(0).unwrap();
|
LL | let _: i64 = <i32 as TryInto<_>>::try_into(0).unwrap();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -118,7 +118,7 @@ LL + let _: i64 = <i32 as Into<_>>::into(0);
|
|||||||
|
|
|
|
||||||
|
|
||||||
error: use of a fallible conversion when an infallible one could be used
|
error: use of a fallible conversion when an infallible one could be used
|
||||||
--> $DIR/unnecessary_fallible_conversions.rs:17:18
|
--> $DIR/unnecessary_fallible_conversions.rs:41:18
|
||||||
|
|
|
|
||||||
LL | let _: i64 = <i32 as TryInto<_>>::try_into(0).expect("can't happen");
|
LL | let _: i64 = <i32 as TryInto<_>>::try_into(0).expect("can't happen");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
Loading…
Reference in New Issue
Block a user