Skip to content

Commit

Permalink
cargo fmt w/ rustfmt 1.8.0-nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisorlando committed Sep 28, 2024
1 parent 72a8ecd commit 4d99768
Show file tree
Hide file tree
Showing 39 changed files with 82 additions and 89 deletions.
4 changes: 2 additions & 2 deletions time-macros/src/date.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::iter::Peekable;

use num_conv::Truncate;
use proc_macro::{token_stream, TokenTree};
use proc_macro::{TokenTree, token_stream};
use time_core::util::{days_in_year, weeks_in_year};

use crate::Error;
use crate::helpers::{
consume_any_ident, consume_number, consume_punct, days_in_year_month, ymd_to_yo, ywd_to_yo,
};
use crate::to_tokens::ToTokenTree;
use crate::Error;

#[cfg(feature = "large-dates")]
const MAX_YEAR: i32 = 999_999;
Expand Down
2 changes: 1 addition & 1 deletion time-macros/src/datetime.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::iter::Peekable;

use proc_macro::{token_stream, Ident, Span, TokenTree};
use proc_macro::{Ident, Span, TokenTree, token_stream};

use crate::date::Date;
use crate::error::Error;
Expand Down
2 changes: 1 addition & 1 deletion time-macros/src/format_description/ast.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::iter;

use super::{lexer, unused, Error, Location, Spanned, SpannedValue, Unused};
use super::{Error, Location, Spanned, SpannedValue, Unused, lexer, unused};

