Skip to content
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

lint identity_conversion could be extended to work with try_from/try_into #5344

Closed
tmpolaczyk opened this issue Mar 19, 2020 · 0 comments · Fixed by #5631
Closed

lint identity_conversion could be extended to work with try_from/try_into #5344

tmpolaczyk opened this issue Mar 19, 2020 · 0 comments · Fixed by #5631
Labels
A-documentation Area: Adding or improving documentation A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-complexity Lint: Belongs in the complexity lint group

Comments

@tmpolaczyk
Copy link

The following code doesn't warn about the useless conversion from u8 to u8:

let a = 0u8;
let b = u8::try_from(a).unwrap();

Playground link

The identity_conversion lint currently only supports the traits Into, From, and FromIter. I think it should be simple and useful to extend it to also work with TryFrom and TryInto.

An alternative would be a new lint to warn on usages of try_from when from is enough, but I'm not sure how can that be implemented.

@flip1995 flip1995 added L-complexity Lint: Belongs in the complexity lint group good-first-issue These issues are a good way to get started with Clippy A-documentation Area: Adding or improving documentation A-lint Area: New lints labels Mar 19, 2020
@bors bors closed this as completed in ee3088f May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documentation Area: Adding or improving documentation A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-complexity Lint: Belongs in the complexity lint group
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants