From 74e70765ad397418294d357b97f6b87d8a13fe7f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 24 Jan 2026 13:28:39 -0600 Subject: [PATCH] hint: Add a recommendation to benchmark with `cold_path` 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. --- library/core/src/hint.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index 4c050b49bf7e..bf8bbd12d82a 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -708,6 +708,10 @@ pub const fn unlikely(b: bool) -> bool { /// Hints to the compiler that given path is cold, i.e., unlikely to be taken. The compiler may /// choose to optimize paths that are not cold at the expense of paths that are cold. /// +/// Note that like all hints, the exact effect to codegen is not guaranteed. Using `cold_path` +/// can actually *decrease* performance if the branch is called more than expected. It is advisable +/// to perform benchmarks to tell if this function is useful. +/// /// # Examples /// /// ```