Skip to content

Conversation

@tgross35
Copy link
Contributor

@tgross35 tgross35 commented Jan 24, 2026

  • Add a note recommending benchmarks to cold_path, as other hints have
  • Note that cold_path can be used to implement likely and unlikely
  • Update the tracking issue for the likely_unlikely feature

Tracking issue: #136873
Tracking issue: #151619

@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 24, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 24, 2026

r? @scottmcm

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

Other hints have a note recommending benchmarks to ensure they actually
do what is intended. This is also applicable for `cold_path`, so add a
note here.
@tgross35 tgross35 changed the title hint: Add a recommendation to benchmark with cold_path Update documentation for cold_path, likely, and unlikely Jan 24, 2026
@jhpratt
Copy link
Member

jhpratt commented Jan 24, 2026

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 24, 2026

📌 Commit bdf5790 has been approved by jhpratt

It is now in the queue for this repository.

@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 Jan 24, 2026
Comment on lines 747 to 761
/// #[inline(always)]
/// pub const fn likely(b: bool) -> bool {
/// if b {
/// true
/// } else {
/// cold_path();
/// false
/// }
/// }
///
/// #[inline(always)]
/// pub const fn unlikely(b: bool) -> bool {
/// if b {
/// cold_path();
/// true
/// } else {
/// false
/// }
/// }
Copy link
Contributor

@traviscross traviscross Jan 24, 2026

Choose a reason for hiding this comment

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

Suggested change
/// #[inline(always)]
/// pub const fn likely(b: bool) -> bool {
/// if b {
/// true
/// } else {
/// cold_path();
/// false
/// }
/// }
///
/// #[inline(always)]
/// pub const fn unlikely(b: bool) -> bool {
/// if b {
/// cold_path();
/// true
/// } else {
/// false
/// }
/// }
/// #[inline(always)]
/// pub const fn likely(b: bool) -> bool {
/// if !b {
/// cold_path();
/// }
/// b
/// }
///
/// #[inline(always)]
/// pub const fn unlikely(b: bool) -> bool {
/// if b {
/// cold_path();
/// }
/// b
/// }

Or is there a reason to prefer the less-tight factoring?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, this is just our implementation in intrinsics. I’ll apply this.

@tgross35
Copy link
Contributor Author

@bors r-

For a chance to apply TC’s suggestion

@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 Jan 24, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 24, 2026

Commit bdf5790 has been unapproved.

@scottmcm
Copy link
Member

Doc update makes sense to me, and linking to #151619 is the right one

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 26, 2026

📌 Commit 6c0ae93 has been approved by scottmcm

It is now in the queue for this repository.

@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 Jan 26, 2026
rust-bors bot pushed a commit that referenced this pull request Jan 26, 2026
Rollup of 2 pull requests

Successful merges:

 - #151612 (Update documentation for `cold_path`, `likely`, and `unlikely`)
 - #151670 (compiletest: Parse aux `proc-macro` directive into struct)
Zalathar added a commit to Zalathar/rust that referenced this pull request Jan 26, 2026
Update documentation for `cold_path`, `likely`, and `unlikely`

* Add a note recommending benchmarks to `cold_path`, as other hints have
* Note that `cold_path` can be used to implement `likely` and `unlikely`
* Update the tracking issue for the `likely_unlikely` feature

Tracking issue: rust-lang#136873
Tracking issue: rust-lang#151619
@rust-bors rust-bors bot merged commit 443c5b0 into rust-lang:main Jan 26, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 26, 2026
rust-timer added a commit that referenced this pull request Jan 26, 2026
Rollup merge of #151612 - tgross35:cold-path-doc, r=scottmcm

Update documentation for `cold_path`, `likely`, and `unlikely`

* Add a note recommending benchmarks to `cold_path`, as other hints have
* Note that `cold_path` can be used to implement `likely` and `unlikely`
* Update the tracking issue for the `likely_unlikely` feature

Tracking issue: #136873
Tracking issue: #151619
@tgross35 tgross35 deleted the cold-path-doc branch January 26, 2026 19:41
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.

5 participants