summaryrefslogtreecommitdiffstats
path: root/vendor/time-macros/src/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/time-macros/src/helpers')
-rw-r--r--vendor/time-macros/src/helpers/mod.rs8
-rw-r--r--vendor/time-macros/src/helpers/string.rs8
2 files changed, 7 insertions, 9 deletions
diff --git a/vendor/time-macros/src/helpers/mod.rs b/vendor/time-macros/src/helpers/mod.rs
index cbf3ba3ed..56300b3e6 100644
--- a/vendor/time-macros/src/helpers/mod.rs
+++ b/vendor/time-macros/src/helpers/mod.rs
@@ -4,17 +4,15 @@ mod string;
use std::iter::Peekable;
use std::str::FromStr;
-#[cfg(any(feature = "formatting", feature = "parsing"))]
-use proc_macro::TokenStream;
use proc_macro::{token_stream, Span, TokenTree};
use time_core::util::{days_in_year, is_leap_year};
use crate::Error;
#[cfg(any(feature = "formatting", feature = "parsing"))]
-pub(crate) fn get_string_literal(tokens: TokenStream) -> Result<(Span, Vec<u8>), Error> {
- let mut tokens = tokens.into_iter();
-
+pub(crate) fn get_string_literal(
+ mut tokens: impl Iterator<Item = TokenTree>,
+) -> Result<(Span, Vec<u8>), Error> {
match (tokens.next(), tokens.next()) {
(Some(TokenTree::Literal(literal)), None) => string::parse(&literal),
(Some(tree), None) => Err(Error::ExpectedString {
diff --git a/vendor/time-macros/src/helpers/string.rs b/vendor/time-macros/src/helpers/string.rs
index fa3780f5e..6b478f60d 100644
--- a/vendor/time-macros/src/helpers/string.rs
+++ b/vendor/time-macros/src/helpers/string.rs
@@ -57,7 +57,7 @@ fn parse_lit_str_cooked(mut s: &str) -> Vec<u8> {
continue 'outer;
}
},
- _ => unreachable!("invalid escape"),
+ _ => bug!("invalid escape"),
}
}
b'\r' => {
@@ -120,7 +120,7 @@ fn parse_lit_byte_str_cooked(mut v: &[u8]) -> Vec<u8> {
continue 'outer;
}
},
- _ => unreachable!("invalid escape"),
+ _ => bug!("invalid escape"),
}
}
b'\r' => {
@@ -151,7 +151,7 @@ where
b'0'..=b'9' => b1 - b'0',
b'a'..=b'f' => 10 + (b1 - b'a'),
b'A'..=b'F' => 10 + (b1 - b'A'),
- _ => unreachable!("invalid hex escape"),
+ _ => bug!("invalid hex escape"),
};
(ch, &s[2..])
}
@@ -172,7 +172,7 @@ fn backslash_u(mut s: &str) -> (char, &str) {
continue;
}
b'}' if digits != 0 => break,
- _ => unreachable!("invalid unicode escape"),
+ _ => bug!("invalid unicode escape"),
};
ch *= 0x10;
ch += u32::from(digit);