RS.CLIPPY.UNNECESSARY_FALLIBLE_CONVERSIONS

Calling the `try_from` and `try_into` trait methods when `From`/`Into` is implemented

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: unnecessary_fallible_conversions. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for calls to TryInto::try_into and TryFrom::try_from when their infallible counterparts could be used.

Why is this bad?

In those cases, the TryInto and TryFrom trait implementation is a blanket impl that forwards to Into or From, which always succeeds. The returned Result<_, Infallible> requires error handling to get the contained value even though the conversion can never fail.

Example

let _: Result<i64, _> = 1i32.try_into();
let _: Result<i64, _> = <_>::try_from(1i32);

Use from/into instead:

let _: i64 = 1i32.into();
let _: i64 = <_>::from(1i32);