Skip to content

Conversation

clarfonthey
Copy link
Contributor

@clarfonthey clarfonthey commented Aug 27, 2025

Tracking issue: #145938

Since constants don't actually care about branch prediction, this just uses const_eval_select to use a normal if statement in const-time, instead of having to make the intrinsic work in const context.

Blocked by #146187.

@rustbot
Copy link
Collaborator

rustbot commented Aug 27, 2025

r? @tgross35

rustbot has assigned @tgross35.
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

@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 Aug 27, 2025
@clarfonthey clarfonthey changed the title const `select_unpredictable const select_unpredictable Aug 27, 2025
@rust-log-analyzer

This comment has been minimized.

@clarfonthey
Copy link
Contributor Author

@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 28, 2025
@bors
Copy link
Collaborator

bors commented Aug 31, 2025

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

@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2025

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
Copy link
Collaborator

rustbot commented Oct 15, 2025

This PR was rebased onto a different master 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.

@clarfonthey
Copy link
Contributor Author

@rustbot ready

Should be good, but will fix if CI shows up with any weird issues. Now that ptr::drop_in_place works in const context, we can just mark this method and its corresponding intrinsic as const. I also updated the existing test to test both at runtime and const-time, so that we verify that the drop behaviour is consistent across both.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Oct 15, 2025
@clarfonthey clarfonthey force-pushed the const-select-unpredictable branch from c6f7eab to 003a538 Compare October 15, 2025 00:37
let _selected = core::hint::select_unpredictable(core::hint::black_box(true), a, b);
assert!(!a_dropped);
assert!(b_dropped);
// FIXME(const-hack): use drop(selected) instead of a scope here
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't want to block this on #147708 but I'll update this depending on which one gets merged first.

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.

6 participants