chiark / gitweb /
config, wip macro
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 24 Jul 2021 11:15:38 +0000 (12:15 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 24 Jul 2021 11:15:38 +0000 (12:15 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
macros/macros.rs

index 13c727ce0fb12bd49c2adf52adc487ed3883dd8d..142a0f7c3d0ef85541756e4025760be53229d04b 100644 (file)
@@ -7,7 +7,7 @@
 #![allow(unused_mut)] // xxx
 
 use syn::{parse_macro_input, parse_quote, Data, DataStruct, DeriveInput, Meta, NestedMeta, Path};
-use quote::{quote, quote_spanned};
+use quote::{quote, quote_spanned, ToTokens};
 use proc_macro2::{Literal, TokenStream};
 
 use itertools::Itertools;
@@ -41,7 +41,7 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
     for attr in &field.attrs {
       if attr.tokens.is_empty() {
         let atspan = attr.path.segments.last().unwrap().ident.span();
-        method = quote!{ #attr.path };
+        method = attr.path.to_token_stream();
         if &attr.path == &parse_quote!{ limited } {
           skl = quote_spanned!{atspan=> SKL::Limited };
         }
@@ -53,7 +53,7 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
         let (tmethod, tskl) = meta.nested.iter().collect_tuple().unwrap();
         fn get_path(meta: &NestedMeta) -> TokenStream {
           match meta {
-            NestedMeta::Meta(Meta::Path(ref path)) => quote!{ #path },
+            NestedMeta::Meta(Meta::Path(ref path)) => path.to_token_stream(),
             _ => panic!(),
           }
         }