summaryrefslogtreecommitdiffstats
path: root/vendor/time-macros
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/time-macros
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/time-macros')
-rw-r--r--vendor/time-macros/.cargo-checksum.json2
-rw-r--r--vendor/time-macros/Cargo.toml6
-rw-r--r--vendor/time-macros/src/format_description/ast.rs42
-rw-r--r--vendor/time-macros/src/lib.rs50
-rw-r--r--vendor/time-macros/src/offset.rs5
-rw-r--r--vendor/time-macros/src/quote.rs1
-rw-r--r--vendor/time-macros/src/serde_format_description.rs25
-rw-r--r--vendor/time-macros/src/shim.rs117
-rw-r--r--vendor/time-macros/src/time.rs9
9 files changed, 77 insertions, 180 deletions
diff --git a/vendor/time-macros/.cargo-checksum.json b/vendor/time-macros/.cargo-checksum.json
index 9562cb38d..d3e6b760a 100644
--- a/vendor/time-macros/.cargo-checksum.json
+++ b/vendor/time-macros/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"74589b1a61b46282b57a9c7c723bf88105c73401b2397ea4044cc9d4d7bbd81b","LICENSE-Apache":"b8929fea28678da67251fb2daf9438f67503814211051861612441806d8edb05","LICENSE-MIT":"04620bf27e4a643dd47bf27652320c205acdb776c1f9f24bb8c3bfaba10804c5","src/date.rs":"ffcd3d0998ec67abb43a3f8eccc6104172f5061b855312b89d53bb82fece2460","src/datetime.rs":"5c7f6e07dc2f0dcfcd86216664df53bc008dbc86f346df57a9ff57f52fe43bc6","src/error.rs":"b3dea92631092068dd73e57e1cbf548f7ae85762826dcdea7fd6454bf357a50a","src/format_description/ast.rs":"2244ee0072e26ee686f5b8301eae8efd4bf53fc8e77104a88ef1d7f0fd15434b","src/format_description/format_item.rs":"03ff10699383e5ad08fe690199d45288f13363337abbc811a70b03a8b1703ab1","src/format_description/lexer.rs":"e7db7b6431f00c81b8d15a162088a1622ecd65bfb58d4e642c3c93a8dd5ae4ad","src/format_description/mod.rs":"f48c0ff590bc74529f06a98f60a6af5814bc30d1456bf0b81ac334c0b3f41bba","src/format_description/public/component.rs":"e2c2c8a189e2eb9f9354ff1d9d8edeafa34303e91dc58457df373e7e61c38b78","src/format_description/public/mod.rs":"5260592b310ea9e30808d30c92ea94c7bf1bdb171250a1342279e927d2528d73","src/format_description/public/modifier.rs":"37661e1f7cd9fd11a82f5a1ce6d5971686afa91e6feebc7b9d32df297e8b667f","src/helpers/mod.rs":"a8f8ed59a72b239d7a530357d212873f2e75ea924ec19a6d5d6e24a2baa8100c","src/helpers/string.rs":"3af2d0c701ca978c705922a272e76506dbdf0f376d44ed9ae7283086c67852ba","src/lib.rs":"4f799dcf9412cee499c0db951bd0972da73c11b6b39f7fe9c50615dbd2a3ae6f","src/offset.rs":"fc9341648e091b4d8f7bec47006c01c21cb038c7ef98bd36a492cf78e7533023","src/quote.rs":"e9a495682e436b5708e71113e0e10a32eb967148785f091cd25756781dad3173","src/serde_format_description.rs":"aa279c8005005fc87c52fa5e8be8ef8fc13ef456a18e3cd5d702ae81194ba4d9","src/shim.rs":"8083a3893f2224202f91d21c02df33df66a505ad1cf98dc9fa3f1b492ccf98c0","src/time.rs":"3c06562358aed7ef624319c96e3f9c150a069606ab930de98ac379ef16b08100","src/to_tokens.rs":"6636ea489c7484bad9b39f72d6956a04c95ce82d8462b12079cc03db778fd263"},"package":"fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36"} \ No newline at end of file
+{"files":{"Cargo.toml":"2e216c0b8c00ba8937bd4ff2698e535b5c3a6998ebd6740b018e8f09c62d45ae","LICENSE-Apache":"b8929fea28678da67251fb2daf9438f67503814211051861612441806d8edb05","LICENSE-MIT":"04620bf27e4a643dd47bf27652320c205acdb776c1f9f24bb8c3bfaba10804c5","src/date.rs":"ffcd3d0998ec67abb43a3f8eccc6104172f5061b855312b89d53bb82fece2460","src/datetime.rs":"5c7f6e07dc2f0dcfcd86216664df53bc008dbc86f346df57a9ff57f52fe43bc6","src/error.rs":"b3dea92631092068dd73e57e1cbf548f7ae85762826dcdea7fd6454bf357a50a","src/format_description/ast.rs":"e202485d6b6a3113fe8dec89ad2522f750ce08db92e8dbf299dfda2922307652","src/format_description/format_item.rs":"03ff10699383e5ad08fe690199d45288f13363337abbc811a70b03a8b1703ab1","src/format_description/lexer.rs":"e7db7b6431f00c81b8d15a162088a1622ecd65bfb58d4e642c3c93a8dd5ae4ad","src/format_description/mod.rs":"f48c0ff590bc74529f06a98f60a6af5814bc30d1456bf0b81ac334c0b3f41bba","src/format_description/public/component.rs":"e2c2c8a189e2eb9f9354ff1d9d8edeafa34303e91dc58457df373e7e61c38b78","src/format_description/public/mod.rs":"5260592b310ea9e30808d30c92ea94c7bf1bdb171250a1342279e927d2528d73","src/format_description/public/modifier.rs":"37661e1f7cd9fd11a82f5a1ce6d5971686afa91e6feebc7b9d32df297e8b667f","src/helpers/mod.rs":"a8f8ed59a72b239d7a530357d212873f2e75ea924ec19a6d5d6e24a2baa8100c","src/helpers/string.rs":"3af2d0c701ca978c705922a272e76506dbdf0f376d44ed9ae7283086c67852ba","src/lib.rs":"e4440db5493ac28f8210b1488b1b72eec9fd72e315cf00c164ac2429961c0f22","src/offset.rs":"4b9c001a954c1f121a572f5675073f7a4e46d00cc9eb77736bfea2df94ffd05b","src/quote.rs":"634a12b95236e4ab2b8ab70a1a4a2629113c3ce3cf6defefc7ffeb81544c1d89","src/serde_format_description.rs":"f1eb3cb54fa0ef86f3fa702dbac00816b34c6151745e7c7d4c7ff8cc92c2dc3d","src/time.rs":"d762e8f22f749d9546d5d2a78b8a0380510be27b4cd3fed375695d7982d8396e","src/to_tokens.rs":"6636ea489c7484bad9b39f72d6956a04c95ce82d8462b12079cc03db778fd263"},"package":"372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b"} \ No newline at end of file
diff --git a/vendor/time-macros/Cargo.toml b/vendor/time-macros/Cargo.toml
index 9dbc16e07..9017bfc6f 100644
--- a/vendor/time-macros/Cargo.toml
+++ b/vendor/time-macros/Cargo.toml
@@ -11,9 +11,9 @@
[package]
edition = "2021"
-rust-version = "1.63.0"
+rust-version = "1.65.0"
name = "time-macros"
-version = "0.2.8"
+version = "0.2.9"
authors = [
"Jacob Pratt <open-source@jhpratt.dev>",
"Time contributors",
@@ -36,7 +36,7 @@ repository = "https://github.com/time-rs/time"
proc-macro = true
[dependencies.time-core]
-version = "=0.1.0"
+version = "=0.1.1"
[features]
formatting = []
diff --git a/vendor/time-macros/src/format_description/ast.rs b/vendor/time-macros/src/format_description/ast.rs
index 497c8965d..f33c6d433 100644
--- a/vendor/time-macros/src/format_description/ast.rs
+++ b/vendor/time-macros/src/format_description/ast.rs
@@ -127,24 +127,24 @@ fn parse_component<'a, I: Iterator<Item = Result<lexer::Token<'a>, Error>>, cons
) -> Result<Item<'a>, Error> {
let leading_whitespace = tokens.next_if_whitespace();
- guard!(let Some(name) = tokens.next_if_not_whitespace() else {
+ let Some(name) = tokens.next_if_not_whitespace() else {
let span = match leading_whitespace {
Some(Spanned { value: _, span }) => span,
None => opening_bracket.to(opening_bracket),
};
return Err(span.error("expected component name"));
- });
+ };
if *name == b"optional" {
- guard!(let Some(whitespace) = tokens.next_if_whitespace() else {
+ let Some(whitespace) = tokens.next_if_whitespace() else {
return Err(name.span.error("expected whitespace after `optional`"));
- });
+ };
let nested = parse_nested::<_, VERSION>(whitespace.span.end, tokens)?;
- guard!(let Some(closing_bracket) = tokens.next_if_closing_bracket() else {
+ let Some(closing_bracket) = tokens.next_if_closing_bracket() else {
return Err(opening_bracket.error("unclosed bracket"));
- });
+ };
return Ok(Item::Optional {
opening_bracket,
@@ -157,18 +157,18 @@ fn parse_component<'a, I: Iterator<Item = Result<lexer::Token<'a>, Error>>, cons
}
if *name == b"first" {
- guard!(let Some(whitespace) = tokens.next_if_whitespace() else {
+ let Some(whitespace) = tokens.next_if_whitespace() else {
return Err(name.span.error("expected whitespace after `first`"));
- });
+ };
let mut nested_format_descriptions = Vec::new();
while let Ok(description) = parse_nested::<_, VERSION>(whitespace.span.end, tokens) {
nested_format_descriptions.push(description);
}
- guard!(let Some(closing_bracket) = tokens.next_if_closing_bracket() else {
+ let Some(closing_bracket) = tokens.next_if_closing_bracket() else {
return Err(opening_bracket.error("unclosed bracket"));
- });
+ };
return Ok(Item::First {
opening_bracket,
@@ -182,7 +182,7 @@ fn parse_component<'a, I: Iterator<Item = Result<lexer::Token<'a>, Error>>, cons
let mut modifiers = Vec::new();
let trailing_whitespace = loop {
- guard!(let Some(whitespace) = tokens.next_if_whitespace() else { break None });
+ let Some(whitespace) = tokens.next_if_whitespace() else { break None };
if let Some(location) = tokens.next_if_opening_bracket() {
return Err(location
@@ -190,13 +190,13 @@ fn parse_component<'a, I: Iterator<Item = Result<lexer::Token<'a>, Error>>, cons
.error("modifier must be of the form `key:value`"));
}
- guard!(let Some(Spanned { value, span }) = tokens.next_if_not_whitespace() else {
+ let Some(Spanned { value, span }) = tokens.next_if_not_whitespace() else {
break Some(whitespace);
- });
+ };
- guard!(let Some(colon_index) = value.iter().position(|&b| b == b':') else {
+ let Some(colon_index) = value.iter().position(|&b| b == b':') else {
return Err(span.error("modifier must be of the form `key:value`"));
- });
+ };
let key = &value[..colon_index];
let value = &value[colon_index + 1..];
@@ -215,9 +215,9 @@ fn parse_component<'a, I: Iterator<Item = Result<lexer::Token<'a>, Error>>, cons
});
};
- guard!(let Some(closing_bracket) = tokens.next_if_closing_bracket() else {
+ let Some(closing_bracket) = tokens.next_if_closing_bracket() else {
return Err(opening_bracket.error("unclosed bracket"));
- });
+ };
Ok(Item::Component {
_opening_bracket: unused(opening_bracket),
@@ -233,13 +233,13 @@ fn parse_nested<'a, I: Iterator<Item = Result<lexer::Token<'a>, Error>>, const V
last_location: Location,
tokens: &mut lexer::Lexed<I>,
) -> Result<NestedFormatDescription<'a>, Error> {
- guard!(let Some(opening_bracket) = tokens.next_if_opening_bracket() else {
+ let Some(opening_bracket) = tokens.next_if_opening_bracket() else {
return Err(last_location.error("expected opening bracket"));
- });
+ };
let items = parse_inner::<_, true, VERSION>(tokens).collect::<Result<_, _>>()?;
- guard!(let Some(closing_bracket) = tokens.next_if_closing_bracket() else {
+ let Some(closing_bracket) = tokens.next_if_closing_bracket() else {
return Err(opening_bracket.error("unclosed bracket"));
- });
+ };
let trailing_whitespace = tokens.next_if_whitespace();
Ok(NestedFormatDescription {
diff --git a/vendor/time-macros/src/lib.rs b/vendor/time-macros/src/lib.rs
index 84ad25113..ce62ac5be 100644
--- a/vendor/time-macros/src/lib.rs
+++ b/vendor/time-macros/src/lib.rs
@@ -42,9 +42,6 @@ macro_rules! bug {
#[macro_use]
mod quote;
-#[cfg(any(feature = "formatting", feature = "parsing"))]
-#[macro_use]
-mod shim;
mod date;
mod datetime;
@@ -231,36 +228,41 @@ pub fn serde_format_description(input: TokenStream) -> TokenStream {
// We now have two options. The user can either provide a format description as a string or
// they can provide a path to a format description. If the latter, all remaining tokens are
// assumed to be part of the path.
- let (format, raw_format_string) = match tokens.peek() {
+ let (format, format_description_display) = match tokens.peek() {
// string literal
Some(TokenTree::Literal(_)) => {
let (span, format_string) = helpers::get_string_literal(tokens)?;
let items = format_description::parse_with_version(version, &format_string, span)?;
let items: TokenStream =
items.into_iter().map(|item| quote! { #S(item), }).collect();
- let items = quote! { &[#S(items)] };
+ let items = quote! {
+ const ITEMS: &[::time::format_description::FormatItem<'_>] = &[#S(items)];
+ ITEMS
+ };
+ (items, String::from_utf8_lossy(&format_string).into_owned())
+ }
+ // path
+ Some(_) => {
+ let tokens = tokens.collect::<TokenStream>();
+ let tokens_string = tokens.to_string();
(
- items,
- Some(String::from_utf8_lossy(&format_string).into_owned()),
+ quote! {{
+ // We can't just do `super::path` because the path could be an absolute
+ // path. In that case, we'd be generating `super::::path`, which is invalid.
+ // Even if we took that into account, it's not possible to know if it's an
+ // external crate, which would just require emitting `path` directly. By
+ // taking this approach, we can leave it to the compiler to do the actual
+ // resolution.
+ mod __path_hack {
+ pub(super) use super::super::*;
+ pub(super) use #S(tokens) as FORMAT;
+ }
+ __path_hack::FORMAT
+ }},
+ tokens_string,
)
}
- // path
- Some(_) => (
- quote! {{
- // We can't just do `super::path` because the path could be an absolute path. In
- // that case, we'd be generating `super::::path`, which is invalid. Even if we
- // took that into account, it's not possible to know if it's an external crate,
- // which would just require emitting `path` directly. By taking this approach,
- // we can leave it to the compiler to do the actual resolution.
- mod __path_hack {
- pub(super) use super::super::*;
- pub(super) use #S(tokens.collect::<TokenStream>()) as FORMAT;
- }
- __path_hack::FORMAT
- }},
- None,
- ),
None => return Err(Error::UnexpectedEndOfInput),
};
@@ -268,7 +270,7 @@ pub fn serde_format_description(input: TokenStream) -> TokenStream {
mod_name,
formattable,
format,
- raw_format_string,
+ format_description_display,
))
})()
.unwrap_or_else(|err: Error| err.to_compile_error_standalone())
diff --git a/vendor/time-macros/src/offset.rs b/vendor/time-macros/src/offset.rs
index c2099073f..62d7a223d 100644
--- a/vendor/time-macros/src/offset.rs
+++ b/vendor/time-macros/src/offset.rs
@@ -1,6 +1,7 @@
use std::iter::Peekable;
use proc_macro::{token_stream, Span, TokenTree};
+use time_core::convert::*;
use crate::helpers::{consume_any_ident, consume_number, consume_punct};
use crate::to_tokens::ToTokenTree;
@@ -58,14 +59,14 @@ pub(crate) fn parse(chars: &mut Peekable<token_stream::IntoIter>) -> Result<Offs
span_start: Some(hours_span),
span_end: Some(hours_span),
})
- } else if minutes >= 60 {
+ } else if minutes >= Minute.per(Hour) as _ {
Err(Error::InvalidComponent {
name: "minute",
value: minutes.to_string(),
span_start: Some(minutes_span),
span_end: Some(minutes_span),
})
- } else if seconds >= 60 {
+ } else if seconds >= Second.per(Minute) as _ {
Err(Error::InvalidComponent {
name: "second",
value: seconds.to_string(),
diff --git a/vendor/time-macros/src/quote.rs b/vendor/time-macros/src/quote.rs
index 295abe115..4d3dcbca0 100644
--- a/vendor/time-macros/src/quote.rs
+++ b/vendor/time-macros/src/quote.rs
@@ -67,6 +67,7 @@ macro_rules! quote_inner {
($ts:ident ! $($tail:tt)*) => { sym!($ts '!'); quote_inner!($ts $($tail)*); };
($ts:ident | $($tail:tt)*) => { sym!($ts '|'); quote_inner!($ts $($tail)*); };
($ts:ident * $($tail:tt)*) => { sym!($ts '*'); quote_inner!($ts $($tail)*); };
+ ($ts:ident + $($tail:tt)*) => { sym!($ts '+'); quote_inner!($ts $($tail)*); };
// Identifier
($ts:ident $i:ident $($tail:tt)*) => {
diff --git a/vendor/time-macros/src/serde_format_description.rs b/vendor/time-macros/src/serde_format_description.rs
index c09a4e9e2..1d2f2e2c1 100644
--- a/vendor/time-macros/src/serde_format_description.rs
+++ b/vendor/time-macros/src/serde_format_description.rs
@@ -4,12 +4,10 @@ pub(crate) fn build(
mod_name: Ident,
ty: TokenTree,
format: TokenStream,
- raw_format_string: Option<String>,
+ format_description_display: String,
) -> TokenStream {
let ty_s = &*ty.to_string();
- let format_description_display = raw_format_string.unwrap_or_else(|| format.to_string());
-
let visitor = if cfg!(feature = "parsing") {
quote! {
struct Visitor;
@@ -34,7 +32,7 @@ pub(crate) fn build(
self,
value: &str
) -> Result<__TimeSerdeType, E> {
- __TimeSerdeType::parse(value, &DESCRIPTION).map_err(E::custom)
+ __TimeSerdeType::parse(value, &description()).map_err(E::custom)
}
}
@@ -81,7 +79,7 @@ pub(crate) fn build(
) -> Result<S::Ok, S::Error> {
use ::serde::Serialize;
datetime
- .format(&DESCRIPTION)
+ .format(&description())
.map_err(::time::error::Format::into_invalid_serde_value::<S>)?
.serialize(serializer)
}
@@ -110,7 +108,7 @@ pub(crate) fn build(
serializer: S,
) -> Result<S::Ok, S::Error> {
use ::serde::Serialize;
- option.map(|datetime| datetime.format(&DESCRIPTION))
+ option.map(|datetime| datetime.format(&description()))
.transpose()
.map_err(::time::error::Format::into_invalid_serde_value::<S>)?
.serialize(serializer)
@@ -141,18 +139,29 @@ pub(crate) fn build(
quote!()
};
+ let fd_traits = match (cfg!(feature = "formatting"), cfg!(feature = "parsing")) {
+ (false, false) => {
+ bug!("serde_format_description::build called without formatting or parsing enabled")
+ }
+ (false, true) => quote! { ::time::parsing::Parsable },
+ (true, false) => quote! { ::time::formatting::Formattable },
+ (true, true) => quote! { ::time::formatting::Formattable + ::time::parsing::Parsable },
+ };
+
quote! {
mod #(mod_name) {
use ::time::#(ty) as __TimeSerdeType;
- const DESCRIPTION: &[::time::format_description::FormatItem<'_>] = #S(format);
+ const fn description() -> impl #S(fd_traits) {
+ #S(format)
+ }
#S(visitor)
#S(serialize_primary)
#S(deserialize_primary)
pub(super) mod option {
- use super::{DESCRIPTION, __TimeSerdeType};
+ use super::{description, __TimeSerdeType};
#S(deserialize_option_imports)
#S(serialize_option)
diff --git a/vendor/time-macros/src/shim.rs b/vendor/time-macros/src/shim.rs
deleted file mode 100644
index f31e5d501..000000000
--- a/vendor/time-macros/src/shim.rs
+++ /dev/null
@@ -1,117 +0,0 @@
-#![allow(unused_macros)]
-
-// The following code is copyright 2016 Alex Burka. Available under the MIT OR Apache-2.0 license.
-// Some adaptations have been made to the original code.
-
-pub(crate) enum LetElseBodyMustDiverge {}
-
-#[allow(clippy::missing_docs_in_private_items)]
-macro_rules! __guard_output {
- ((($($imms:ident)*) ($($muts:ident)*)),
- [($($pattern:tt)*) ($rhs:expr) ($diverge:expr)]) => {
- __guard_impl!(@as_stmt
- let ($($imms,)* $(mut $muts,)*) = {
- #[allow(unused_mut)]
- match $rhs {
- $($pattern)* => {
- ($($imms,)* $($muts,)*)
- },
- _ => {
- let _: $crate::shim::LetElseBodyMustDiverge = $diverge;
- },
- }
- }
- )
- };
-}
-
-macro_rules! __guard_impl {
- (@as_stmt $s:stmt) => { $s };
- (@collect () -> $($rest:tt)*) => {
- __guard_output!($($rest)*)
- };
- (@collect (($($inside:tt)*) $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($inside)* $($tail)*) -> $idents, $thru)
- };
- (@collect ({$($inside:tt)*} $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($inside)* $($tail)*) -> $idents, $thru)
- };
- (@collect ([$($inside:tt)*] $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($inside)* $($tail)*) -> $idents, $thru)
- };
- (@collect (, $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> $idents, $thru)
- };
- (@collect (.. $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> $idents, $thru)
- };
- (@collect (@ $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> $idents, $thru)
- };
- (@collect (_ $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> $idents, $thru)
- };
- (@collect (& $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> $idents, $thru)
- };
- (@collect (:: <$($generic:tt),*> $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> $idents, $thru)
- };
- (@collect (:: $pathend:ident $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> $idents, $thru)
- };
- (@collect (| $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect () -> $idents, $thru)
- };
- (@collect ($id:ident: $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> $idents, $thru)
- };
- (@collect ($pathcomp:ident :: $pathend:ident $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> $idents, $thru)
- };
- (@collect ($id:ident ($($inside:tt)*) $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($inside)* $($tail)*) -> $idents, $thru)
- };
- (@collect ($id:ident {$($inside:tt)*} $($tail:tt)*) -> $idents:tt, $thru:tt) => {
- __guard_impl!(@collect ($($inside)* $($tail)*) -> $idents, $thru)
- };
- (@collect (ref mut $id:ident $($tail:tt)*) -> (($($imms:ident)*) $muts:tt), $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> (($($imms)* $id) $muts), $thru)
- };
- (@collect (ref $id:ident $($tail:tt)*) -> (($($imms:ident)*) $muts:tt), $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> (($($imms)* $id) $muts), $thru)
- };
- (@collect (mut $id:ident $($tail:tt)*) -> ($imms:tt ($($muts:ident)*)), $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> ($imms ($($muts)* $id)), $thru)
- };
- (@collect ($id:ident $($tail:tt)*) -> (($($imms:ident)*) $muts:tt), $thru:tt) => {
- __guard_impl!(@collect ($($tail)*) -> (($($imms)* $id) $muts), $thru)
- };
- (@split (else { $($diverge:tt)* } = $($tail:tt)*) -> ($pat:tt)) => {
- __guard_impl!(@collect $pat -> (() ()), [$pat ($($tail)*) ({ $($diverge)* })])
- };
- (@split (= $($tail:tt)*) -> ($pat:tt)) => {
- __guard_impl!(@split expr ($($tail)*) -> ($pat ()))
- };
- (@split ($head:tt $($tail:tt)*) -> (($($pat:tt)*))) => {
- __guard_impl!(@split ($($tail)*) -> (($($pat)* $head)))
- };
- (@split expr (else { $($tail:tt)* }) -> ($pat:tt $expr:tt)) => {
- __guard_impl!(@collect $pat -> (() ()), [$pat $expr ({ $($tail)* })])
- };
- (@split expr (else { $($body:tt)* } $($tail:tt)*) -> ($pat:tt ($($expr:tt)*))) => {
- __guard_impl!(@split expr ($($tail)*) -> ($pat ($($expr)* else { $($body)* })))
- };
- (@split expr ($head:tt $($tail:tt)*) -> ($pat:tt ($($expr:tt)*))) => {
- __guard_impl!(@split expr ($($tail)*) -> ($pat ($($expr)* $head)))
- };
- (let $($tail:tt)*) => {
- __guard_impl!(@split ($($tail)*) -> (()))
- };
-}
-
-macro_rules! guard {
- ($($input:tt)*) => {
- __guard_impl!($($input)*)
- };
-}
diff --git a/vendor/time-macros/src/time.rs b/vendor/time-macros/src/time.rs
index 719e2051f..96314de1f 100644
--- a/vendor/time-macros/src/time.rs
+++ b/vendor/time-macros/src/time.rs
@@ -1,6 +1,7 @@
use std::iter::Peekable;
use proc_macro::{token_stream, Span, TokenTree};
+use time_core::convert::*;
use crate::helpers::{consume_any_ident, consume_number, consume_punct};
use crate::to_tokens::ToTokenTree;
@@ -72,21 +73,21 @@ pub(crate) fn parse(chars: &mut Peekable<token_stream::IntoIter>) -> Result<Time
(hour, Period::Pm) => hour + 12,
};
- if hour >= 24 {
+ if hour >= Hour.per(Day) {
Err(Error::InvalidComponent {
name: "hour",
value: hour.to_string(),
span_start: Some(hour_span),
span_end: Some(period_span.unwrap_or(hour_span)),
})
- } else if minute >= 60 {
+ } else if minute >= Minute.per(Hour) {
Err(Error::InvalidComponent {
name: "minute",
value: minute.to_string(),
span_start: Some(minute_span),
span_end: Some(minute_span),
})
- } else if second >= 60. {
+ } else if second >= Second.per(Minute) as _ {
Err(Error::InvalidComponent {
name: "second",
value: second.to_string(),
@@ -98,7 +99,7 @@ pub(crate) fn parse(chars: &mut Peekable<token_stream::IntoIter>) -> Result<Time
hour,
minute,
second: second.trunc() as _,
- nanosecond: (second.fract() * 1_000_000_000.).round() as _,
+ nanosecond: (second.fract() * Nanosecond.per(Second) as f64).round() as _,
})
}
}