-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Reexport likely/unlikely in std::hint #133695
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @workingjubilee. Use |
This would need lang and libs-api to look over. I'd note that the discussion in the tracking issue seems to be saying that this is the wrong API. In particular a |
This comment has been minimized.
This comment has been minimized.
Yes, I agree with #26179 (comment) that I think the next step would be to create an ACP for |
Basically the current implementation gathers information about which code paths are cold, but this information is only used in select with 2 options. This was all I needed to fix likely and unlikely and I didn't want to make the PR bigger than needed. However common patterns in Rust generate select with more than 2 options. For example this code:
May generate something equivalent to:
|
This comment has been minimized.
This comment has been minimized.
"the compiler currently doesn't support the better option" sounds fixable. |
@workingjubilee I'm all for improving But And since there is RFC I thought they may already be approved |
If we had In any case you should file an ACP at https://github.com/rust-lang/libs-team/issues (it's just an issue template) for adding something new in
Given it was accepted about a decade ago, there is a good chance it would have to be revisited anyway :) |
@tgross35 I'd like to have both likely/unlikely and cold_path, because cold_path can sometimes be awkward. For example, I think:
is more readable than:
I'll look into the ACP and try to create one for all of these functions. |
I agree it's not the most convenient when you have one branch that you want to prioritize rather than deprioritizing all others, for either |
it might be useful to review https://blog.aaronballman.com/2020/08/dont-use-the-likely-or-unlikely-attributes/ which raises some relevant concerns. |
Since
likely
/unlikely
should be working now, we could reexport them instd::hint
. I'm not sure if this is already approved or if it requires approvalTracking issue: #26179