Skip to content

Commit 2d37c01

Browse files
committed
Bump MSRV to 1.53
1 parent 1edf9fa commit 2d37c01

File tree

20 files changed

+80
-146
lines changed

20 files changed

+80
-146
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) || github.event_name == 'push' }}
3333
strategy:
3434
matrix:
35-
rust: ["1.51", stable]
35+
rust: ["1.53", stable]
3636
target:
3737
- name: NetBSD
3838
triple: x86_64-unknown-netbsd
@@ -152,7 +152,7 @@ jobs:
152152
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) || github.event_name == 'push' }}
153153
strategy:
154154
matrix:
155-
rust: ["1.51", stable]
155+
rust: ["1.53", stable]
156156
os:
157157
- { name: Ubuntu, value: ubuntu-20.04, has_local_offset: true }
158158
- { name: Windows, value: windows-latest, has_local_offset: true }

.github/workflows/powerset.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
args: |
101101
check
102102
--no-dev-deps
103-
--version-range 1.51..
103+
--version-range 1.53..
104104
--clean-per-version
105105
--feature-powerset
106106
--optional-deps
@@ -116,7 +116,7 @@ jobs:
116116
args: |
117117
check
118118
--no-dev-deps
119-
--version-range 1.51..
119+
--version-range 1.53..
120120
--clean-per-version
121121
--feature-powerset
122122
--optional-deps

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# time
22

