[!] Use rustc_inherit_overflow_checks in next_power_of_two
I believe the previous code was calling `ops::Add::add` instead of the `+` operator to get this behavior.
This commit is contained in:
parent
a29424a226
commit
c981d67b50
1 changed files with 2 additions and 3 deletions
|
|
@ -8,7 +8,6 @@ use crate::convert::Infallible;
|
|||
use crate::fmt;
|
||||
use crate::intrinsics;
|
||||
use crate::mem;
|
||||
use crate::ops;
|
||||
use crate::str::FromStr;
|
||||
|
||||
macro_rules! impl_nonzero_fmt {
|
||||
|
|
@ -4042,9 +4041,9 @@ assert_eq!(3", stringify!($SelfT), ".next_power_of_two(), 4);", $EndFeature, "
|
|||
```"),
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
pub fn next_power_of_two(self) -> Self {
|
||||
// Call the trait to get overflow checks
|
||||
ops::Add::add(self.one_less_than_next_power_of_two(), 1)
|
||||
self.one_less_than_next_power_of_two() + 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue