From d37b0be87eaf009ff582c69ab35533015572da88 Mon Sep 17 00:00:00 2001 From: Mikhail Katychev Date: Mon, 13 Feb 2023 08:33:29 -0700 Subject: [PATCH] replaced bytecheck with combo rkyv-validation feature --- Cargo.toml | 2 +- src/date.rs | 6 +++--- src/datetime/mod.rs | 6 +++--- src/month.rs | 4 ++-- src/naive/date.rs | 4 ++-- src/naive/datetime/mod.rs | 4 ++-- src/naive/isoweek.rs | 4 ++-- src/naive/time/mod.rs | 4 ++-- src/offset/fixed.rs | 4 ++-- src/offset/local/mod.rs | 4 ++-- src/offset/utc.rs | 4 ++-- src/oldtime.rs | 4 ++-- src/weekday.rs | 4 ++-- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aeabe398e9..07e5e38028 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ std = [] clock = ["std", "winapi", "iana-time-zone"] oldtime = ["time"] wasmbind = ["wasm-bindgen", "js-sys"] -bytecheck = ["dep:bytecheck", "rkyv?/validation"] +rkyv-validation = ["rkyv/validation", "dep:bytecheck"] unstable-locales = ["pure-rust-locales", "alloc"] __internal_bench = ["criterion"] __doctest = [] diff --git a/src/date.rs b/src/date.rs index aa2fdb6d0d..2d7266e80b 100644 --- a/src/date.rs +++ b/src/date.rs @@ -10,7 +10,7 @@ use core::cmp::Ordering; use core::ops::{Add, AddAssign, Sub, SubAssign}; use core::{fmt, hash}; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; #[cfg(feature = "rkyv")] use rkyv::{Archive, Deserialize, Serialize}; @@ -59,7 +59,7 @@ use crate::{Datelike, Weekday}; #[deprecated(since = "0.4.23", note = "Use `NaiveDate` or `DateTime` instead")] #[derive(Clone)] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes)))] pub struct Date { date: NaiveDate, offset: Tz::Offset, @@ -527,7 +527,7 @@ impl fmt::Debug for Date { // This boilerplate is a shortcoming of the `Derive` macro. // See: https://github.com/rkyv/rkyv/issues/333 -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] impl fmt::Debug for ArchivedDate where Tz: Archive, diff --git a/src/datetime/mod.rs b/src/datetime/mod.rs index b1ae1c497a..68cc0336c8 100644 --- a/src/datetime/mod.rs +++ b/src/datetime/mod.rs @@ -35,7 +35,7 @@ use crate::Date; use crate::Months; use crate::{Datelike, Timelike, Weekday}; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; #[cfg(feature = "rkyv")] use rkyv::{Archive, Deserialize, Serialize}; @@ -88,7 +88,7 @@ pub enum SecondsFormat { /// [`TimeZone`](./offset/trait.TimeZone.html) implementations. #[derive(Clone)] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes)))] pub struct DateTime { datetime: NaiveDateTime, offset: Tz::Offset, @@ -994,7 +994,7 @@ impl fmt::Debug for DateTime { // This boilerplate is a shortcoming of the `Derive` macro. // See: https://github.com/rkyv/rkyv/issues/333 -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] impl fmt::Debug for ArchivedDateTime where Tz: Archive, diff --git a/src/month.rs b/src/month.rs index 1b26bae27d..bd046d38f7 100644 --- a/src/month.rs +++ b/src/month.rs @@ -1,6 +1,6 @@ use core::fmt; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; #[cfg(feature = "rkyv")] use rkyv::{Archive, Deserialize, Serialize}; @@ -32,7 +32,7 @@ use rkyv::{Archive, Deserialize, Serialize}; #[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)] #[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes, Debug)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes, Debug)))] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub enum Month { /// January diff --git a/src/naive/date.rs b/src/naive/date.rs index 2983c8c6c4..663d7474d6 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -9,7 +9,7 @@ use core::convert::TryFrom; use core::ops::{Add, AddAssign, RangeInclusive, Sub, SubAssign}; use core::{fmt, str}; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; use num_integer::div_mod_floor; use num_traits::ToPrimitive; @@ -188,7 +188,7 @@ impl Days { /// This is currently the internal format of Chrono's date types. #[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone)] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes, Debug)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes, Debug)))] pub struct NaiveDate { ymdf: DateImpl, // (year << 13) | of } diff --git a/src/naive/datetime/mod.rs b/src/naive/datetime/mod.rs index 0ba3aa262b..285d1fdb42 100644 --- a/src/naive/datetime/mod.rs +++ b/src/naive/datetime/mod.rs @@ -10,7 +10,7 @@ use core::fmt::Write; use core::ops::{Add, AddAssign, Sub, SubAssign}; use core::{fmt, str}; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; use num_integer::div_mod_floor; use num_traits::ToPrimitive; @@ -83,7 +83,7 @@ pub const MAX_DATETIME: NaiveDateTime = NaiveDateTime::MAX; /// ``` #[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone)] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes, Debug)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes, Debug)))] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct NaiveDateTime { date: NaiveDate, diff --git a/src/naive/isoweek.rs b/src/naive/isoweek.rs index 9125533536..593548d6a1 100644 --- a/src/naive/isoweek.rs +++ b/src/naive/isoweek.rs @@ -7,7 +7,7 @@ use core::fmt; use super::internals::{DateImpl, Of, YearFlags}; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; #[cfg(feature = "rkyv")] use rkyv::{Archive, Deserialize, Serialize}; @@ -20,7 +20,7 @@ use rkyv::{Archive, Deserialize, Serialize}; /// via the [`Datelike::iso_week`](../trait.Datelike.html#tymethod.iso_week) method. #[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone)] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes, Debug)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes, Debug)))] pub struct IsoWeek { // note that this allows for larger year range than `NaiveDate`. // this is crucial because we have an edge case for the first and last week supported, diff --git a/src/naive/time/mod.rs b/src/naive/time/mod.rs index e26cdf86ac..5c103ba8f1 100644 --- a/src/naive/time/mod.rs +++ b/src/naive/time/mod.rs @@ -8,7 +8,7 @@ use core::borrow::Borrow; use core::ops::{Add, AddAssign, Sub, SubAssign}; use core::{fmt, str}; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; use num_integer::div_mod_floor; #[cfg(feature = "rkyv")] @@ -191,7 +191,7 @@ mod tests; /// **there is absolutely no guarantee that the leap second read has actually happened**. #[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone)] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes, Debug)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes, Debug)))] pub struct NaiveTime { secs: u32, frac: u32, diff --git a/src/offset/fixed.rs b/src/offset/fixed.rs index 0c85991c6a..cfbc3231f0 100644 --- a/src/offset/fixed.rs +++ b/src/offset/fixed.rs @@ -6,7 +6,7 @@ use core::fmt; use core::ops::{Add, Sub}; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; use num_integer::div_mod_floor; #[cfg(feature = "rkyv")] @@ -26,7 +26,7 @@ use crate::Timelike; /// [`west_opt`](#method.west_opt) methods for examples. #[derive(PartialEq, Eq, Hash, Copy, Clone)] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes, Debug)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes, Debug)))] pub struct FixedOffset { local_minus_utc: i32, } diff --git a/src/offset/local/mod.rs b/src/offset/local/mod.rs index 1db691f5ff..84977c9b97 100644 --- a/src/offset/local/mod.rs +++ b/src/offset/local/mod.rs @@ -3,7 +3,7 @@ //! The local (system) time zone. -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; #[cfg(feature = "rkyv")] use rkyv::{Archive, Deserialize, Serialize}; @@ -55,7 +55,7 @@ mod tz_info; /// ``` #[derive(Copy, Clone, Debug)] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes, Debug)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes, Debug)))] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct Local; diff --git a/src/offset/utc.rs b/src/offset/utc.rs index 95fdd15919..9d5d26a258 100644 --- a/src/offset/utc.rs +++ b/src/offset/utc.rs @@ -14,7 +14,7 @@ use core::fmt; ))] use std::time::{SystemTime, UNIX_EPOCH}; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; #[cfg(feature = "rkyv")] use rkyv::{Archive, Deserialize, Serialize}; @@ -44,7 +44,7 @@ use crate::{Date, DateTime}; /// ``` #[derive(Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes, Debug)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes, Debug)))] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct Utc; diff --git a/src/oldtime.rs b/src/oldtime.rs index cabbb9547e..733a2f8f5c 100644 --- a/src/oldtime.rs +++ b/src/oldtime.rs @@ -16,7 +16,7 @@ use core::{fmt, i64}; #[cfg(any(feature = "std", test))] use std::error::Error; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; #[cfg(feature = "rkyv")] use rkyv::{Archive, Deserialize, Serialize}; @@ -54,7 +54,7 @@ macro_rules! try_opt { /// This also allows for the negative duration; see individual methods for details. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes, Debug)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes, Debug)))] pub struct Duration { secs: i64, nanos: i32, // Always 0 <= nanos < NANOS_PER_SEC diff --git a/src/weekday.rs b/src/weekday.rs index e00590c034..04fc882ac0 100644 --- a/src/weekday.rs +++ b/src/weekday.rs @@ -1,6 +1,6 @@ use core::fmt; -#[cfg(all(feature = "bytecheck", feature = "rkyv"))] +#[cfg(feature = "rkyv-validation")] use bytecheck::CheckBytes; #[cfg(feature = "rkyv")] use rkyv::{Archive, Deserialize, Serialize}; @@ -13,7 +13,7 @@ use rkyv::{Archive, Deserialize, Serialize}; #[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)] #[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))] #[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize), archive(compare(PartialEq)))] -#[cfg_attr(all(feature = "bytecheck", feature = "rkyv"), archive_attr(derive(CheckBytes, Debug)))] +#[cfg_attr(feature = "rkyv-validation", archive_attr(derive(CheckBytes, Debug)))] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub enum Weekday { /// Monday.