fallible_int_fallback: cover unwrap_or_else + add UI test#1
Merged
Andrew Gazelka (andrewgazelka) merged 1 commit intoJun 5, 2026
Conversation
The lint already fired on .unwrap_or / .unwrap_or_default on a Result<_, TryFromIntError>; extend it to .unwrap_or_else, which silently substitutes a value the same way. Sharpen the message/help to say the default hides the overflow and how to fix it (propagate, explicit clamp, or allow-with-reason). Add a UI test covering all three methods plus the try_into() form, and negative cases (Option::unwrap_or, a non-int-error Result, an explicit min-then-cast). Drop a stray em dash and use Ty unqualified to satisfy the internal dogfood lint.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Lintcheck changes for 3112419
This comment will be updated if you push new changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Extends the existing
fallible_int_fallbackrestriction lint to also catch.unwrap_or_else(..)(it already caught.unwrap_or/.unwrap_or_default) on aResult<_, TryFromIntError>, since all three silently substitute a default for an out-of-range integer conversion.Result'sErrisTryFromIntError, soOption::unwrap_orand unrelatedResults are untouched#[allow]with a reason)try_into()form, with negative cases that must not fireTyunqualified for the internal dogfood lint)Validated locally on the pinned toolchain:
cargo buildclean,TESTNAME=fallible_int_fallback cargo uitestpasses (5 expected hits, 0 false positives).Made with Claude (Opus 4.8).
Note
Extend
fallible_int_fallbacklint to coverunwrap_or_elseand add UI testsunwrap_or_elseto the set of methods that trigger theFALLIBLE_INT_FALLBACKlint, alongsideunwrap_orandunwrap_or_default, when the receiver isResult<_, TryFromIntError>.Macroscope summarized 3112419.