Skip to content

Commit

Permalink
Address updated lints
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Aug 4, 2024
1 parent aca5c36 commit 866c3a0
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 25 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,28 @@ single-use-lifetimes = "warn"
trivial-casts = "warn"
trivial-numeric-casts = "warn"
unreachable-pub = "warn"
unstable-name-collisions = { level = "warn", priority = 1 } # overrides #![deny(future_incompatible)]
unused = "warn"
unused = { level = "warn", priority = -1 }
unused-import-braces = "warn"
unused-lifetimes = "warn"
unused-qualifications = "warn"
# unused-results = "warn"
variant-size-differences = "warn"

unstable-name-collisions = { level = "allow", priority = 1 } # overrides #![deny(future_incompatible)], temporary while `.cast_{un}signed()` is unstable

[workspace.lints.clippy]
alloc-instead-of-core = "deny"
std-instead-of-core = "deny"
undocumented-unsafe-blocks = "deny"

all = "warn"
missing-docs-in-private-items = "warn"
all = { level = "warn", priority = -1 }
dbg-macro = "warn"
decimal-literal-representation = "warn"
explicit-auto-deref = "warn"
get-unwrap = "warn"
manual-let-else = "warn"
missing-docs-in-private-items = "warn"
missing-enforced-import-renames = "warn"
nursery = "warn"
nursery = { level = "warn", priority = -1 }
obfuscated-if-else = "warn"
print-stdout = "warn"
semicolon-outside-block = "warn"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ macro_rules! bench_rand {
iter_batched_ref!(
ben,
|| StepRng::new(0, 1),
[|rng| rng.gen::<$type>()]
[|rng| rng.r#gen::<$type>()]
);
})*
}
Expand Down
1 change: 0 additions & 1 deletion tests/duration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use core::u64;
use std::cmp::Ordering;
use std::cmp::Ordering::{Equal, Greater, Less};
use std::time::Duration as StdDuration;
Expand Down
2 changes: 1 addition & 1 deletion tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn run_with_all_features() -> Result<(), Box<dyn std::error::Error>> {
impl std::error::Error for Error {}

let status = std::process::Command::new("cargo")
.args(&["test", "--all-features"])
.args(["test", "--all-features"])
.status()?;

return if status.success() {
Expand Down
16 changes: 8 additions & 8 deletions tests/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ fn support() {
let mut rng = rand::rngs::mock::StepRng::new(0, 656_175_560);

for _ in 0..7 {
let _ = rng.gen::<Weekday>();
let _ = rng.r#gen::<Weekday>();
}
for _ in 0..12 {
let _ = rng.gen::<Month>();
let _ = rng.r#gen::<Month>();
}
let _ = rng.gen::<Time>();
let _ = rng.gen::<Date>();
let _ = rng.gen::<UtcOffset>();
let _ = rng.gen::<PrimitiveDateTime>();
let _ = rng.gen::<OffsetDateTime>();
let _ = rng.gen::<Duration>();
let _ = rng.r#gen::<Time>();
let _ = rng.r#gen::<Date>();
let _ = rng.r#gen::<UtcOffset>();
let _ = rng.r#gen::<PrimitiveDateTime>();
let _ = rng.r#gen::<OffsetDateTime>();
let _ = rng.r#gen::<Duration>();
}
8 changes: 4 additions & 4 deletions time/src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ impl Duration {
/// ```rust
/// # use time::{Duration, ext::NumericalDuration};
/// assert_eq!(Duration::seconds_f64(0.5), 0.5.seconds());
/// assert_eq!(Duration::seconds_f64(-0.5), -0.5.seconds());
/// assert_eq!(Duration::seconds_f64(-0.5), (-0.5).seconds());
/// ```
pub fn seconds_f64(seconds: f64) -> Self {
try_from_secs!(
Expand Down Expand Up @@ -564,7 +564,7 @@ impl Duration {
/// ```rust
/// # use time::{Duration, ext::NumericalDuration};
/// assert_eq!(Duration::saturating_seconds_f64(0.5), 0.5.seconds());
/// assert_eq!(Duration::saturating_seconds_f64(-0.5), -0.5.seconds());
/// assert_eq!(Duration::saturating_seconds_f64(-0.5), (-0.5).seconds());
/// assert_eq!(
/// Duration::saturating_seconds_f64(f64::NAN),
/// Duration::new(0, 0),
Expand Down Expand Up @@ -637,7 +637,7 @@ impl Duration {
/// ```rust
/// # use time::{Duration, ext::NumericalDuration};
/// assert_eq!(Duration::checked_seconds_f64(0.5), Some(0.5.seconds()));
/// assert_eq!(Duration::checked_seconds_f64(-0.5), Some(-0.5.seconds()));
/// assert_eq!(Duration::checked_seconds_f64(-0.5), Some((-0.5).seconds()));
/// assert_eq!(Duration::checked_seconds_f64(f64::NAN), None);
/// assert_eq!(Duration::checked_seconds_f64(f64::NEG_INFINITY), None);
/// assert_eq!(Duration::checked_seconds_f64(f64::INFINITY), None);
Expand All @@ -664,7 +664,7 @@ impl Duration {
/// ```rust
/// # use time::{Duration, ext::NumericalDuration};
/// assert_eq!(Duration::checked_seconds_f32(0.5), Some(0.5.seconds()));
/// assert_eq!(Duration::checked_seconds_f32(-0.5), Some(-0.5.seconds()));
/// assert_eq!(Duration::checked_seconds_f32(-0.5), Some((-0.5).seconds()));
/// assert_eq!(Duration::checked_seconds_f32(f32::NAN), None);
/// assert_eq!(Duration::checked_seconds_f32(f32::NEG_INFINITY), None);
/// assert_eq!(Duration::checked_seconds_f32(f32::INFINITY), None);
Expand Down
1 change: 1 addition & 0 deletions time/src/error/component_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ impl ComponentRange {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for ComponentRange {}
1 change: 1 addition & 0 deletions time/src/error/conversion_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ impl fmt::Display for ConversionRange {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for ConversionRange {}

impl From<ConversionRange> for crate::Error {
Expand Down
1 change: 1 addition & 0 deletions time/src/error/different_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ impl fmt::Display for DifferentVariant {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for DifferentVariant {}

impl From<DifferentVariant> for crate::Error {
Expand Down
1 change: 1 addition & 0 deletions time/src/error/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ impl TryFrom<Format> for io::Error {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for Format {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match *self {
Expand Down
1 change: 1 addition & 0 deletions time/src/error/indeterminate_offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impl fmt::Display for IndeterminateOffset {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for IndeterminateOffset {}

impl From<IndeterminateOffset> for crate::Error {
Expand Down
1 change: 1 addition & 0 deletions time/src/error/invalid_format_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ impl fmt::Display for InvalidFormatDescription {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for InvalidFormatDescription {}
1 change: 1 addition & 0 deletions time/src/error/invalid_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ impl fmt::Display for InvalidVariant {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for InvalidVariant {}

impl From<InvalidVariant> for crate::Error {
Expand Down
1 change: 1 addition & 0 deletions time/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl fmt::Display for Error {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Expand Down
1 change: 1 addition & 0 deletions time/src/error/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl fmt::Display for Parse {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for Parse {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Expand Down
1 change: 1 addition & 0 deletions time/src/error/parse_from_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl fmt::Display for ParseFromDescription {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for ParseFromDescription {}

impl From<ParseFromDescription> for crate::Error {
Expand Down
1 change: 1 addition & 0 deletions time/src/error/try_from_parsed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl TryFrom<TryFromParsed> for error::ComponentRange {
}

#[cfg(feature = "std")]
#[allow(clippy::std_instead_of_core)]
impl std::error::Error for TryFromParsed {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Expand Down
2 changes: 1 addition & 1 deletion time/src/parsing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a, T> ParsedItem<'a, T> {
/// Filter the value with the provided function. If the function returns `false`, the value
/// is discarded and `None` is returned. Otherwise, the value is preserved and `Some(self)` is
/// returned.
pub(crate) fn filter(self, f: impl FnOnce(&T) -> bool) -> Option<ParsedItem<'a, T>> {
pub(crate) fn filter(self, f: impl FnOnce(&T) -> bool) -> Option<Self> {
f(&self.1).then_some(self)
}
}
Expand Down
6 changes: 3 additions & 3 deletions time/src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{Date, Duration, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcO

impl Distribution<Time> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Time {
Time::from_hms_nanos_ranged(rng.gen(), rng.gen(), rng.gen(), rng.gen())
Time::from_hms_nanos_ranged(rng.r#gen(), rng.r#gen(), rng.r#gen(), rng.r#gen())
}
}

Expand All @@ -21,7 +21,7 @@ impl Distribution<Date> for Standard {

impl Distribution<UtcOffset> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UtcOffset {
UtcOffset::from_hms_ranged(rng.gen(), rng.gen(), rng.gen())
UtcOffset::from_hms_ranged(rng.r#gen(), rng.r#gen(), rng.r#gen())
}
}

Expand All @@ -40,7 +40,7 @@ impl Distribution<OffsetDateTime> for Standard {

impl Distribution<Duration> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Duration {
Duration::new_ranged(rng.gen(), rng.gen())
Duration::new_ranged(rng.r#gen(), rng.r#gen())
}
}

Expand Down
2 changes: 2 additions & 0 deletions time/src/serde/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
/// use time::serde;
/// use time::format_description::well_known::{iso8601, Iso8601};
///
/// # #[allow(dead_code)]
/// const CONFIG: iso8601::EncodedConfig = iso8601::Config::DEFAULT
/// .set_year_is_six_digits(false)
/// .encode();
/// # #[allow(dead_code)]
/// const FORMAT: Iso8601<CONFIG> = Iso8601::<CONFIG>;
///
/// // Makes a module `mod my_format { ... }`.
Expand Down

0 comments on commit 866c3a0

Please sign in to comment.