From 53da53bcd091d79a5ae90c23c64529e2e8753964 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 8 May 2023 09:32:24 +0200 Subject: [PATCH 1/4] Bump MSRV to 1.56 --- .github/workflows/test.yml | 11 +++++------ Cargo.toml | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1250867787..106157c14f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,9 +32,8 @@ jobs: - run: cargo test --doc --all-features --color=always -- --color=always # later this may be able to be included with the below - # kept seperate for now as the following don't compile on 1.38.0 - # * rkyv - # * criterion + # kept separate for now as the following don't compile on 1.56.1 + # * arbitrary rust_msrv: strategy: matrix: @@ -44,11 +43,11 @@ jobs: - uses: actions/checkout@v2 - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.38.0 + toolchain: 1.56.1 - uses: Swatinem/rust-cache@v2 # run --lib and --doc to avoid the long running integration tests which are run elsewhere - - run: cargo test --lib --features unstable-locales,wasmbind,oldtime,clock,rustc-serialize,winapi --color=always -- --color=always - - run: cargo test --doc --features unstable-locales,wasmbind,oldtime,clock,rustc-serialize,winapi --color=always -- --color=always + - run: cargo test --lib --features unstable-locales,wasmbind,oldtime,clock,rustc-serialize,winapi,serde --color=always -- --color=always + - run: cargo test --doc --features unstable-locales,wasmbind,oldtime,clock,rustc-serialize,winapi,serde --color=always -- --color=always rust_versions: strategy: diff --git a/Cargo.toml b/Cargo.toml index 8920d6ba21..7c3a02409d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ readme = "README.md" license = "MIT/Apache-2.0" exclude = ["/ci/*"] edition = "2018" +rust-version = "1.56.0" [lib] name = "chrono" From a3dc7d526e7db62b1e9b976eafd40eb29e21488c Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 8 May 2023 09:34:10 +0200 Subject: [PATCH 2/4] Allow clippy to take advantage of new MSRV --- clippy.toml | 1 - src/format/mod.rs | 1 + src/format/parsed.rs | 1 + src/format/scan.rs | 9 +-------- src/naive/date.rs | 2 +- src/offset/local/unix.rs | 4 ++-- 6 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml deleted file mode 100644 index 749c3b58a5..0000000000 --- a/clippy.toml +++ /dev/null @@ -1 +0,0 @@ -msrv = "1.38" diff --git a/src/format/mod.rs b/src/format/mod.rs index 768ed76815..c3db7ade92 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -356,6 +356,7 @@ impl ParseError { } /// The category of parse error +#[allow(clippy::manual_non_exhaustive)] #[derive(Debug, Clone, PartialEq, Eq, Copy, Hash)] pub enum ParseErrorKind { /// Given field is out of permitted range. diff --git a/src/format/parsed.rs b/src/format/parsed.rs index 1ed5dcbf1d..b5fb8e699f 100644 --- a/src/format/parsed.rs +++ b/src/format/parsed.rs @@ -22,6 +22,7 @@ use crate::{Datelike, Timelike}; /// /// - `to_*` methods try to make a concrete date and time value out of set fields. /// It fully checks any remaining out-of-range conditions and inconsistent/impossible fields. +#[allow(clippy::manual_non_exhaustive)] #[derive(Clone, PartialEq, Eq, Debug, Default, Hash)] pub struct Parsed { /// Year. diff --git a/src/format/scan.rs b/src/format/scan.rs index 399a50c30f..705ccf9095 100644 --- a/src/format/scan.rs +++ b/src/format/scan.rs @@ -313,14 +313,7 @@ where /// [RFC 2822 Section 4.3]: https://tools.ietf.org/html/rfc2822#section-4.3 pub(super) fn timezone_offset_2822(s: &str) -> ParseResult<(&str, Option)> { // tries to parse legacy time zone names - let upto = s - .as_bytes() - .iter() - .position(|&c| match c { - b'a'..=b'z' | b'A'..=b'Z' => false, - _ => true, - }) - .unwrap_or(s.len()); + let upto = s.as_bytes().iter().position(|&c| !c.is_ascii_alphabetic()).unwrap_or(s.len()); if upto > 0 { let name = &s.as_bytes()[..upto]; let s = &s[upto..]; diff --git a/src/naive/date.rs b/src/naive/date.rs index 85db44fa06..0c7768c4f5 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -2249,7 +2249,7 @@ mod tests { assert_eq!( NaiveDate::from_ymd_opt(2022, 8, 3) .unwrap() - .checked_sub_months(Months::new((i32::MIN as i64).abs() as u32 + 1)), + .checked_sub_months(Months::new((i32::MIN as i64).unsigned_abs() as u32 + 1)), None ); diff --git a/src/offset/local/unix.rs b/src/offset/local/unix.rs index 32aa31618b..22114f21ef 100644 --- a/src/offset/local/unix.rs +++ b/src/offset/local/unix.rs @@ -88,7 +88,7 @@ impl Default for Cache { fn default() -> Cache { // default to UTC if no local timezone can be found let env_tz = env::var("TZ").ok(); - let env_ref = env_tz.as_ref().map(|s| s.as_str()); + let env_ref = env_tz.as_deref(); Cache { last_checked: SystemTime::now(), source: Source::new(env_ref), @@ -114,7 +114,7 @@ impl Cache { Ok(d) if d.as_secs() < 1 => (), Ok(_) | Err(_) => { let env_tz = env::var("TZ").ok(); - let env_ref = env_tz.as_ref().map(|s| s.as_str()); + let env_ref = env_tz.as_deref(); let new_source = Source::new(env_ref); let out_of_date = match (&self.source, &new_source) { From fdc0f13d7e19eeb0072bd1f840ade2881734ab55 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 8 May 2023 13:41:04 +0200 Subject: [PATCH 3/4] Remove custom matches!() macro --- src/lib.rs | 12 ------------ src/offset/local/tz_info/rule.rs | 1 - src/offset/local/tz_info/timezone.rs | 1 - 3 files changed, 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 861ee10593..acd4f4a0f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -513,15 +513,3 @@ pub use naive::__BenchYearFlags; pub mod serde { pub use super::datetime::serde::*; } - -/// MSRV 1.42 -#[cfg(test)] -#[macro_export] -macro_rules! matches { - ($expression:expr, $(|)? $( $pattern:pat )|+ $( if $guard: expr )? $(,)?) => { - match $expression { - $( $pattern )|+ $( if $guard )? => true, - _ => false - } - } -} diff --git a/src/offset/local/tz_info/rule.rs b/src/offset/local/tz_info/rule.rs index c2596265eb..5b8634eece 100644 --- a/src/offset/local/tz_info/rule.rs +++ b/src/offset/local/tz_info/rule.rs @@ -777,7 +777,6 @@ mod tests { use super::super::timezone::Transition; use super::super::{Error, TimeZone}; use super::{AlternateTime, LocalTimeType, RuleDay, TransitionRule}; - use crate::matches; #[test] fn test_quoted() -> Result<(), Error> { diff --git a/src/offset/local/tz_info/timezone.rs b/src/offset/local/tz_info/timezone.rs index 8572825a89..866cc011b2 100644 --- a/src/offset/local/tz_info/timezone.rs +++ b/src/offset/local/tz_info/timezone.rs @@ -632,7 +632,6 @@ const SECONDS_PER_28_DAYS: i64 = SECONDS_PER_DAY * 28; mod tests { use super::super::Error; use super::{LeapSecond, LocalTimeType, TimeZone, TimeZoneName, Transition, TransitionRule}; - use crate::matches; #[test] fn test_no_dst() -> Result<(), Error> { From 41d823cb7854773f64b016a92c74a036fbc0ba5b Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 8 May 2023 13:41:19 +0200 Subject: [PATCH 4/4] Remove unnecessary cast --- src/naive/date.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/naive/date.rs b/src/naive/date.rs index 0c7768c4f5..a95ac3ea29 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -2249,7 +2249,7 @@ mod tests { assert_eq!( NaiveDate::from_ymd_opt(2022, 8, 3) .unwrap() - .checked_sub_months(Months::new((i32::MIN as i64).unsigned_abs() as u32 + 1)), + .checked_sub_months(Months::new(i32::MIN.unsigned_abs() + 1)), None );