Skip to content

signed strict division: just use normal division#158483

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:signed-strict-div
Jul 1, 2026
Merged

signed strict division: just use normal division#158483
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:signed-strict-div

Conversation

@RalfJung

@RalfJung RalfJung commented Jun 27, 2026

Copy link
Copy Markdown
Member

For some reason, #116090 picked an unnecessarily complicated implementation for this. I don't know if there was any specific reason for this;. Cc @rmehri01 @m-ou-se in case someone remembers.

This was pointed out on IRLO: https://internals.rust-lang.org/t/why-is-strict-div-implemented-in-terms-of-overflowing-div-for-signed-integers/24387

Let's just use regular division here, which is consistent with what we do for unsigned types.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 27, 2026
@rustbot

rustbot commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from Darksonn, JohnTitor, Mark-Simulacrum, clarfonthey, jhpratt

@RalfJung RalfJung force-pushed the signed-strict-div branch 2 times, most recently from 9e095fa to 8e814f3 Compare June 27, 2026 12:13
@jhpratt

jhpratt commented Jun 27, 2026

Copy link
Copy Markdown
Member

r=me if there's no concerns. My suspicion is that this was written with #[rustc_inherit_overflow_checks] in mind even though it's not present here.

r? jhpratt

@rustbot rustbot assigned jhpratt and unassigned Mark-Simulacrum Jun 27, 2026
@scottmcm

Copy link
Copy Markdown
Member

The only thing that comes to mind is if someone was wanting it to panic for x / 0 but have overflow behaviour for INT_MIN / -1 -- but of course that's not how our division works today.

@RalfJung

RalfJung commented Jun 27, 2026

Copy link
Copy Markdown
Member Author

The only thing that comes to mind is if someone was wanting it to panic for x / 0 but have overflow behaviour for INT_MIN / -1 -- but of course that's not how our division works today.

That exists, it is called overflowing_div.

@rust-bors

This comment has been minimized.

@RalfJung RalfJung force-pushed the signed-strict-div branch from 8e814f3 to 10fb96c Compare June 27, 2026 21:13
@rustbot

rustbot commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@jhpratt

jhpratt commented Jul 1, 2026

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 10fb96c has been approved by jhpratt

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Jul 1, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 1, 2026
signed strict division: just use normal division

For some reason, rust-lang#116090 picked an unnecessarily complicated implementation for this. I don't know if there was any specific reason for this;. Cc @rmehri01 @m-ou-se in case someone remembers.

This was pointed out on IRLO: https://internals.rust-lang.org/t/why-is-strict-div-implemented-in-terms-of-overflowing-div-for-signed-integers/24387

Let's just use regular division here, which is consistent with what we do for unsigned types.
rust-bors Bot pushed a commit that referenced this pull request Jul 1, 2026
Rollup of 6 pull requests

Successful merges:

 - #157718 (Do not increase depth when evaluating nested goals of `NormalizesTo`)
 - #158449 (QNX target renaming)
 - #158483 (signed strict division: just use normal division)
 - #158516 ( Deduplicate codegen backends in bootstrap config)
 - #158542 (Rename `align` to `default_align` on `Scalar` and `Primitive`)
 - #158636 (linkchecker: upgrade to `html5ever v0.39`)
@rust-bors rust-bors Bot merged commit 933b5e7 into rust-lang:main Jul 1, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jul 1, 2026
rust-timer added a commit that referenced this pull request Jul 1, 2026
Rollup merge of #158483 - RalfJung:signed-strict-div, r=jhpratt

signed strict division: just use normal division

For some reason, #116090 picked an unnecessarily complicated implementation for this. I don't know if there was any specific reason for this;. Cc @rmehri01 @m-ou-se in case someone remembers.

This was pointed out on IRLO: https://internals.rust-lang.org/t/why-is-strict-div-implemented-in-terms-of-overflowing-div-for-signed-integers/24387

Let's just use regular division here, which is consistent with what we do for unsigned types.
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jul 2, 2026
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#157718 (Do not increase depth when evaluating nested goals of `NormalizesTo`)
 - rust-lang/rust#158449 (QNX target renaming)
 - rust-lang/rust#158483 (signed strict division: just use normal division)
 - rust-lang/rust#158516 ( Deduplicate codegen backends in bootstrap config)
 - rust-lang/rust#158542 (Rename `align` to `default_align` on `Scalar` and `Primitive`)
 - rust-lang/rust#158636 (linkchecker: upgrade to `html5ever v0.39`)
@RalfJung RalfJung deleted the signed-strict-div branch July 2, 2026 14:37
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-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants