Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use deprecated method in impl Arbitrary for DateTime #1336

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
- run: |
cargo hack check --feature-powerset --optional-deps serde \
cargo hack check --feature-powerset --optional-deps arbitrary,serde \
--skip __internal_bench,iana-time-zone,pure-rust-locales,libc,winapi,rkyv-16,rkyv-64,rkyv-validation \
--all-targets
# run using `bash` on all platforms for consistent
Expand Down
2 changes: 1 addition & 1 deletion src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ where

// Note that implementation of Arbitrary cannot be automatically derived for Date<Tz>, due to
// the nontrivial bound <Tz as TimeZone>::Offset: Arbitrary.
#[cfg(feature = "arbitrary")]
#[cfg(all(feature = "arbitrary", feature = "std"))]
impl<'a, Tz> arbitrary::Arbitrary<'a> for Date<Tz>
where
Tz: TimeZone,
Expand Down
4 changes: 2 additions & 2 deletions src/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@

// Note that implementation of Arbitrary cannot be simply derived for DateTime<Tz>, due to
// the nontrivial bound <Tz as TimeZone>::Offset: Arbitrary.
#[cfg(feature = "arbitrary")]
#[cfg(all(feature = "arbitrary", feature = "std"))]
impl<'a, Tz> arbitrary::Arbitrary<'a> for DateTime<Tz>
where
Tz: TimeZone,
Expand All @@ -1705,7 +1705,7 @@
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<DateTime<Tz>> {
let datetime = NaiveDateTime::arbitrary(u)?;
let offset = <Tz as TimeZone>::Offset::arbitrary(u)?;
Ok(DateTime::from_utc(datetime, offset))
Ok(DateTime::from_naive_utc_and_offset(datetime, offset))

Check warning on line 1708 in src/datetime/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/datetime/mod.rs#L1708

Added line #L1708 was not covered by tests
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ const fn div_mod_floor_64(this: i64, other: i64) -> (i64, i64) {
(this.div_euclid(other), this.rem_euclid(other))
}

#[cfg(feature = "arbitrary")]
#[cfg(all(feature = "arbitrary", feature = "std"))]
impl arbitrary::Arbitrary<'_> for Duration {
fn arbitrary(u: &mut arbitrary::Unstructured) -> arbitrary::Result<Duration> {
const MIN_SECS: i64 = -i64::MAX / MILLIS_PER_SEC - 1;
Expand Down
4 changes: 2 additions & 2 deletions src/month.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))]

Check warning on line 40 in src/month.rs

View check run for this annotation

Codecov / codecov/patch

src/month.rs#L40

Added line #L40 was not covered by tests
pub enum Month {
/// January
January = 0,
Expand Down Expand Up @@ -225,7 +225,7 @@

/// A duration in calendar months
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))]

Check warning on line 228 in src/month.rs

View check run for this annotation

Codecov / codecov/patch

src/month.rs#L228

Added line #L228 was not covered by tests
pub struct Months(pub(crate) u32);

impl Months {
Expand Down
2 changes: 1 addition & 1 deletion src/naive/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub const MIN_DATE: NaiveDate = NaiveDate::MIN;
#[deprecated(since = "0.4.20", note = "Use NaiveDate::MAX instead")]
pub const MAX_DATE: NaiveDate = NaiveDate::MAX;

#[cfg(feature = "arbitrary")]
#[cfg(all(feature = "arbitrary", feature = "std"))]
impl arbitrary::Arbitrary<'_> for NaiveDate {
fn arbitrary(u: &mut arbitrary::Unstructured) -> arbitrary::Result<NaiveDate> {
let year = u.int_in_range(MIN_YEAR..=MAX_YEAR)?;
Expand Down
2 changes: 1 addition & 1 deletion src/naive/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))]

Check warning on line 84 in src/naive/datetime/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/naive/datetime/mod.rs#L84

Added line #L84 was not covered by tests
pub struct NaiveDateTime {
date: NaiveDate,
time: NaiveTime,
Expand Down
2 changes: 1 addition & 1 deletion src/offset/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl fmt::Display for FixedOffset {
}
}

#[cfg(feature = "arbitrary")]
#[cfg(all(feature = "arbitrary", feature = "std"))]
impl arbitrary::Arbitrary<'_> for FixedOffset {
fn arbitrary(u: &mut arbitrary::Unstructured) -> arbitrary::Result<FixedOffset> {
let secs = u.int_in_range(-86_399..=86_399)?;
Expand Down
2 changes: 1 addition & 1 deletion src/offset/utc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
archive_attr(derive(Clone, Copy, PartialEq, Eq, Debug, Hash))
)]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))]

Check warning on line 51 in src/offset/utc.rs

View check run for this annotation

Codecov / codecov/patch

src/offset/utc.rs#L51

Added line #L51 was not covered by tests
pub struct Utc;

#[cfg(feature = "now")]
Expand Down
2 changes: 1 addition & 1 deletion src/weekday.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
archive_attr(derive(Clone, Copy, PartialEq, Eq, Debug, Hash))
)]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))]

Check warning on line 41 in src/weekday.rs

View check run for this annotation

Codecov / codecov/patch

src/weekday.rs#L41

Added line #L41 was not covered by tests
pub enum Weekday {
/// Monday.
Mon = 0,
Expand Down