3-
[![minimum rustc: 1.51](https://img.shields.io/badge/minimum%20rustc-1.51-yellowgreen?logo=rust&style=flat-square)](https://www.whatrustisit.com)
3+
[![minimum rustc: 1.53](https://img.shields.io/badge/minimum%20rustc-1.53-yellowgreen?logo=rust&style=flat-square)](https://www.whatrustisit.com)
44
[![version](https://img.shields.io/crates/v/time?color=blue&logo=rust&style=flat-square)](https://crates.io/crates/time)
55
[![build status](https://img.shields.io/github/workflow/status/time-rs/time/Build/main?style=flat-square)](https://github.com/time-rs/time/actions)
66
[![codecov](https://codecov.io/gh/time-rs/time/branch/main/graph/badge.svg?token=yt4XSmQNKQ)](https://codecov.io/gh/time-rs/time)

src/duration.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,7 @@ impl Duration {
602602
/// assert_eq!(10.seconds().checked_div(-2), Some((-5).seconds()));
603603
/// assert_eq!(1.seconds().checked_div(0), None);
604604
/// ```
605-
#[allow(clippy::missing_const_for_fn)] // requires Rust 1.52
606-
pub fn checked_div(self, rhs: i32) -> Option<Self> {
605+
pub const fn checked_div(self, rhs: i32) -> Option<Self> {
607606
let seconds = const_try_opt!(self.seconds.checked_div(rhs as i64));
608607
let carry = self.seconds - seconds * (rhs as i64);
609608
let extra_nanos = const_try_opt!((carry * 1_000_000_000).checked_div(rhs as i64));

src/format_description/modifier.rs

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -409,56 +409,37 @@ impl Modifiers {
409409
break;
410410
}
411411

412-
#[allow(clippy::unnested_or_patterns)]
413412
match (component_name, modifier) {
414-
(b"day", b"padding:space")
415-
| (b"hour", b"padding:space")
416-
| (b"minute", b"padding:space")
417-
| (b"month", b"padding:space")
418-
| (b"offset_hour", b"padding:space")
419-
| (b"offset_minute", b"padding:space")
420-
| (b"offset_second", b"padding:space")
421-
| (b"ordinal", b"padding:space")
422-
| (b"second", b"padding:space")
423-
| (b"week_number", b"padding:space")
424-
| (b"year", b"padding:space") => modifiers.padding = Some(Padding::Space),
425-
(b"day", b"padding:zero")
426-
| (b"hour", b"padding:zero")
427-
| (b"minute", b"padding:zero")
428-
| (b"month", b"padding:zero")
429-
| (b"offset_hour", b"padding:zero")
430-
| (b"offset_minute", b"padding:zero")
431-
| (b"offset_second", b"padding:zero")
432-
| (b"ordinal", b"padding:zero")
433-
| (b"second", b"padding:zero")
434-
| (b"week_number", b"padding:zero")
435-
| (b"year", b"padding:zero") => modifiers.padding = Some(Padding::Zero),
436-
(b"day", b"padding:none")
437-
| (b"hour", b"padding:none")
438-
| (b"minute", b"padding:none")
439-
| (b"month", b"padding:none")
440-
| (b"offset_hour", b"padding:none")
441-
| (b"offset_minute", b"padding:none")
442-
| (b"offset_second", b"padding:none")
443-
| (b"ordinal", b"padding:none")
444-
| (b"second", b"padding:none")
445-
| (b"week_number", b"padding:none")
446-
| (b"year", b"padding:none") => modifiers.padding = Some(Padding::None),
413+
(
414+
b"day" | b"hour" | b"minute" | b"month" | b"offset_hour" | b"offset_minute"
415+
| b"offset_second" | b"ordinal" | b"second" | b"week_number" | b"year",
416+
b"padding:space",
417+
) => modifiers.padding = Some(Padding::Space),
418+
(
419+
b"day" | b"hour" | b"minute" | b"month" | b"offset_hour" | b"offset_minute"
420+
| b"offset_second" | b"ordinal" | b"second" | b"week_number" | b"year",
421+
b"padding:zero",
422+
) => modifiers.padding = Some(Padding::Zero),
423+
(
424+
b"day" | b"hour" | b"minute" | b"month" | b"offset_hour" | b"offset_minute"
425+
| b"offset_second" | b"ordinal" | b"second" | b"week_number" | b"year",
426+
b"padding:none",
427+
) => modifiers.padding = Some(Padding::None),
447428
(b"hour", b"repr:24") => modifiers.hour_is_12_hour_clock = Some(false),
448429
(b"hour", b"repr:12") => modifiers.hour_is_12_hour_clock = Some(true),
449-
(b"month", b"case_sensitive:true")
450-
| (b"period", b"case_sensitive:true")
451-
| (b"weekday", b"case_sensitive:true") => modifiers.case_sensitive = Some(true),
452-
(b"month", b"case_sensitive:false")
453-
| (b"period", b"case_sensitive:false")
454-
| (b"weekday", b"case_sensitive:false") => modifiers.case_sensitive = Some(false),
430+
(b"month" | b"period" | b"weekday", b"case_sensitive:true") => {
431+
modifiers.case_sensitive = Some(true)
432+
}
433+
(b"month" | b"period" | b"weekday", b"case_sensitive:false") => {
434+
modifiers.case_sensitive = Some(false)
435+
}
455436
(b"month", b"repr:numerical") => modifiers.month_repr = Some(MonthRepr::Numerical),
456437
(b"month", b"repr:long") => modifiers.month_repr = Some(MonthRepr::Long),
457438
(b"month", b"repr:short") => modifiers.month_repr = Some(MonthRepr::Short),
458-
(b"offset_hour", b"sign:automatic") | (b"year", b"sign:automatic") => {
439+
(b"offset_hour" | b"year", b"sign:automatic") => {
459440
modifiers.sign_is_mandatory = Some(false);
460441
}
461-
(b"offset_hour", b"sign:mandatory") | (b"year", b"sign:mandatory") => {
442+
(b"offset_hour" | b"year", b"sign:mandatory") => {
462443
modifiers.sign_is_mandatory = Some(true);
463444
}
464445
(b"period", b"case:upper") => modifiers.period_is_uppercase = Some(true),

src/formatting/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,9 @@ fn fmt_hour(
342342
is_12_hour_clock,
343343
}: modifier::Hour,
344344
) -> Result<usize, io::Error> {
345-
#[allow(clippy::unnested_or_patterns)]
346345
let value = match (time.hour(), is_12_hour_clock) {
347346
(hour, false) => hour,
348-
(0, true) | (12, true) => 12,
347+
(0 | 12, true) => 12,
349348
(hour, true) if hour < 12 => hour,
350349
(hour, true) => hour - 12,
351350
};

src/lib.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
trivial_numeric_casts,
9191
unreachable_pub,
9292
unsafe_code,
93-
// unsafe_op_in_unsafe_fn, // requires Rust 1.51
93+
unsafe_op_in_unsafe_fn,
9494
unused_extern_crates
9595
)]
9696
#![warn(
@@ -102,6 +102,7 @@
102102
clippy::print_stdout,
103103
clippy::todo,
104104
clippy::unimplemented,
105+
clippy::unnested_or_patterns,
105106
clippy::unwrap_in_result,
106107
clippy::unwrap_used,
107108
clippy::use_debug,
@@ -178,20 +179,6 @@ macro_rules! div_floor {
178179
}};
179180
}
180181

181-
/// Euclidean remainder. Useful for `const` contexts.
182-
macro_rules! rem_euclid {
183-
($a:expr, $b:expr) => {{
184-
let _a = $a;
185-
let _b = $b;
186-
let r = _a % _b;
187-
if r < 0 {
188-
if _b < 0 { r - _b } else { r + _b }
189-
} else {
190-
r
191-
}
192-
}};
193-
}
194-
195182
/// Cascade an out-of-bounds value.
196183
macro_rules! cascade {
197184
(@ordinal ordinal) => {};

src/offset_date_time.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl OffsetDateTime {
149149
UNIX_EPOCH_JULIAN_DAY + div_floor!(timestamp, 86_400) as i32,
150150
);
151151

152-
let seconds_within_day = rem_euclid!(timestamp, 86_400);
152+
let seconds_within_day = timestamp.rem_euclid(86_400);
153153
let time = Time::__from_hms_nanos_unchecked(
154154
(seconds_within_day / 3_600) as _,
155155
((seconds_within_day % 3_600) / 60) as _,
@@ -185,7 +185,7 @@ impl OffsetDateTime {
185185
datetime.utc_datetime.hour(),
186186
datetime.utc_datetime.minute(),
187187
datetime.utc_datetime.second(),
188-
rem_euclid!(timestamp, 1_000_000_000) as u32,
188+
timestamp.rem_euclid(1_000_000_000) as u32,
189189
))
190190
.assume_utc())
191191
}
@@ -280,7 +280,7 @@ impl OffsetDateTime {
280280
cascade!(minute in 0..60 => hour);
281281

282282
Time::__from_hms_nanos_unchecked(
283-
rem_euclid!(hour, 24) as _,
283+
hour.rem_euclid(24) as _,
284284
minute as _,
285285
second as _,
286286
self.utc_datetime.nanosecond(),
@@ -591,7 +591,7 @@ impl OffsetDateTime {
591591

592592
cascade!(second in 0..60 => minute);
593593
cascade!(minute in 0..60 => hour);
594-
rem_euclid!(hour, 24) as _
594+
hour.rem_euclid(24) as _
595595
}
596596

597597
/// Get the minute within the hour in the stored offset.
@@ -613,7 +613,7 @@ impl OffsetDateTime {
613613
let mut minute = self.utc_datetime.minute() as i8 + self.offset.minutes_past_hour();
614614

615615
cascade!(second in 0..60 => minute);
616-
rem_euclid!(minute, 60) as _
616+
minute.rem_euclid(60) as _
617617
}
618618

619619
/// Get the second within the minute in the stored offset.
@@ -632,7 +632,7 @@ impl OffsetDateTime {
632632
/// ```
633633
pub const fn second(self) -> u8 {
634634
let second = self.utc_datetime.second() as i8 + self.offset.seconds_past_minute();
635-
rem_euclid!(second, 60) as _
635+
second.rem_euclid(60) as _
636636
}
637637

638638
// Because a `UtcOffset` is limited in resolution to one second, any subsecond value will not

src/parsing/combinator/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ use crate::parsing::ParsedItem;
99
/// Parse a "+" or "-" sign. Returns the ASCII byte representing the sign, if present.
1010
pub(crate) const fn sign(input: &[u8]) -> Option<ParsedItem<'_, u8>> {
1111
match input {
12-
[b'-', remaining @ ..] => Some(ParsedItem(remaining, b'-')),
13-
[b'+', remaining @ ..] => Some(ParsedItem(remaining, b'+')),
12+
[sign @ (b'-' | b'+'), remaining @ ..] => Some(ParsedItem(remaining, *sign)),
1413
_ => None,
1514
}
1615
}

src/parsing/combinator/rfc/rfc2234.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::parsing::ParsedItem;
77
/// Consume exactly one space or tab.
88
pub(crate) const fn wsp(input: &[u8]) -> Option<ParsedItem<'_, ()>> {
99
match input {
10-
[b' ', rest @ ..] | [b'\t', rest @ ..] => Some(ParsedItem(rest, ())),
10+
[b' ' | b'\t', rest @ ..] => Some(ParsedItem(rest, ())),
1111
_ => None,
1212
}
1313
}

0 commit comments

Comments
 (0)