pub(super) enum Item<'a> {
Literal(Spanned<&'a [u8]>),
Expand Down
2 changes: 1 addition & 1 deletion time-macros/src/format_description/format_item.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::num::NonZeroU16;
use std::str::{self, FromStr};

use super::{ast, unused, Error, Span, Spanned, Unused};
use super::{Error, Span, Spanned, Unused, ast, unused};

pub(super) fn parse<'a>(
ast_items: impl Iterator<Item = Result<ast::Item<'a>, Error>>,
Expand Down
2 changes: 1 addition & 1 deletion time-macros/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::iter::Peekable;
use std::str::FromStr;

use num_conv::prelude::*;
use proc_macro::{token_stream, Span, TokenTree};
use proc_macro::{Span, TokenTree, token_stream};
use time_core::util::{days_in_year, is_leap_year};

use crate::Error;
Expand Down
4 changes: 2 additions & 2 deletions time-macros/src/offset.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::iter::Peekable;

use num_conv::prelude::*;
use proc_macro::{token_stream, Span, TokenTree};
use proc_macro::{Span, TokenTree, token_stream};
use time_core::convert::*;

use crate::Error;
use crate::helpers::{consume_any_ident, consume_number, consume_punct};
use crate::to_tokens::ToTokenTree;
use crate::Error;

pub(crate) struct Offset {
pub(crate) hours: i8,
Expand Down
4 changes: 2 additions & 2 deletions time-macros/src/time.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::iter::Peekable;

use proc_macro::{token_stream, Span, TokenTree};
use proc_macro::{Span, TokenTree, token_stream};
use time_core::convert::*;

use crate::Error;
use crate::helpers::{consume_any_ident, consume_number, consume_punct};
use crate::to_tokens::ToTokenTree;
use crate::Error;

enum Period {
Am,
Expand Down
20 changes: 8 additions & 12 deletions time/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::internal_macros::{
#[cfg(feature = "parsing")]
use crate::parsing::Parsable;
use crate::util::{days_in_year, days_in_year_month, is_leap_year, weeks_in_year};
use crate::{error, Duration, Month, PrimitiveDateTime, Time, Weekday};
use crate::{Duration, Month, PrimitiveDateTime, Time, Weekday, error};

type Year = RangedI32<MIN_YEAR, MAX_YEAR>;

Expand Down Expand Up @@ -1376,17 +1376,13 @@ impl SmartDisplay for Date {
day => width(2),
);

Metadata::new(
formatted_width,
self,
DateMetadata {
year_width,
display_sign,
year,
month: u8::from(month),
day,
},
)
Metadata::new(formatted_width, self, DateMetadata {
year_width,
display_sign,
year,
month: u8::from(month),
day,
})
}

fn fmt_with_metadata(
Expand Down
6 changes: 3 additions & 3 deletions time/src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ use core::time::Duration as StdDuration;
use deranged::RangedI32;
use num_conv::prelude::*;

#[cfg(feature = "std")]
#[allow(deprecated)]
use crate::Instant;
use crate::convert::*;
use crate::error;
use crate::internal_macros::{
const_try_opt, expect_opt, impl_add_assign, impl_div_assign, impl_mul_assign, impl_sub_assign,
};
#[cfg(feature = "std")]
#[allow(deprecated)]
use crate::Instant;

/// By explicitly inserting this enum where padding is expected, the compiler is able to better
/// perform niche value optimization.
Expand Down
2 changes: 1 addition & 1 deletion time/src/ext/numerical_duration.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::convert::*;
use crate::Duration;
use crate::convert::*;

/// Sealed trait to prevent downstream implementations.
mod sealed {
Expand Down
2 changes: 1 addition & 1 deletion time/src/format_description/parse/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloc::string::String;
use alloc::vec::Vec;
use core::iter;

use super::{lexer, unused, Error, Location, Spanned, SpannedValue, Unused};
use super::{Error, Location, Spanned, SpannedValue, Unused, lexer, unused};
use crate::internal_macros::bug;

/// One part of a complete format description.
Expand Down
2 changes: 1 addition & 1 deletion time/src/format_description/parse/format_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloc::string::String;
use core::num::NonZeroU16;
use core::str::{self, FromStr};

use super::{ast, unused, Error, Span, Spanned};
use super::{Error, Span, Spanned, ast, unused};
use crate::internal_macros::bug;

/// Parse an AST iterator into a sequence of format items.
Expand Down
2 changes: 1 addition & 1 deletion time/src/format_description/parse/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use core::iter;

use super::{unused, Error, Location, Spanned, SpannedValue};
use super::{Error, Location, Spanned, SpannedValue, unused};

/// An iterator over the lexed tokens.
pub(super) struct Lexed<I: Iterator> {
Expand Down
4 changes: 2 additions & 2 deletions time/src/formatting/formattable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use crate::format_description::well_known::iso8601::EncodedConfig;
use crate::format_description::well_known::{Iso8601, Rfc2822, Rfc3339};
use crate::format_description::{BorrowedFormatItem, OwnedFormatItem};
use crate::formatting::{
format_component, format_number_pad_zero, iso8601, write, MONTH_NAMES, WEEKDAY_NAMES,
MONTH_NAMES, WEEKDAY_NAMES, format_component, format_number_pad_zero, iso8601, write,
};
use crate::{error, Date, Time, UtcOffset};
use crate::{Date, Time, UtcOffset, error};

/// A type that describes a format.
///
Expand Down
4 changes: 2 additions & 2 deletions time/src/formatting/iso8601.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use std::io;
use num_conv::prelude::*;

use crate::convert::*;
use crate::format_description::well_known::Iso8601;
use crate::format_description::well_known::iso8601::{
DateKind, EncodedConfig, OffsetPrecision, TimePrecision,
};
use crate::format_description::well_known::Iso8601;
use crate::formatting::{format_float, format_number_pad_zero, write, write_if, write_if_else};
use crate::{error, Date, Time, UtcOffset};
use crate::{Date, Time, UtcOffset, error};

/// Format the date portion of ISO 8601.
pub(super) fn format_date<const CONFIG: EncodedConfig>(
Expand Down
4 changes: 2 additions & 2 deletions time/src/formatting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use num_conv::prelude::*;
pub use self::formattable::Formattable;
use crate::convert::*;
use crate::ext::DigitCount;
use crate::format_description::{modifier, Component};
use crate::{error, Date, OffsetDateTime, Time, UtcOffset};
use crate::format_description::{Component, modifier};
use crate::{Date, OffsetDateTime, Time, UtcOffset, error};

#[allow(clippy::missing_docs_in_private_items)]
const MONTH_NAMES: [&[u8]; 12] = [
Expand Down
2 changes: 1 addition & 1 deletion time/src/instant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use core::ops::{Add, Sub};
use core::time::Duration as StdDuration;
use std::time::Instant as StdInstant;

use crate::internal_macros::{impl_add_assign, impl_sub_assign};
use crate::Duration;
use crate::internal_macros::{impl_add_assign, impl_sub_assign};

/// A measurement of a monotonically non-decreasing clock. Opaque and useful only with [`Duration`].
///
Expand Down
2 changes: 1 addition & 1 deletion time/src/offset_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::internal_macros::{
};
#[cfg(feature = "parsing")]
use crate::parsing::Parsable;
use crate::{error, util, Date, Duration, Month, PrimitiveDateTime, Time, UtcOffset, Weekday};
use crate::{Date, Duration, Month, PrimitiveDateTime, Time, UtcOffset, Weekday, error, util};

/// The Julian day of the Unix epoch.
// Safety: `ordinal` is not zero.
Expand Down
2 changes: 1 addition & 1 deletion time/src/parsing/combinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pub(crate) mod rfc;
use num_conv::prelude::*;

use crate::format_description::modifier::Padding;
use crate::parsing::shim::{Integer, IntegerParseBytes};
use crate::parsing::ParsedItem;
use crate::parsing::shim::{Integer, IntegerParseBytes};

/// Parse a "+" or "-" sign. Returns the ASCII byte representing the sign, if present.
pub(crate) const fn sign(input: &[u8]) -> Option<ParsedItem<'_, u8>> {
Expand Down
4 changes: 2 additions & 2 deletions time/src/parsing/combinator/rfc/iso8601.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
//!
//! [ISO 8601]: https://www.iso.org/iso-8601-date-and-time-format.html

use core::num::{NonZeroU16, NonZeroU8};
use core::num::{NonZeroU8, NonZeroU16};

use num_conv::prelude::*;

use crate::parsing::combinator::{any_digit, ascii_char, exactly_n_digits, first_match, sign};
use crate::parsing::ParsedItem;
use crate::parsing::combinator::{any_digit, ascii_char, exactly_n_digits, first_match, sign};
use crate::{Month, Weekday};

/// What kind of format is being parsed. This is used to ensure each part of the format (date, time,
Expand Down
2 changes: 1 addition & 1 deletion time/src/parsing/combinator/rfc/rfc2822.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//!
//! [RFC 2822]: https://datatracker.ietf.org/doc/html/rfc2822

use crate::parsing::ParsedItem;
use crate::parsing::combinator::rfc::rfc2234::wsp;
use crate::parsing::combinator::{ascii_char, one_or_more, zero_or_more};
use crate::parsing::ParsedItem;

/// Consume the `fws` rule.
// The full rule is equivalent to /\r\n[ \t]+|[ \t]+(?:\r\n[ \t]+)*/
Expand Down
4 changes: 2 additions & 2 deletions time/src/parsing/component.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//! Parsing implementations for all [`Component`](crate::format_description::Component)s.

use core::num::{NonZeroU16, NonZeroU8};
use core::num::{NonZeroU8, NonZeroU16};

use num_conv::prelude::*;

use crate::convert::*;
use crate::format_description::modifier;
use crate::parsing::ParsedItem;
#[cfg(feature = "large-dates")]
use crate::parsing::combinator::n_to_m_digits_padded;
use crate::parsing::combinator::{
any_digit, exactly_n_digits, exactly_n_digits_padded, first_match, n_to_m_digits, opt, sign,
};
use crate::parsing::ParsedItem;
use crate::{Month, Weekday};

// region: date components
Expand Down
4 changes: 2 additions & 2 deletions time/src/parsing/iso8601.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use num_conv::prelude::*;
use crate::convert::*;
use crate::error;
use crate::error::ParseFromDescription::{InvalidComponent, InvalidLiteral};
use crate::format_description::well_known::iso8601::EncodedConfig;
use crate::format_description::well_known::Iso8601;
use crate::format_description::well_known::iso8601::EncodedConfig;
use crate::parsing::combinator::rfc::iso8601::{
day, dayk, dayo, float, hour, min, month, week, year, ExtendedKind,
ExtendedKind, day, dayk, dayo, float, hour, min, month, week, year,
};
use crate::parsing::combinator::{ascii_char, sign};
use crate::parsing::{Parsed, ParsedItem};
Expand Down
6 changes: 3 additions & 3 deletions time/src/parsing/parsable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use core::ops::Deref;
use num_conv::prelude::*;

use crate::error::TryFromParsed;
use crate::format_description::well_known::iso8601::EncodedConfig;
use crate::format_description::well_known::{Iso8601, Rfc2822, Rfc3339};
use crate::format_description::BorrowedFormatItem;
#[cfg(feature = "alloc")]
use crate::format_description::OwnedFormatItem;
use crate::format_description::well_known::iso8601::EncodedConfig;
use crate::format_description::well_known::{Iso8601, Rfc2822, Rfc3339};
use crate::internal_macros::bug;
use crate::parsing::{Parsed, ParsedItem};
use crate::{error, Date, Month, OffsetDateTime, Time, UtcOffset, Weekday};
use crate::{Date, Month, OffsetDateTime, Time, UtcOffset, Weekday, error};

/// A type that can be parsed.
#[cfg_attr(docsrs, doc(notable_trait))]
Expand Down
19 changes: 10 additions & 9 deletions time/src/parsing/parsed.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Information parsed from an input and format description.

use core::num::{NonZeroU16, NonZeroU8};
use core::num::{NonZeroU8, NonZeroU16};

use deranged::{
OptionRangedI128, OptionRangedI32, OptionRangedI8, OptionRangedU16, OptionRangedU32,
OptionRangedU8, RangedI128, RangedI32, RangedI8, RangedU16, RangedU32, RangedU8,
OptionRangedI8, OptionRangedI32, OptionRangedI128, OptionRangedU8, OptionRangedU16,
OptionRangedU32, RangedI8, RangedI32, RangedI128, RangedU8, RangedU16, RangedU32,
};
use num_conv::prelude::*;
use num_conv::{CastUnsigned, Truncate};
Expand All @@ -14,15 +14,16 @@ use crate::date::{MAX_YEAR, MIN_YEAR};
use crate::error::TryFromParsed::InsufficientInformation;
#[cfg(feature = "alloc")]
use crate::format_description::OwnedFormatItem;
use crate::format_description::{modifier, BorrowedFormatItem, Component};
use crate::format_description::{BorrowedFormatItem, Component, modifier};
use crate::internal_macros::{bug, const_try_opt};
use crate::parsing::ParsedItem;
use crate::parsing::component::{
parse_day, parse_end, parse_hour, parse_ignore, parse_minute, parse_month, parse_offset_hour,
parse_offset_minute, parse_offset_second, parse_ordinal, parse_period, parse_second,
parse_subsecond, parse_unix_timestamp, parse_week_number, parse_weekday, parse_year, Period,
Period, parse_day, parse_end, parse_hour, parse_ignore, parse_minute, parse_month,
parse_offset_hour, parse_offset_minute, parse_offset_second, parse_ordinal, parse_period,
parse_second, parse_subsecond, parse_unix_timestamp, parse_week_number, parse_weekday,
parse_year,
};
use crate::parsing::ParsedItem;
use crate::{error, Date, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday};
use crate::{Date, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday, error};

/// Sealed to prevent downstream implementations.
mod sealed {
Expand Down
2 changes: 1 addition & 1 deletion time/src/primitive_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::formatting::Formattable;
use crate::internal_macros::{const_try, const_try_opt};
#[cfg(feature = "parsing")]
use crate::parsing::Parsable;
use crate::{error, util, Date, Duration, Month, OffsetDateTime, Time, UtcOffset, Weekday};
use crate::{Date, Duration, Month, OffsetDateTime, Time, UtcOffset, Weekday, error, util};

/// Combined date and time.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
Expand Down
2 changes: 1 addition & 1 deletion time/src/quickcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

use alloc::boxed::Box;

use quickcheck::{empty_shrinker, single_shrinker, Arbitrary, Gen};
use quickcheck::{Arbitrary, Gen, empty_shrinker, single_shrinker};

use crate::{Date, Duration, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday};

Expand Down
2 changes: 1 addition & 1 deletion time/src/rand.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Implementation of [`Distribution`] for various structs.

use rand::distributions::{Distribution, Standard};
use rand::Rng;
use rand::distributions::{Distribution, Standard};

use crate::{Date, Duration, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday};

Expand Down
8 changes: 4 additions & 4 deletions time/src/serde/iso8601.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
#[cfg(feature = "parsing")]
use core::marker::PhantomData;

#[cfg(feature = "formatting")]
use serde::ser::Error as _;
#[cfg(feature = "parsing")]
use serde::Deserializer;
#[cfg(feature = "formatting")]
use serde::ser::Error as _;
#[cfg(feature = "formatting")]
use serde::{Serialize, Serializer};

#[cfg(feature = "parsing")]
use super::Visitor;
use crate::format_description::well_known::iso8601::{Config, EncodedConfig};
use crate::format_description::well_known::Iso8601;
use crate::OffsetDateTime;
use crate::format_description::well_known::Iso8601;
use crate::format_description::well_known::iso8601::{Config, EncodedConfig};

/// The configuration of ISO 8601 used for serde implementations.
pub(crate) const SERDE_CONFIG: EncodedConfig =
Expand Down
Loading

0 comments on commit 4d99768

Please sign in to comment.