Add error-annotations in tests for unnecessary_fallible_conversions
This commit is contained in:
parent
094ce3de3e
commit
1cce757672
3 changed files with 60 additions and 10 deletions
|
|
@ -1,18 +1,43 @@
|
|||
#![warn(clippy::unnecessary_fallible_conversions)]
|
||||
|
||||
fn main() {
|
||||
// --- TryFromMethod `T::try_from(u)` ---
|
||||
|
||||
let _: i64 = 0i32.into();
|
||||
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||
|
||||
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);
|
||||
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||
|
||||
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);
|
||||
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||
|
||||
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);
|
||||
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||
|
||||
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);
|
||||
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||
|
||||
let _: i64 = <i32 as Into<_>>::into(0);
|
||||
//~^ ERROR: use of a fallible conversion when an infallible one could be used
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue