2 () => (::proc_macro
::TokenStream
::new());
4 let mut ts
= ::proc_macro
::TokenStream
::new();
6 quote_inner
!(ts_mut $
($x
)*);
11 #[cfg(any(feature = "formatting", feature = "parsing"))]
12 macro_rules
! quote_append
{
13 ($ts
:ident $
($x
:tt
)*) => {{
14 quote_inner
!($ts $
($x
)*);
18 macro_rules
! quote_group
{
20 ::proc_macro
::TokenTree
::Group(::proc_macro
::Group
::new(
21 ::proc_macro
::Delimiter
::Brace
,
28 ($ts
:ident $x
:tt $y
:tt
) => {
30 ::proc_macro
::TokenTree
::from(::proc_macro
::Punct
::new(
32 ::proc_macro
::Spacing
::Joint
,
34 ::proc_macro
::TokenTree
::from(::proc_macro
::Punct
::new(
36 ::proc_macro
::Spacing
::Alone
,
40 ($ts
:ident $x
:tt
) => {
41 $ts
.extend([::proc_macro
::TokenTree
::from(::proc_macro
::Punct
::new(
43 ::proc_macro
::Spacing
::Alone
,
48 macro_rules
! quote_inner
{
52 // Single or double symbols
53 ($ts
:ident
:: $
($tail
:tt
)*) => { sym!($ts ':' ':'); quote_inner!($ts $($tail)*); }
;
54 ($ts
:ident
.. $
($tail
:tt
)*) => { sym!($ts '.' '.'); quote_inner!($ts $($tail)*); }
;
55 ($ts
:ident
: $
($tail
:tt
)*) => { sym!($ts ':'); quote_inner!($ts $($tail)*); }
;
56 ($ts
:ident
= $
($tail
:tt
)*) => { sym!($ts '='); quote_inner!($ts $($tail)*); }
;
57 ($ts
:ident
; $
($tail
:tt
)*) => { sym!($ts ';'); quote_inner!($ts $($tail)*); }
;
58 ($ts
:ident
, $
($tail
:tt
)*) => { sym!($ts ','); quote_inner!($ts $($tail)*); }
;
59 ($ts
:ident
. $
($tail
:tt
)*) => { sym!($ts '.'); quote_inner!($ts $($tail)*); }
;
60 ($ts
:ident
& $
($tail
:tt
)*) => { sym!($ts '&'); quote_inner!($ts $($tail)*); }
;
61 ($ts
:ident
<< $
($tail
:tt
)*) => { sym!($ts '<' '<'); quote_inner!($ts $($tail)*); }
;
62 ($ts
:ident
< $
($tail
:tt
)*) => { sym!($ts '<'); quote_inner!($ts $($tail)*); }
;
63 ($ts
:ident
>> $
($tail
:tt
)*) => { sym!($ts '>' '>'); quote_inner!($ts $($tail)*); }
;
64 ($ts
:ident
> $
($tail
:tt
)*) => { sym!($ts '>'); quote_inner!($ts $($tail)*); }
;
65 ($ts
:ident
-> $
($tail
:tt
)*) => { sym!($ts '-' '>'); quote_inner!($ts $($tail)*); }
;
66 ($ts
:ident ? $
($tail
:tt
)*) => { sym!($ts '?'); quote_inner!($ts $($tail)*); }
;
67 ($ts
:ident
! $
($tail
:tt
)*) => { sym!($ts '!'); quote_inner!($ts $($tail)*); }
;
68 ($ts
:ident
| $
($tail
:tt
)*) => { sym!($ts '|'); quote_inner!($ts $($tail)*); }
;
69 ($ts
:ident
* $
($tail
:tt
)*) => { sym!($ts '*'); quote_inner!($ts $($tail)*); }
;
72 ($ts
:ident $i
:ident $
($tail
:tt
)*) => {
73 $ts
.extend([::proc_macro
::TokenTree
::from(::proc_macro
::Ident
::new(
75 ::proc_macro
::Span
::mixed_site(),
77 quote_inner
!($ts $
($tail
)*);
81 ($ts
:ident $l
:literal $
($tail
:tt
)*) => {
82 $ts
.extend([::proc_macro
::TokenTree
::from(::proc_macro
::Literal
::string(&$l
))]);
83 quote_inner
!($ts $
($tail
)*);
87 ($ts
:ident $l
:lifetime $
($tail
:tt
)*) => {
89 ::proc_macro
::TokenTree
::from(
90 ::proc_macro
::Punct
::new('
\''
, ::proc_macro
::Spacing
::Joint
)
92 ::proc_macro
::TokenTree
::from(::proc_macro
::Ident
::new(
93 stringify
!($l
).trim_start_matches(|c
| c
== '
\''
),
94 ::proc_macro
::Span
::mixed_site(),
97 quote_inner
!($ts $
($tail
)*);
101 ($ts
:ident ($
($inner
:tt
)*) $
($tail
:tt
)*) => {
102 $ts
.extend([::proc_macro
::TokenTree
::Group(::proc_macro
::Group
::new(
103 ::proc_macro
::Delimiter
::Parenthesis
,
106 quote_inner
!($ts $
($tail
)*);
108 ($ts
:ident
[$
($inner
:tt
)*] $
($tail
:tt
)*) => {
109 $ts
.extend([::proc_macro
::TokenTree
::Group(::proc_macro
::Group
::new(
110 ::proc_macro
::Delimiter
::Bracket
,
113 quote_inner
!($ts $
($tail
)*);
115 ($ts
:ident {$($inner:tt)*} $
($tail
:tt
)*) => {
116 $ts
.extend([::proc_macro
::TokenTree
::Group(::proc_macro
::Group
::new(
117 ::proc_macro
::Delimiter
::Brace
,
120 quote_inner
!($ts $
($tail
)*);
123 // Interpolated values
124 // TokenTree by default
125 ($ts
:ident
#($e:expr) $($tail:tt)*) => {
126 $ts
.extend([$
crate::to_tokens
::ToTokenTree
::into_token_tree($e
)]);
127 quote_inner
!($ts $
($tail
)*);
129 // Allow a TokenStream by request. It's more expensive, so avoid if possible.
130 ($ts
:ident
#S($e:expr) $($tail:tt)*) => {
131 $
crate::to_tokens
::ToTokenStream
::append_to($e
, $ts
);
132 quote_inner
!($ts $
($tail
)*);