@@ -3657,24 +3657,22 @@ declare_clippy_lint! {
3657
3657
}
3658
3658
3659
3659
declare_clippy_lint ! {
3660
- /// Looks for one of two kinds of expressions:
3661
- /// - Calling `<T as TryInto<U>> ::try_into` where `T` also implements `Into<U>`
3662
- /// - Calling `<T as TryFrom<U>>::try_from` where `T` also implements `From<U>`
3660
+ /// ### What it does
3661
+ /// Checks for calls to ` TryInto::try_into` and `TryFrom::try_from` when their infallible counterparts
3662
+ /// could be used.
3663
3663
///
3664
3664
/// ### Why is this bad?
3665
- /// In those cases, the `TryInto` and `TryFrom` trait implementation is a blanket impl which forwards
3665
+ /// In those cases, the `TryInto` and `TryFrom` trait implementation is a blanket impl that forwards
3666
3666
/// to `Into` or `From`, which always succeeds.
3667
- /// Indeed, its associated `Error` type is the empty enum `Infallible`,
3668
- /// which is impossible to construct by nature, so the error handling that is then imposed by
3669
- /// the `Result<_, Infallible>` is unnecessary and can be avoided simply by calling `.into()` or `::from`
3670
- /// directly in the first place.
3667
+ /// The returned `Result<_, Infallible>` requires error handling to get the contained value
3668
+ /// even though the conversion can never fail.
3671
3669
///
3672
3670
/// ### Example
3673
3671
/// ```rust
3674
3672
/// let _: Result<i64, _> = 1i32.try_into();
3675
3673
/// let _: Result<i64, _> = <_>::try_from(1i32);
3676
3674
/// ```
3677
- /// Use instead:
3675
+ /// Use `from`/`into` instead:
3678
3676
/// ```rust
3679
3677
/// let _: i64 = 1i32.into();
3680
3678
/// let _: i64 = <_>::from(1i32);
0 commit comments