about summary refs log tree commit diff
diff options
context:
space:
mode:
authorivan-shrimp <70307174+ivan-shrimp@users.noreply.github.com>2024-05-12 11:29:24 +0800
committerivan-shrimp <70307174+ivan-shrimp@users.noreply.github.com>2024-05-12 11:29:24 +0800
commit7fde7308bf751315e0f4fabe32258916b166e34e (patch)
treea0963b83c1a3d2d008b4bd7c6f4435839df04bfa
parentfe03fb95695059809e75283cf84ad4c88e0ee656 (diff)
downloadrust-7fde7308bf751315e0f4fabe32258916b166e34e.tar.gz
rust-7fde7308bf751315e0f4fabe32258916b166e34e.zip
reverse condition in `uN::checked_sub`
-rw-r--r--library/core/src/num/uint_macros.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs
index 48a96c5792c..446d0658c12 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
             }
         }