- Fix regression of literal out of range check for negative i64 value#25778
- Fix regression of literal out of range check for negative i64 value#25778bors merged 1 commit intorust-lang:masterfrom
Conversation
…s which was introduced by commit 7b1916d. - Add missing test cases to test/compile-fail/lint-type-overflow.rs which would have detected the regression.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
I don't think this is really true, but that quibble is not going to block this PR. (The |
|
@bors r+ |
|
📌 Commit 43502ad has been approved by |
A regression was introduced by commit 7b1916d #25612. Negative signed integer literals less than -9223372036854775808i64 were no longer properly reported as #[warn(overflowing_literals)]. Also adding missing test cases to test/compile-fail/lint-type-overflow.rs which could have detected the regression. Further explanation: The expression `(negative && v > max as u64 + 1)` relies on the fact that algebraically speaking `-min == max + 1` to avoid negation and removing the need for `min` completely. If i128 or i256 are ever added, it should also work for these types without requiring a change to `min != i64::MIN &&` also simplifying maintenance. r? @pnkfelix
A regression was introduced by commit 7b1916d #25612. Negative signed integer literals less than -9223372036854775808i64 were no longer properly reported as #[warn(overflowing_literals)].
Also adding missing test cases to test/compile-fail/lint-type-overflow.rs which could have detected the regression.
Further explanation:
The expression
(negative && v > max as u64 + 1)relies on the fact that algebraically speaking-min == max + 1to avoid negation and removing the need formincompletely.If i128 or i256 are ever added, it should also work for these types without requiring a change to
min != i64::MIN &&also simplifying maintenance.r? @pnkfelix