about summary refs log tree commit diff
diff options
context:
space:
mode:
authorthe8472 <the8472@users.noreply.github.com>2021-08-16 00:01:41 +0200
committerGitHub <noreply@github.com>2021-08-16 00:01:41 +0200
commit7256a6a86d10e51f47af994cb3f6fc0d68deebd1 (patch)
treec1d8d5efdf6e23f8cc6d95c26ce165a43aa11f89
parenta98a30976b5aeeb1a2d6145a6cec2544072d9b47 (diff)
downloadrust-7256a6a86d10e51f47af994cb3f6fc0d68deebd1.tar.gz
rust-7256a6a86d10e51f47af994cb3f6fc0d68deebd1.zip
Apply suggestions from code review
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
-rw-r--r--library/std/src/time/monotonic.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/time/monotonic.rs b/library/std/src/time/monotonic.rs
index 4f79b670a3a..d4572ee76be 100644
--- a/library/std/src/time/monotonic.rs
+++ b/library/std/src/time/monotonic.rs
@@ -34,14 +34,14 @@ pub mod inner {
         let packed = (secs << 32) | nanos;
         let old = MONO.load(Relaxed);
 
-        if packed == UNINITIALIZED || packed.wrapping_sub(old) < u64::MAX / 2 {
+        if old == UNINITIALIZED || packed.wrapping_sub(old) < u64::MAX / 2 {
             MONO.store(packed, Relaxed);
             raw
         } else {
             // Backslide occurred. We reconstruct monotonized time by assuming the clock will never
             // backslide more than 2`32 seconds which means we can reuse the upper 32bits from
             // the seconds.
-            let secs = (secs & 0xffff_ffff << 32) | old >> 32;
+            let secs = (secs & 0xffff_ffff_0000_0000) | old >> 32;
             let nanos = old as u32;
             ZERO.checked_add_duration(&Duration::new(secs, nanos)).unwrap()
         }