diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 565fc1930ea4f..f2190efa4d3c9 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -2017,6 +2017,13 @@ macro_rules! uint_impl { one >>= 2; } + // SAFETY: the result is positive and fits in an integer with half as many bits. + // Inform the optimizer about it. + unsafe { + intrinsics::assume(0 < res); + intrinsics::assume(res < 1 << (Self::BITS / 2)); + } + res }