Files
rust/library/core/src
Jonathan Brouwer 27d6b3c9b7 Rollup merge of #151576 - tgross35:stabilize-cold-path, r=jhpratt
Stabilize `core::hint::cold_path`

`cold_path` has been around unstably for a while and is a rather useful tool to have. It does what it is supposed to and there are no known remaining issues, so stabilize it here (including const).

Newly stable API:

```rust
// in core::hint
pub const fn cold_path();
```

I have opted to exclude `likely` and `unlikely` for now since they have had some concerns about ease of use that `cold_path` doesn't suffer from. `cold_path` is also significantly more flexible; in addition to working with boolean `if` conditions, it can be used in `match` arms, `if let`, closures, and other control flow blocks. `likely` and `unlikely` are also possible to implement in user code via `cold_path`, if desired.

Closes: https://github.com/rust-lang/rust/issues/136873 (tracking issue)

---

There has been some design and implementation work for making `#[cold]` function in more places, such as `if` arms, `match` arms, and closure bodies. Considering a stable `cold_path` will cover all of these usecases, it does not seem worth pursuing a more powerful `#[cold]` as an alternative way to do the same thing. If the lang team agrees, then:

Closes: https://github.com/rust-lang/rust/issues/26179
Closes: https://github.com/rust-lang/rust/pull/120193
2026-02-07 13:06:35 +01:00
..
2026-01-27 21:15:27 +03:00
2025-11-11 23:46:10 +03:00
fix
2025-11-27 17:55:34 +07:00
2026-01-25 17:30:39 +00:00
2026-01-30 15:52:40 +00:00
2026-01-29 20:26:06 +02:00
2026-01-26 17:08:00 +00:00
2025-09-01 21:38:26 -04:00
2026-02-02 19:47:32 +01:00
2026-01-27 21:15:27 +03:00
2025-10-20 12:20:15 -06:00
2026-01-23 15:12:47 +07:00
2025-09-07 21:16:35 -07:00
2025-12-18 19:07:49 -08:00
2025-06-15 22:08:41 +02:00
2026-01-26 13:43:06 -06:00
2025-11-12 14:33:41 +01:00