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

fix: overflowing bin hex #136424

Merged
merged 1 commit into from
Feb 28, 2025
Merged

fix: overflowing bin hex #136424

merged 1 commit into from
Feb 28, 2025

Conversation

11happy
Copy link
Contributor

@11happy 11happy commented Feb 2, 2025

Overview:

Testing

  • Tested the updated functionality.
  • previously emitted diagnostics:
error: literal out of range for `i32`
 --> src/main.rs:2:9
  |
2 |     _ = 0x8FFF_FFFF_FFFF_FFFE;
  |         ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32`
  = help: consider using the type `i128` instead
  = note: `#[deny(overflowing_literals)]` on by default
help: to use as a negative number (decimal `-2`), consider using the type `u32` for the literal and cast it to `i32`
  |
2 |     _ = 0x8FFF_FFFF_FFFF_FFFEu32 as i32;
  |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • current diagnostics:
error: literal out of range for `i32`
 --> ../temp.rs:2:13
  |
2 |     let x = 0x8FFF_FFFF_FFFF_FFFE;
  |             ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32`
  = help: consider using the type `u64` instead
  = note: `#[deny(overflowing_literals)]` on by default
help: to use as a negative number (decimal `-2`), consider using the type `u64` for the literal and cast it to `i32`
  |
2 |     let x = 0x8FFF_FFFF_FFFF_FFFEu64 as i32;
  |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@rustbot
Copy link
Collaborator

rustbot commented Feb 2, 2025

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @fmease (or someone else) some time within the next two weeks.

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 Feb 2, 2025
@rust-log-analyzer

This comment has been minimized.

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2025
@s-cerevisiae
Copy link
Contributor

s-cerevisiae commented Feb 3, 2025

You are expected to fix the test affected by your change, in this case tests/ui/lint/type-overflow.rs.

Please refer to the rustc dev guide for instructions on how to write, run and change test files.

Btw I left a //~| HELP case empty in line 44 of that file because of the issue you are fixing, you may add the corresponding overflowing_bin_hex help message there so that it's fully tested :3

@vayunbiyani
Copy link
Contributor

@11happy I added a PR to bless the test case, you could please merge it?

@11happy
Copy link
Contributor Author

11happy commented Feb 9, 2025

@s-cerevisiae I have fixed the test case & added another one as well wherer earlier response was incorrect.
Thank you

@11happy
Copy link
Contributor Author

11happy commented Feb 9, 2025

@vayunbiyani you could perhaps ask the respective maintainers to merge your corresponding PR, I don't have merge rights.
Thank you

@vayunbiyani
Copy link
Contributor

The PR is on your fork so you should be good to do so!

@11happy
Copy link
Contributor Author

11happy commented Feb 9, 2025

The PR is on your fork so you should be good to do so!

Thank you for the PR I have integrated those changes.

@bors
Copy link
Contributor

bors commented Feb 11, 2025

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

@11happy
Copy link
Contributor Author

11happy commented Feb 16, 2025

Humble Ping! @s-cerevisiae I have also fixed the merge conflict.
Thank you

@rust-log-analyzer

This comment has been minimized.

@fmease
Copy link
Member

fmease commented Feb 25, 2025

@11happy The CI is failing because #136958 & #137348 tweaked the appearance of certain structured suggestions. You simply need to rebase & rebless tests/ui/lint/type-overflow.rs (e.g., via ./x t tests/ui/lint/type-overflow.rs --bless if you're on Linux (see the rustc dev guide for more options)).

Please also squash the two commits into a single one (since the diff is pretty small).

The Signed-off-by field is okay (tho it doesn't bear any specific meaning in the Rust project IINM). Regarding @vayunbiyani's patch you incorporated, I was a bit surprised to see the original authorship information removed. I'm not entirely sure if authorship attribution is necessary in this specific case since the change by [@]vayunbiyani is likely to be considered trivial wrt. to copyright law (IANAL). Anyway, no big deal but you could consider using Co-authored-by: in such cases in the future :)

Humble Ping! [@]s-cerevisiae I have also fixed the merge conflict.

([@]s-cerevisiae is not an official r-l/r reviewer)

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After that though, we're good to go! Thanks for working on this

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Feb 28, 2025
@rustbot

This comment has been minimized.

@rustbot rustbot removed the has-merge-commits PR has merge commits, merge with caution. label Feb 28, 2025
Signed-off-by: 11happy <soni5happy@gmail.com>

rebase

Signed-off-by: 11happy <soni5happy@gmail.com>

fix: rebless

Signed-off-by: 11happy <soni5happy@gmail.com>
@11happy
Copy link
Contributor Author

11happy commented Feb 28, 2025

Thanks @fmease , I have reblessed & rebased the commits as well. Thank you for providing me opportunity to work on this, I am new to this rust community, interested to learn & contribute.

@fmease
Copy link
Member

fmease commented Feb 28, 2025

Thank you and welcome!
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 28, 2025

📌 Commit dbf8fe0 has been approved by fmease

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 28, 2025
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 28, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 28, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang#136424 (fix: overflowing bin hex)
 - rust-lang#136824 (solver cycles are coinductive once they have one coinductive step)
 - rust-lang#137220 (Support `rust.channel = "auto-detect"`)
 - rust-lang#137712 (Clean up TypeckResults::extract_binding_mode)
 - rust-lang#137713 (Fix enzyme build errors)
 - rust-lang#137748 (Fix method name in `TyCtxt::hir_crate()` documentation)
 - rust-lang#137778 (update enzyme to handle range metadata)
 - rust-lang#137780 (Fix typo in query expansion documentation)
 - rust-lang#137788 (Bump `rustc_{codegen_ssa,llvm}` `cc` to 1.2.16 to fix `x86` Windows jobs on newest Windows SDK)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 743f26d into rust-lang:master Feb 28, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Feb 28, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 28, 2025
Rollup merge of rust-lang#136424 - 11happy:overflow.hex.fix, r=fmease

fix: overflowing bin hex

**Overview:**
- This PR fixes rust-lang#135404.

**Testing**
- Tested the updated functionality.
- previously emitted diagnostics:
```bash
error: literal out of range for `i32`
 --> src/main.rs:2:9
  |
2 |     _ = 0x8FFF_FFFF_FFFF_FFFE;
  |         ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32`
  = help: consider using the type `i128` instead
  = note: `#[deny(overflowing_literals)]` on by default
help: to use as a negative number (decimal `-2`), consider using the type `u32` for the literal and cast it to `i32`
  |
2 |     _ = 0x8FFF_FFFF_FFFF_FFFEu32 as i32;
  |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ```
- current diagnostics:
```bash
error: literal out of range for `i32`
 --> ../temp.rs:2:13
  |
2 |     let x = 0x8FFF_FFFF_FFFF_FFFE;
  |             ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32`
  = help: consider using the type `u64` instead
  = note: `#[deny(overflowing_literals)]` on by default
help: to use as a negative number (decimal `-2`), consider using the type `u64` for the literal and cast it to `i32`
  |
2 |     let x = 0x8FFF_FFFF_FFFF_FFFEu64 as i32;
  |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
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.

Wrong type suggested in overflowing_bin_hex
7 participants