about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbyt <55319043+tiif@users.noreply.github.com>2024-06-09 17:59:06 +0800
committertiif <pekyuan@gmail.com>2024-06-09 18:00:58 +0800
commitd0fb350b6adaebfe342ddadb220baa415ab29824 (patch)
tree132d97d6972cf81661b7ba32a41711ded7b08d38
parentaa8323585cf3b8846b4dd83f48404a26f7df63c9 (diff)
Add comment for u128 to u64 conversion.
Co-authored-by: Ralf Jung <post@ralfj.de>
-rw-r--r--src/tools/miri/src/clock.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/tools/miri/src/clock.rs b/src/tools/miri/src/clock.rs
index b8d0c847069..2ace9b66de7 100644
--- a/src/tools/miri/src/clock.rs
+++ b/src/tools/miri/src/clock.rs
@@ -40,6 +40,8 @@ impl Instant {
                 InstantKind::Virtual { nanoseconds: earlier },
             ) => {
                 let duration = nanoseconds.saturating_sub(earlier);
+                // `Duration` does not provide a nice constructor from a `u128` of nanoseconds,
+                // so we have to implement this ourselves.
                 // It is possible for second to overflow because u64::MAX < (u128::MAX / 1e9).
                 let seconds = u64::try_from(duration.saturating_div(1_000_000_000)).unwrap();
                 // It is impossible for nanosecond to overflow because u32::MAX > 1e9.