Open
Description
Hi.
It looks like when you generate non-items in a custom derive, they are silently dropped.
For instance, with the following custom derive:
#[proc_macro_derive(HelloWorld)]
pub fn hello_world(input: TokenStream) -> TokenStream {
let ast = syn::parse(input).unwrap();
let gen = impl_hello_world(&ast);
gen.into()
}
fn impl_hello_world(ast: &syn::DeriveInput) -> quote::Tokens {
let name = &ast.ident;
quote! {{
fn hello_world() {
println!("Hello, World! My name is {}", stringify!(#name));
}
hello_world();
}}
}
and the following code:
fn main() {
#[derive(HelloWorld)]
struct _Toto {
}
}
nothing is printed on the screen.
So, is it normal that non-items are dropped?
Could they be generated as well if it makes sense (like in a struct that is defined within a function)?
If not, if would be nice to have a least a warning when this happen.
Thanks.