Skip to content

Fix panic in lint for out of range literals #25612

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 21, 2015

Conversation

petrochenkov
Copy link
Contributor

Reported here #25441 (comment)

@rust-highfive
Copy link
Contributor

r? @nrc

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

@bors: r+ 0ec7d77

Thanks!

@bors
Copy link
Collaborator

bors commented May 19, 2015

☔ The latest upstream changes (presumably #24333) made this pull request unmergeable. Please resolve the merge conflicts.

@petrochenkov
Copy link
Contributor Author

Rebased

@nrc
Copy link
Member

nrc commented May 20, 2015

@bors r=@alexcrichton

@bors
Copy link
Collaborator

bors commented May 20, 2015

📌 Commit 7b1916d has been approved by @alexcrichton

@bors
Copy link
Collaborator

bors commented May 21, 2015

⌛ Testing commit 7b1916d with merge 9ee4ead...

bors added a commit that referenced this pull request May 21, 2015
@bors bors merged commit 7b1916d into rust-lang:master May 21, 2015
bors added a commit that referenced this pull request May 26, 2015
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
@petrochenkov petrochenkov deleted the lintabs branch May 26, 2015 22:05
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants