From 812b5b1dc72218e13bccae61b4de2b3581a68e4f Mon Sep 17 00:00:00 2001 From: Paul Dicker Date: Fri, 19 May 2023 15:47:30 +0200 Subject: [PATCH] Add comment to useless range check --- src/format/parse.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/format/parse.rs b/src/format/parse.rs index ed3f91f6df..c3f50067c3 100644 --- a/src/format/parse.rs +++ b/src/format/parse.rs @@ -216,7 +216,11 @@ fn parse_rfc3339<'a>(parsed: &mut Parsed, mut s: &'a str) -> ParseResult<(&'a st } let offset = try_consume!(scan::timezone_offset_zulu(s, |s| scan::char(s, b':'))); - if offset <= -86_400 || offset >= 86_400 { + // This range check is similar to the one in `FixedOffset::east_opt`, so it would be redundant. + // But it is possible to read the offset directly from `Parsed`. We want to only successfully + // populate `Parsed` if the input is fully valid RFC 3339. + const MAX_OFFSET: i32 = 23 * 3600 + 59 * 60; + if offset < -MAX_OFFSET || offset > MAX_OFFSET { return Err(OUT_OF_RANGE); } parsed.set_offset(i64::from(offset))?;