Skip to content

Commit cc87909

Browse files
authored
Rollup merge of #139726 - Amanieu:select_unpredictable_hint, r=dtolnay
Move `select_unpredictable` to the `hint` module There has been considerable discussion in both the ACP (rust-lang/libs-team#468) and tracking issue (#133962) about whether the `bool::select_unpredictable` method should be in `core::hint` instead. I believe this is the right move for the following reasons: - The documentation explicitly says that it is a hint, not a codegen guarantee. - `bool` doesn't have a corresponding `select` method, and I don't think we should be adding one. - This shouldn't be something that people reach for with auto-completion unless they specifically understand the interactions with branch prediction. Using conditional moves can easily make code *slower* by preventing the CPU from speculating past the condition due to the data dependency. - Although currently `core::hint` only contains no-ops, this isn't a hard rule (for example `unreachable_unchecked` is a bit of a gray area). The documentation only status that the module contains "hints to compiler that affects how code should be emitted or optimized". This is consistent with what `select_unpredictable` does.
2 parents 7f4e654 + 2c319b3 commit cc87909

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)