diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 48a96c5792c64..446d0658c1262 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -584,11 +584,11 @@ macro_rules! uint_impl { // Thus, rather than using `overflowing_sub` that produces a wrapping // subtraction, check it ourself so we can use an unchecked one. - if self >= rhs { + if self < rhs { + None + } else { // SAFETY: just checked this can't overflow Some(unsafe { intrinsics::unchecked_sub(self, rhs) }) - } else { - None } }