diff --git a/tokio/src/time/driver/mod.rs b/tokio/src/time/driver/mod.rs index cf2290bc3b9..99718774793 100644 --- a/tokio/src/time/driver/mod.rs +++ b/tokio/src/time/driver/mod.rs @@ -129,7 +129,7 @@ impl ClockTime { .unwrap_or_else(|| Duration::from_secs(0)); let ms = dur.as_millis(); - ms.try_into().expect("Duration too far into the future") + ms.try_into().unwrap_or(u64::MAX) } pub(self) fn tick_to_duration(&self, t: u64) -> Duration { diff --git a/tokio/tests/time_sleep.rs b/tokio/tests/time_sleep.rs index 20477d26bb7..97cadecb0a5 100644 --- a/tokio/tests/time_sleep.rs +++ b/tokio/tests/time_sleep.rs @@ -235,22 +235,6 @@ async fn long_sleeps() { assert!(tokio::time::Instant::now() <= deadline + Duration::from_millis(1)); } -#[tokio::test] -#[should_panic(expected = "Duration too far into the future")] -async fn very_long_sleeps() { - tokio::time::pause(); - - // Some platforms (eg macos) can't represent times this far in the future - if let Some(deadline) = tokio::time::Instant::now().checked_add(Duration::from_secs(1u64 << 62)) - { - tokio::time::sleep_until(deadline).await; - } else { - // make it pass anyway (we can't skip/ignore the test based on the - // result of checked_add) - panic!("Duration too far into the future (test ignored)") - } -} - #[tokio::test] async fn reset_after_firing() { let timer = tokio::time::sleep(std::time::Duration::from_millis(1));