dtolnay / quote

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

the trait quote::Tokens is not implemented for syn::Ident #212

Closed giluis closed 2 years ago

giluis commented 2 years ago

Hello, Going through the proc-macro-workshop, Builder project.

While trying to pass the second test case, I got this error: image

The related code is this:

use proc_macro::TokenStream;
use syn::*;
use quote::*;

#[proc_macro_derive(Builder)]
pub fn derive(input: TokenStream) -> TokenStream {
    let ast = parse_macro_input!(input as DeriveInput);
    let name = ast.ident;
    let expanded = quote!{ #name };
    TokenStream::from(expanded)
}

I don't understand what is going on. I have done this in the past with syn and Ident usually implemented ToTokens IIRC

What am I missing?

giluis commented 2 years ago

Figured out the problem! Was using version 1.0. When I changed to version 1.0.82 it started working. Perhaps it would be better to change the cargo.toml section example that is present in the README, which states:

[dependencies]
quote = "1.0"
lroux-at-jellysmack commented 2 years ago

Hello @giluis, a cargo update would have fixed it while keeping quote = "1.0" :)

PS: No a contributor of quote