diff --git a/src/client/pool.rs b/src/client/pool.rs index 4080ad5f66..b9772d688d 100644 --- a/src/client/pool.rs +++ b/src/client/pool.rs @@ -458,7 +458,9 @@ impl PoolInner { trace!("idle interval evicting closed for {:?}", key); return false; } - if now - entry.idle_at > dur { + + // Avoid `Instant::sub` to avoid issues like rust-lang/rust#86470. + if now.saturating_duration_since(entry.idle_at) > dur { trace!("idle interval evicting expired for {:?}", key); return false; } @@ -721,7 +723,8 @@ impl Expiration { fn expires(&self, instant: Instant) -> bool { match self.0 { - Some(timeout) => instant.elapsed() > timeout, + // Avoid `Instant::elapsed` to avoid issues like rust-lang/rust#86470. + Some(timeout) => Instant::now().saturating_duration_since(instant) > timeout, None => false, } }