-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Lint suggesting use of TryFrom for checked integer conversion #3947
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
Labels
A-lint
Area: New lints
L-complexity
Lint: Belongs in the complexity lint group
L-style
Lint: Belongs in the style lint group
Comments
pJunger
added a commit
to pJunger/rust-clippy
that referenced
this issue
May 4, 2019
pJunger
added a commit
to pJunger/rust-clippy
that referenced
this issue
May 12, 2019
pJunger
added a commit
to pJunger/rust-clippy
that referenced
this issue
May 14, 2019
bors
added a commit
that referenced
this issue
May 17, 2019
Added lint for TryFrom for checked integer conversion. works towards #3947 Added lint for try_from for checked integer conversion. Should recognize simple & straight-forward checked integer conversions.
pJunger
added a commit
to pJunger/rust-clippy
that referenced
this issue
May 18, 2019
bors
added a commit
that referenced
this issue
May 20, 2019
Added lint for TryFrom for checked integer conversion. works towards #3947 Added lint for try_from for checked integer conversion. Should recognize simple & straight-forward checked integer conversions.
So now that the simple check is merged, the next steps that I can see would be something like this:
Regarding 1:Simple transformations:
or a transformation for the current rustfix solution
into
Questions:
Regarding 2:Questions:
What do you think? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-lint
Area: New lints
L-complexity
Lint: Belongs in the complexity lint group
L-style
Lint: Belongs in the style lint group
Checked integer conversion code has historically looked something like this:
But now that TryFrom is stable, it can be done in a more foolproof way like this:
It'd be cool if there was a lint guiding users to migrate their code.
The text was updated successfully, but these errors were encountered: