rust/library
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
..
alloc Rollup merge of #148590 - GrigorenkoPV:atomic_try_update, r=jhpratt 2026-02-07 13:06:33 +01:00
alloctests Rollup merge of #151756 - Voultapher:fix-box-retag-in-sort, r=Mark-Simulacrum 2026-02-02 10:28:29 +11:00
backtrace@28ec93b503 Update backtrace 2026-01-26 10:57:35 +00:00
compiler-builtins Rollup merge of #151109 - tyhdefu:float_bits_const, r=tgross35 2026-02-03 21:58:39 +11:00
core Rollup merge of #151576 - tgross35:stabilize-cold-path, r=jhpratt 2026-02-07 13:06:35 +01:00
coretests feat: Implement int_from_ascii for NonZero<T> 2026-02-07 13:48:52 +09:00
panic_abort Use core via rustc-std-workspace-core in library/panic* 2025-07-31 22:47:24 +00:00
panic_unwind Fix new function_casts_as_integer lint errors in core, std, panic_unwind and compiler crates 2025-11-10 16:38:28 +01:00
portable-simd Merge commit 'd9aae8cc54' into sync-from-portable-simd-2026-01-28 2026-01-28 00:56:52 -05:00
proc_macro Auto merge of #151543 - GuillaumeGomez:more-proc-macro-literal-methods, r=Amanieu 2026-02-01 15:46:27 +00:00
profiler_builtins Fix profiler_builtins build script to handle full path to profiler lib 2025-04-11 16:57:38 +02:00
rtstartup Update cfg(bootstrap) 2025-07-01 10:55:49 -07:00
rustc-std-workspace-alloc Disable unit tests for stdlib packages that don't contain any 2025-07-24 09:15:28 +00:00
rustc-std-workspace-core Use core via rustc-std-workspace-core in library/panic* 2025-07-31 22:47:24 +00:00
rustc-std-workspace-std Disable unit tests for stdlib packages that don't contain any 2025-07-24 09:15:28 +00:00
std Rollup merge of #148590 - GrigorenkoPV:atomic_try_update, r=jhpratt 2026-02-07 13:06:33 +01:00
std_detect Replace version placeholders with 1.94 2026-01-20 21:17:10 -05:00
stdarch disable s390x vector intrinsics if softfloat is enabled 2026-02-05 13:36:18 +01:00
sysroot compiler-builtins: Remove the no-f16-f128 feature 2026-01-11 07:02:27 -06:00
test Rollup merge of #151383 - cyrgani:no-internal-deprecation, r=scottmcm 2026-01-27 12:50:52 +11:00
unwind Correct hexagon "unwinder_private_data_size" 2025-12-29 15:21:09 -06:00
windows_link Update windows bindings in std 2026-01-26 10:59:16 +00:00
Cargo.lock Rollup merge of #151660 - fmease:bump-backtrace-demangler-alt, r=tgross35 2026-01-28 21:10:51 +01:00
Cargo.toml Update windows bindings in std 2026-01-26 10:59:16 +00:00