Skip to content

new lint: unnecessary_faillible_conversion #11577

@sosthene-nitrokey

Description

@sosthene-nitrokey

What it does

This lint would warn against using try_into from the TryInto or TryFrom trait when there is an available Into or From implementation.

Advantage

Remove the need for handling an error case that can never happen (if there is a From impl, the Error case of the TryFrom impl is Infallible.

Drawbacks

No response

Example

let a: u32 = 32;
let b: Result<u64, Infaillible> = a.try_into();

Could be written as:

let a: u32 = 32;
let b: u64 = a.into();

Metadata

Metadata

Assignees

Labels

A-lintArea: New lints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions