quote.rs (2612e3bbc0386368a850140a6c9b990cd496a5ec) | quote.rs (071cedc84e907f6984b3de3285ec2b077d3c3cdb) |
---|---|
1// SPDX-License-Identifier: Apache-2.0 OR MIT 2 3use proc_macro::{TokenStream, TokenTree}; 4 5pub(crate) trait ToTokens { 6 fn to_tokens(&self, tokens: &mut TokenStream); 7} 8 --- 110 unchanged lines hidden (view full) --- 119 quote_spanned!(@proc $v $span $($tt)*); 120 }; 121 (@proc $v:ident $span:ident ! $($tt:tt)*) => { 122 $v.push(::proc_macro::TokenTree::Punct( 123 ::proc_macro::Punct::new('!', ::proc_macro::Spacing::Alone) 124 )); 125 quote_spanned!(@proc $v $span $($tt)*); 126 }; | 1// SPDX-License-Identifier: Apache-2.0 OR MIT 2 3use proc_macro::{TokenStream, TokenTree}; 4 5pub(crate) trait ToTokens { 6 fn to_tokens(&self, tokens: &mut TokenStream); 7} 8 --- 110 unchanged lines hidden (view full) --- 119 quote_spanned!(@proc $v $span $($tt)*); 120 }; 121 (@proc $v:ident $span:ident ! $($tt:tt)*) => { 122 $v.push(::proc_macro::TokenTree::Punct( 123 ::proc_macro::Punct::new('!', ::proc_macro::Spacing::Alone) 124 )); 125 quote_spanned!(@proc $v $span $($tt)*); 126 }; |
127 (@proc $v:ident $span:ident ; $($tt:tt)*) => { 128 $v.push(::proc_macro::TokenTree::Punct( 129 ::proc_macro::Punct::new(';', ::proc_macro::Spacing::Alone) 130 )); 131 quote_spanned!(@proc $v $span $($tt)*); 132 }; 133 (@proc $v:ident $span:ident + $($tt:tt)*) => { 134 $v.push(::proc_macro::TokenTree::Punct( 135 ::proc_macro::Punct::new('+', ::proc_macro::Spacing::Alone) 136 )); 137 quote_spanned!(@proc $v $span $($tt)*); 138 }; |
|
127 (@proc $v:ident $span:ident $id:ident $($tt:tt)*) => { 128 $v.push(::proc_macro::TokenTree::Ident(::proc_macro::Ident::new(stringify!($id), $span))); 129 quote_spanned!(@proc $v $span $($tt)*); 130 }; 131} 132 133/// Converts tokens into [`proc_macro::TokenStream`] and performs variable interpolations with 134/// mixed site span ([`Span::mixed_site()`]). 135/// 136/// This is a similar to the [`quote!`](https://docs.rs/quote/latest/quote/macro.quote.html) macro 137/// from the `quote` crate but provides only just enough functionality needed by the current 138/// `macros` crate. 139/// 140/// [`Span::mixed_site()`]: https://doc.rust-lang.org/proc_macro/struct.Span.html#method.mixed_site 141macro_rules! quote { 142 ($($tt:tt)*) => { 143 quote_spanned!(::proc_macro::Span::mixed_site() => $($tt)*) 144 } 145} | 139 (@proc $v:ident $span:ident $id:ident $($tt:tt)*) => { 140 $v.push(::proc_macro::TokenTree::Ident(::proc_macro::Ident::new(stringify!($id), $span))); 141 quote_spanned!(@proc $v $span $($tt)*); 142 }; 143} 144 145/// Converts tokens into [`proc_macro::TokenStream`] and performs variable interpolations with 146/// mixed site span ([`Span::mixed_site()`]). 147/// 148/// This is a similar to the [`quote!`](https://docs.rs/quote/latest/quote/macro.quote.html) macro 149/// from the `quote` crate but provides only just enough functionality needed by the current 150/// `macros` crate. 151/// 152/// [`Span::mixed_site()`]: https://doc.rust-lang.org/proc_macro/struct.Span.html#method.mixed_site 153macro_rules! quote { 154 ($($tt:tt)*) => { 155 quote_spanned!(::proc_macro::Span::mixed_site() => $($tt)*) 156 } 157} |