Skip to content

Commit

Permalink
Fix all lints
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Jun 13, 2021
1 parent 3bd207c commit bcb0b52
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 49 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
rust: [1.32.0, 1.36.0, stable]
target:
- { triple: x86_64-unknown-netbsd, std: true }
- { triple: x86_64-sun-solaris, std: true }
- { triple: wasm32-wasi, std: true }
- { triple: thumbv7em-none-eabihf, std: false }
exclude:
Expand All @@ -21,11 +20,6 @@ jobs:
- # WASI target did not exist at the time
rust: 1.32.0
target: { triple: wasm32-wasi, std: true }
- # Solaris target did not exist in previous rust
rust: 1.32.0
target: { triple: x86_64-sun-solaris, std: true }
- rust: 1.36.0
target: { triple: x86_64-sun-solaris, std: true }

steps:
- name: Checkout sources
Expand Down
9 changes: 2 additions & 7 deletions src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use crate::{
DeferredFormat, Duration, ParseResult, PrimitiveDateTime, Time, Weekday,
};
#[cfg(not(feature = "std"))]
use alloc::{
borrow::ToOwned,
string::{String, ToString},
};
use alloc::string::{String, ToString};
use const_fn::const_fn;
use core::{
cmp::{Ord, Ordering, PartialOrd},
Expand Down Expand Up @@ -972,9 +969,7 @@ impl Date {
/// assert_eq!(date!(2019-01-02).lazy_format("%Y-%m-%d").to_string(), "2019-01-02");
/// ```
pub fn lazy_format(self, format: impl AsRef<str>) -> impl Display {
DeferredFormat::new(format.as_ref())
.with_date(self)
.to_owned()
DeferredFormat::new(format.as_ref()).with_date(self).clone()
}

/// Attempt to parse a `Date` using the provided string.
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
clippy::inline_always,
clippy::map_err_ignore,
clippy::missing_errors_doc,
clippy::missing_panics_doc,
clippy::module_name_repetitions,
clippy::must_use_candidate,
clippy::redundant_pub_crate,
Expand Down
7 changes: 2 additions & 5 deletions src/offset_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use crate::{
UtcOffset, Weekday,
};
#[cfg(not(feature = "std"))]
use alloc::{
borrow::ToOwned,
string::{String, ToString},
};
use alloc::string::{String, ToString};
#[cfg(feature = "std")]
use core::convert::From;
use core::{
Expand Down Expand Up @@ -883,7 +880,7 @@ impl OffsetDateTime {
.with_date(self.date())
.with_time(self.time())
.with_offset(self.offset())
.to_owned()
.clone()
}

/// Attempt to parse an `OffsetDateTime` using the provided string.
Expand Down
7 changes: 2 additions & 5 deletions src/primitive_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ use crate::{
Weekday,
};
#[cfg(not(feature = "std"))]
use alloc::{
borrow::ToOwned,
string::{String, ToString},
};
use alloc::string::{String, ToString};
use const_fn::const_fn;
#[cfg(feature = "std")]
use core::convert::From;
Expand Down Expand Up @@ -515,7 +512,7 @@ impl PrimitiveDateTime {
DeferredFormat::new(format.as_ref())
.with_date(self.date())
.with_time(self.time())
.to_owned()
.clone()
}

/// Attempt to parse a `PrimitiveDateTime` using the provided string.
Expand Down
9 changes: 2 additions & 7 deletions src/time_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use crate::{
DeferredFormat, Duration, ParseResult,
};
#[cfg(not(feature = "std"))]
use alloc::{
borrow::ToOwned,
string::{String, ToString},
};
use alloc::string::{String, ToString};
use const_fn::const_fn;
use core::{
cmp::Ordering,
Expand Down Expand Up @@ -567,9 +564,7 @@ impl Time {
/// assert_eq!(time!(0:00).lazy_format("%r").to_string(), "12:00:00 am");
/// ```
pub fn lazy_format(self, format: impl AsRef<str>) -> impl Display {
DeferredFormat::new(format.as_ref())
.with_time(self)
.to_owned()
DeferredFormat::new(format.as_ref()).with_time(self).clone()
}

/// Attempt to parse a `Time` using the provided string.
Expand Down
7 changes: 2 additions & 5 deletions src/utc_offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use crate::{
DeferredFormat, Duration, ParseResult,
};
#[cfg(not(feature = "std"))]
use alloc::{
borrow::ToOwned,
string::{String, ToString},
};
use alloc::string::{String, ToString};
use core::fmt::{self, Display};

/// An offset from UTC.
Expand Down Expand Up @@ -289,7 +286,7 @@ impl UtcOffset {
pub fn lazy_format(self, format: impl AsRef<str>) -> impl Display {
DeferredFormat::new(format.as_ref())
.with_offset(self)
.to_owned()
.clone()
}

/// Attempt to parse the `UtcOffset` using the provided string.
Expand Down
28 changes: 14 additions & 14 deletions time-macros-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ use quote::ToTokens;
use syn::parse_macro_input;
use time::Time;

macro_rules! impl_macros {
($($name:ident : $type:ty),* $(,)?) => {
$(
#[proc_macro_hack]
#[allow(clippy::unimplemented)]
pub fn $name(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
parse_macro_input!(input as $type).to_token_stream().into()
}
)*
};
#[proc_macro_hack]
#[allow(clippy::unimplemented)]
pub fn time(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
parse_macro_input!(input as Time).to_token_stream().into()
}

#[proc_macro_hack]
#[allow(clippy::unimplemented)]
pub fn offset(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
parse_macro_input!(input as Offset).to_token_stream().into()
}

impl_macros! {
time: Time,
offset: Offset,
date: Date,
#[proc_macro_hack]
#[allow(clippy::unimplemented)]
pub fn date(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
parse_macro_input!(input as Date).to_token_stream().into()
}

0 comments on commit bcb0b52

Please sign in to comment.