handle exponent without digits in numeric_literal
#10914
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #10912
The numeric literal util module didn't check for exponents with no digits.
So:
rust-clippy/clippy_utils/src/numeric_literal.rs
Lines 163 to 168 in 384cf37
exponent
here would be the empty string, which passed the!= "0"
check (when it shouldn't have, it should probably be treated as if the user wroteE0
), then later fails when counting the digits and subtracting one (0 - 1 = overflow).Also, interestingly I can't even write a test for this because exponents with no digits is some kind of error by itself and
cargo dev fmt
fails on it.changelog: [
unreadable_literal
]: don't (debug) ICE on numeric literal with empty exponent