We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e85c521 commit 21d66afCopy full SHA for 21d66af
src/tools/miri/src/clock.rs
@@ -43,7 +43,8 @@ impl Instant {
43
// `Duration` does not provide a nice constructor from a `u128` of nanoseconds,
44
// so we have to implement this ourselves.
45
// It is possible for second to overflow because u64::MAX < (u128::MAX / 1e9).
46
- let seconds = u64::try_from(duration.saturating_div(1_000_000_000)).unwrap();
+ // It will be saturated to u64::MAX seconds if the value after division exceeds u64::MAX.
47
+ let seconds = u64::try_from(duration / 1_000_000_000).unwrap_or(u64::MAX);
48
// It is impossible for nanosecond to overflow because u32::MAX > 1e9.
49
let nanosecond = u32::try_from(duration.wrapping_rem(1_000_000_000)).unwrap();
50
Duration::new(seconds, nanosecond)
0 commit comments