Skip to content

Commit

Permalink
chore: likely hints don't work on stable
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Sep 11, 2024
1 parent c81503c commit b2799b5
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,8 @@ cfg_if! {
};
}
} else {
// On stable we can use #[cold] to get a equivalent effect: this attribute
// suggests that the function is unlikely to be called
#[inline(always)]
#[cold]
#[allow(clippy::missing_const_for_fn)]
fn cold() {}

#[inline(always)]
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn likely(b: bool) -> bool {
if !b {
cold();
}
b
}

#[inline(always)]
#[allow(clippy::missing_const_for_fn)]
fn unlikely(b: bool) -> bool {
if b {
cold();
}
b
}
#[allow(unused_imports)]
use core::convert::{identity as likely, identity as unlikely};

macro_rules! maybe_const_assert {
($($tt:tt)*) => {
Expand Down

0 comments on commit b2799b5

Please sign in to comment.