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

Assert the value returned by NonZero*::get being non-zero #119490

Closed
wants to merge 1 commit into from

Conversation

EFanZh
Copy link
Contributor

@EFanZh EFanZh commented Jan 1, 2024

I noticed that the values returned by NonZero*::get functions are not considered non-zero by the compiler, which could lead to bad code generation: https://godbolt.org/z/1Wcb9Po9f. This PR asserts the returned values being non-zero, which could improve code generation in certain situations, one of which being divide an integer by the sum of two smaller non-zero integers: https://godbolt.org/z/sa64xzeec.

@rustbot
Copy link
Collaborator

rustbot commented Jan 1, 2024

r? @Mark-Simulacrum

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

@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 Jan 1, 2024
@EFanZh EFanZh changed the title Assert the value returned NonZero*::get being non-zero Assert the value returned by NonZero*::get being non-zero Jan 1, 2024
@Nilstrieb
Copy link
Member

this is already being done in #119452

@Mark-Simulacrum
Copy link
Member

Going to go ahead and close in favor of that PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants