Skip to content

use cfg!(overflow_checks) in overflow_checks intrinsic instead of cfg!(debug_assertions) - #166295

Open
BioTomateDE wants to merge 1 commit into
rust-lang:mainfrom
BioTomateDE:intrinsics-stuff
Open

BioTomateDE wants to merge 1 commit into
rust-lang:mainfrom
BioTomateDE:intrinsics-stuff

Conversation

@BioTomateDE

@BioTomateDE BioTomateDE commented Nov 21, 2026 •

Copy link
Copy Markdown

The fallback implementation of the overflow_checks() intrinsic is currently defined as:

#[rustc_intrinsic]
pub const fn overflow_checks() -> bool {
    cfg!(debug_assertions)
}

This seems to be an oversight from copypasting. Its docs state:

This eventually evaluates cfg!(overflow_checks)

I changed its fallback body to cfg!(overflow_checks).

If this is somehow intended behavior, I'd put a comment stating that this cfg! is intentionally debug_assertions instead of overflow_checks.
Note: The overflow_checks cfg is currently unstable, tracked at #111466.

Also see https://discord.com/channels/273534239310479360/957720175619215380/1573547547379765341.

@rustbot

rustbot commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@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 Nov 21, 2026
@rustbot

rustbot commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @JohnTitor (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

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

@BioTomateDE

Copy link
Copy Markdown
Author

As per request: @theemathas

@theemathas

Copy link
Copy Markdown
Contributor

For context, I had an LLM do some investigation. It found the following, which I confirmed to be accurate.

So, I concluded that the fact that the overflow_checks intrinsic falls back to cfg!(debug_assertions) was an oversight.

cc @pitaj (author of #128666)

@rust-log-analyzer

This comment has been minimized.

@BioTomateDE

Copy link
Copy Markdown
Author

Another small thing I found: the const_allocate and const_make_global intrinsics are locked behind the const_heap feature-gate (#79597), but const_deallocate is locked behind core_intrinsics. Not sure if this is intended, just thought I'd point it out.

@thomcc

thomcc commented Nov 21, 2026

Copy link
Copy Markdown
Member

Do you mind splitting the docs change into another PR? (This PR has @theemathas's investigation of the overflow_checks change, so let's keep that here). You can request my review on the docs one with r? @thomcc.

@BioTomateDE BioTomateDE changed the title Fix fallback impl of overflow_checks intrinsic and slightly improve docs Fix fallback impl of overflow_checks intrinsic Nov 21, 2026
@rust-log-analyzer

This comment has been minimized.

@thomcc

thomcc commented Nov 21, 2026

Copy link
Copy Markdown
Member

Given the investigation above,

@bors r+

@rust-bors

rust-bors Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

❌ Cannot approve commit 01d4cf3, because CI currently fails on this PR. Use @bors r+ force to override the PR CI check.

@thomcc

thomcc commented Nov 21, 2026

Copy link
Copy Markdown
Member

Tomorrow I'll check and see if this is passing CI and approve it then if it is.

r? @thomcc

@rustbot rustbot assigned thomcc and unassigned JohnTitor Nov 21, 2026
@theemathas

Copy link
Copy Markdown
Contributor

@thomcc We can now approve PRs before CI is finished. This will cause the PR to be "tentatively approved", and it will automatically become actually approved when CI passes.

@bors r=thomcc

@rust-bors

rust-bors Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 7eca63a has been tentatively approved by thomcc

It will be put into the queue for this repository once PR CI succeeds.

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

Reason for tree closure: repeated failures in dist-x86_64-msvc

@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 Nov 21, 2026
@RalfJung RalfJung changed the title Fix fallback impl of overflow_checks intrinsic use cfg!(overflow_checks) in overflow_checks intrinsic instead of cfg!(debug_assertions) Nov 21, 2026
@RalfJung

Copy link
Copy Markdown
Member

@bors squash

@rust-bors

This comment has been minimized.

… `cfg!(debug_assertions)`

* use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of
`cfg!(debug_assertions)`
* add missing `cfg_overflow_checks` feature
@rust-bors rust-bors Bot 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 21, 2026
@rust-bors
rust-bors Bot force-pushed the intrinsics-stuff branch from 7eca63a to f9becad Compare November 21, 2026 09:32
@rust-bors

rust-bors Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

🔨 2 commits were squashed into f9becad.

This pull request was unapproved.

@RalfJung

Copy link
Copy Markdown
Member

No need to have two commits for such a small change.
@bors r=thomcc

@rust-bors

rust-bors Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit f9becad has been tentatively approved by thomcc

It will be put into the queue for this repository once PR CI succeeds.

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

Reason for tree closure: repeated failures in dist-x86_64-msvc

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 21, 2026

This branch has not been deployed

No deployments
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.

7 participants