diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/time-macros/src/quote.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.tar.xz rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/time-macros/src/quote.rs | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/vendor/time-macros/src/quote.rs b/vendor/time-macros/src/quote.rs deleted file mode 100644 index 2fe86cc98..000000000 --- a/vendor/time-macros/src/quote.rs +++ /dev/null @@ -1,134 +0,0 @@ -macro_rules! quote { - () => (::proc_macro::TokenStream::new()); - ($($x:tt)*) => {{ - let mut ts = ::proc_macro::TokenStream::new(); - let ts_mut = &mut ts; - quote_inner!(ts_mut $($x)*); - ts - }}; -} - -#[cfg(any(feature = "formatting", feature = "parsing"))] -macro_rules! quote_append { - ($ts:ident $($x:tt)*) => {{ - quote_inner!($ts $($x)*); - }}; -} - -macro_rules! quote_group { - ({ $($x:tt)* }) => { - ::proc_macro::TokenTree::Group(::proc_macro::Group::new( - ::proc_macro::Delimiter::Brace, - quote!($($x)*) - )) - }; -} - -macro_rules! sym { - ($ts:ident $x:tt $y:tt) => { - $ts.extend([ - ::proc_macro::TokenTree::from(::proc_macro::Punct::new( - $x, - ::proc_macro::Spacing::Joint, - )), - ::proc_macro::TokenTree::from(::proc_macro::Punct::new( - $y, - ::proc_macro::Spacing::Alone, - )), - ]); - }; - ($ts:ident $x:tt) => { - $ts.extend([::proc_macro::TokenTree::from(::proc_macro::Punct::new( - $x, - ::proc_macro::Spacing::Alone, - ))]); - }; -} - -macro_rules! quote_inner { - // Base case - ($ts:ident) => {}; - - // Single or double symbols - ($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)*); }; - ($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)*); }; - ($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)*); }; - ($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)*); }; - ($ts:ident * $($tail:tt)*) => { sym!($ts '*'); quote_inner!($ts $($tail)*); }; - - // Identifier - ($ts:ident $i:ident $($tail:tt)*) => { - $ts.extend([::proc_macro::TokenTree::from(::proc_macro::Ident::new( - &stringify!($i), - ::proc_macro::Span::mixed_site(), - ))]); - quote_inner!($ts $($tail)*); - }; - - // Literal - ($ts:ident $l:literal $($tail:tt)*) => { - $ts.extend([::proc_macro::TokenTree::from(::proc_macro::Literal::string(&$l))]); - quote_inner!($ts $($tail)*); - }; - - // Lifetime - ($ts:ident $l:lifetime $($tail:tt)*) => { - $ts.extend([ - ::proc_macro::TokenTree::from( - ::proc_macro::Punct::new('\'', ::proc_macro::Spacing::Joint) - ), - ::proc_macro::TokenTree::from(::proc_macro::Ident::new( - stringify!($l).trim_start_matches(|c| c == '\''), - ::proc_macro::Span::mixed_site(), - )), - ]); - quote_inner!($ts $($tail)*); - }; - - // Groups - ($ts:ident ($($inner:tt)*) $($tail:tt)*) => { - $ts.extend([::proc_macro::TokenTree::Group(::proc_macro::Group::new( - ::proc_macro::Delimiter::Parenthesis, - quote!($($inner)*) - ))]); - quote_inner!($ts $($tail)*); - }; - ($ts:ident [$($inner:tt)*] $($tail:tt)*) => { - $ts.extend([::proc_macro::TokenTree::Group(::proc_macro::Group::new( - ::proc_macro::Delimiter::Bracket, - quote!($($inner)*) - ))]); - quote_inner!($ts $($tail)*); - }; - ($ts:ident {$($inner:tt)*} $($tail:tt)*) => { - $ts.extend([::proc_macro::TokenTree::Group(::proc_macro::Group::new( - ::proc_macro::Delimiter::Brace, - quote!($($inner)*) - ))]); - quote_inner!($ts $($tail)*); - }; - - // Interpolated values - // TokenTree by default - ($ts:ident #($e:expr) $($tail:tt)*) => { - $ts.extend([$crate::to_tokens::ToTokenTree::into_token_tree($e)]); - quote_inner!($ts $($tail)*); - }; - // Allow a TokenStream by request. It's more expensive, so avoid if possible. - ($ts:ident #S($e:expr) $($tail:tt)*) => { - $crate::to_tokens::ToTokenStream::append_to($e, $ts); - quote_inner!($ts $($tail)*); - }; -} |