dtolnay / quote

Rust quasi-quoting
Apache License 2.0
1.32k stars 90 forks source link

When create struct with keyword field get nothing? #278

Closed beanbean97 closed 2 months ago

beanbean97 commented 2 months ago
let type_ident = syn::Ident::new("type", proc_macro2::Span::call_site());
quote! {
  struct Demo {
    #type_ident:u8,
  }
  let a = Demo {#type_ident : 0u8};
}

expand=>

struct Demo {
}
let a = Demo {r#type: 0u8};

Is a bug or something?

dtolnay commented 2 months ago

This is working correctly as far as I can tell. Probably there was an error elsewhere in your code.