Skip to content

new lint: unnecessary_faillible_conversion #11577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sosthene-nitrokey opened this issue Sep 28, 2023 · 1 comment · Fixed by #11669
Closed

new lint: unnecessary_faillible_conversion #11577

sosthene-nitrokey opened this issue Sep 28, 2023 · 1 comment · Fixed by #11669
Assignees
Labels
A-lint Area: New lints

Comments

@sosthene-nitrokey
Copy link

sosthene-nitrokey commented Sep 28, 2023

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();
@sosthene-nitrokey sosthene-nitrokey added the A-lint Area: New lints label Sep 28, 2023
@y21
Copy link
Member

y21 commented Oct 14, 2023

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants