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

Apply comments from MSRV bump #1026

Merged
merged 3 commits into from
Apr 18, 2023
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 src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ pub enum ParseErrorKind {
/// There was an error on the formatting string, or there were non-supported formating items.
BadFormat,

// TODO: Change this to `#[non_exhaustive]` (on the enum) when MSRV is increased
// TODO: Change this to `#[non_exhaustive]` (on the enum) with the next breaking release.
#[doc(hidden)]
__Nonexhaustive,
}
Expand Down
1 change: 1 addition & 0 deletions src/format/parsed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub struct Parsed {
pub offset: Option<i32>,

/// A dummy field to make this type not fully destructible (required for API stability).
// TODO: Change this to `#[non_exhaustive]` (on the enum) with the next breaking release.
_dummy: (),
}

Expand Down
15 changes: 0 additions & 15 deletions src/offset/local/tz_info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,6 @@ impl From<Utf8Error> for Error {
}
}

// MSRV: 1.38
#[inline]
fn rem_euclid(v: i64, rhs: i64) -> i64 {
let r = v % rhs;
if r < 0 {
if rhs < 0 {
r - rhs
} else {
r + rhs
}
} else {
r
}
}

/// Number of hours in one day
const HOURS_PER_DAY: i64 = 24;
/// Number of seconds in one hour
Expand Down
5 changes: 2 additions & 3 deletions src/offset/local/tz_info/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use super::rule::TransitionRule;
use super::timezone::{LeapSecond, LocalTimeType, TimeZone, Transition};
use super::Error;

#[allow(clippy::map_clone)] // MSRV: 1.36
pub(super) fn parse(bytes: &[u8]) -> Result<TimeZone, Error> {
let mut cursor = Cursor::new(bytes);
let state = State::new(&mut cursor, true)?;
Expand Down Expand Up @@ -66,8 +65,8 @@ pub(super) fn parse(bytes: &[u8]) -> Result<TimeZone, Error> {
leap_seconds.push(LeapSecond::new(unix_leap_time, correction));
}

let std_walls_iter = state.std_walls.iter().map(|&i| i).chain(iter::repeat(0));
let ut_locals_iter = state.ut_locals.iter().map(|&i| i).chain(iter::repeat(0));
let std_walls_iter = state.std_walls.iter().copied().chain(iter::repeat(0));
let ut_locals_iter = state.ut_locals.iter().copied().chain(iter::repeat(0));
if std_walls_iter.zip(ut_locals_iter).take(state.header.type_count).any(|pair| pair == (0, 1)) {
return Err(Error::InvalidTzFile(
"invalid couple of standard/wall and UT/local indicators",
Expand Down
6 changes: 3 additions & 3 deletions src/offset/local/tz_info/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::cmp::Ordering;
use super::parser::Cursor;
use super::timezone::{LocalTimeType, SECONDS_PER_WEEK};
use super::{
rem_euclid, Error, CUMUL_DAY_IN_MONTHS_NORMAL_YEAR, DAYS_PER_WEEK, DAY_IN_MONTHS_NORMAL_YEAR,
Error, CUMUL_DAY_IN_MONTHS_NORMAL_YEAR, DAYS_PER_WEEK, DAY_IN_MONTHS_NORMAL_YEAR,
SECONDS_PER_DAY,
};

Expand Down Expand Up @@ -589,9 +589,9 @@ impl RuleDay {
}

let week_day_of_first_month_day =
rem_euclid(4 + days_since_unix_epoch(year, month, 1), DAYS_PER_WEEK);
(4 + days_since_unix_epoch(year, month, 1)).rem_euclid(DAYS_PER_WEEK);
let first_week_day_occurence_in_month =
1 + rem_euclid(week_day as i64 - week_day_of_first_month_day, DAYS_PER_WEEK);
1 + (week_day as i64 - week_day_of_first_month_day).rem_euclid(DAYS_PER_WEEK);

let mut month_day =
first_week_day_occurence_in_month + (week as i64 - 1) * DAYS_PER_WEEK;
Expand Down