1 | // FIXME: Branch prediction hint. This is currently only available on nightly |
2 | // but it consistently improves performance by 10-15%. |
3 | #[cfg (not(feature = "nightly" ))] |
4 | pub(crate) use core::convert::{identity as likely, identity as unlikely}; |
5 | #[cfg (feature = "nightly" )] |
6 | pub(crate) use core::intrinsics::{likely, unlikely}; |
7 | |
8 | // FIXME: use strict provenance functions once they are stable. |
9 | // Implement it with a transmute for now. |
10 | #[inline (always)] |
11 | #[allow (clippy::useless_transmute)] // clippy is wrong, cast and transmute are different here |
12 | pub(crate) fn invalid_mut<T>(addr: usize) -> *mut T { |
13 | unsafe { core::mem::transmute(src:addr) } |
14 | } |
15 | |