From bcb0b5249f2348b7b7d5cc97b5b4a41f328b38cb Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Sat, 12 Jun 2021 20:15:41 -0400 Subject: [PATCH] Fix all lints --- .github/workflows/build.yaml | 6 ------ src/date.rs | 9 ++------- src/lib.rs | 1 + src/offset_date_time.rs | 7 ++----- src/primitive_date_time.rs | 7 ++----- src/time_mod.rs | 9 ++------- src/utc_offset.rs | 7 ++----- time-macros-impl/src/lib.rs | 28 ++++++++++++++-------------- 8 files changed, 25 insertions(+), 49 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9b0621078..0c0a0046a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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: @@ -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 diff --git a/src/date.rs b/src/date.rs index 51cce3c02..5e91aa421 100644 --- a/src/date.rs +++ b/src/date.rs @@ -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}, @@ -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) -> 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. diff --git a/src/lib.rs b/src/lib.rs index cfa1e0c5e..22fadd575 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, diff --git a/src/offset_date_time.rs b/src/offset_date_time.rs index 9b7410c10..b9dfe9413 100644 --- a/src/offset_date_time.rs +++ b/src/offset_date_time.rs @@ -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::{ @@ -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. diff --git a/src/primitive_date_time.rs b/src/primitive_date_time.rs index 83e92a1ee..e0e84e8a5 100644 --- a/src/primitive_date_time.rs +++ b/src/primitive_date_time.rs @@ -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; @@ -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. diff --git a/src/time_mod.rs b/src/time_mod.rs index 1944b3671..54e2bdf84 100644 --- a/src/time_mod.rs +++ b/src/time_mod.rs @@ -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, @@ -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) -> 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. diff --git a/src/utc_offset.rs b/src/utc_offset.rs index 547f5cc88..aa3788c3d 100644 --- a/src/utc_offset.rs +++ b/src/utc_offset.rs @@ -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. @@ -289,7 +286,7 @@ impl UtcOffset { pub fn lazy_format(self, format: impl AsRef) -> impl Display { DeferredFormat::new(format.as_ref()) .with_offset(self) - .to_owned() + .clone() } /// Attempt to parse the `UtcOffset` using the provided string. diff --git a/time-macros-impl/src/lib.rs b/time-macros-impl/src/lib.rs index 3d9773813..ee64926d4 100644 --- a/time-macros-impl/src/lib.rs +++ b/time-macros-impl/src/lib.rs @@ -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() }