From 8ec749a065cc7ec8f77f51f60737bc40c96ae9f9 Mon Sep 17 00:00:00 2001 From: ADD-SP Date: Sat, 7 Jun 2025 17:14:38 +0800 Subject: [PATCH] time: doc a missing panic scenario of `time::advance` --- tokio/src/time/clock.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tokio/src/time/clock.rs b/tokio/src/time/clock.rs index 83b87cac1b0..80d71b91219 100644 --- a/tokio/src/time/clock.rs +++ b/tokio/src/time/clock.rs @@ -185,8 +185,18 @@ cfg_test_util! { /// /// # Panics /// - /// Panics if time is not frozen or if called from outside of the Tokio - /// runtime. + /// Panics if any of the following conditions are met: + /// + /// - The clock is not frozen, which means that you must + /// call [`pause`] before calling this method. + /// - If called outside of the Tokio runtime. + /// - If the input `duration` is too large (such as [`Duration::MAX`]) + /// to be safely added to the current time without causing an overflow. + /// + /// # Caveats + /// + /// Using a very large `duration` is not recommended, + /// as it may cause panicking due to overflow. /// /// # Auto-advance ///