Skip to content
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

Add casting suggestion when assigning negative 2's complement bin or hex literal to a size compatible signed integer #111212

Merged
merged 2 commits into from
Jun 15, 2023

Conversation

nicklimmm
Copy link
Contributor

Fixes #107896

The issue stated the case for iX::MIN variants. This PR extends the cases for other negative values (in the 2's complement).

Leveraged sign bits to detect such cases.

Example cases:

  • image
  • image
  • image

@rustbot
Copy link
Collaborator

rustbot commented May 4, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @TaKO8Ki (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 4, 2023
@rust-log-analyzer

This comment has been minimized.

@nicklimmm nicklimmm marked this pull request as ready for review May 5, 2023 05:47
@nicklimmm
Copy link
Contributor Author

r? compiler

@rustbot rustbot assigned davidtwco and unassigned TaKO8Ki May 22, 2023
@nicklimmm
Copy link
Contributor Author

r? compiler

@rustbot rustbot assigned compiler-errors and unassigned davidtwco Jun 11, 2023
@pnkfelix
Copy link
Member

The logic here seems good to me.

The only question I asked myself was whether we want to be pushing people towards using as-casts or not. (They can be an anti-pattern sometimes because they are such a heavy hammer.)

But I suspect this change does more good than potential harm, so lets land it.

@pnkfelix
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 15, 2023

📌 Commit 2113769 has been approved by pnkfelix

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 15, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 15, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#111212 (Add casting suggestion when assigning negative 2's complement bin or hex literal to a size compatible signed integer)
 - rust-lang#112304 (Add chapter in rustdoc book for re-exports and add a regression test for `#[doc(hidden)]` behaviour)
 - rust-lang#112486 (Fix suggestion for E0404 not dealing with multiple generics)
 - rust-lang#112562 (rustdoc-gui: allow running on Windows)
 - rust-lang#112621 (Mention `env!` in `option_env!`'s docs)
 - rust-lang#112634 (add InlineConst check)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f530016 into rust-lang:master Jun 15, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assinging to an i32 variable a binary representation of i32::MIN fails to compile
8 participants