New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async
parses as a syn::Ident
#1313
Comments
Whether In general if you are writing a Parse impl that involves some "keyword" i.e. you want to parse |
I see. I'm using |
Yeah that's gonna depend on what edition the user is compiling their crate with. Usually a macro can just dump an Ident into the output code without a check. For example something like If the reason you are checking is to legalize the ident in some way like turning |
Using |
Hi @dtolnay, I am making an attribute proc macro, and one of the argument is a list of identifiers, but cannot be keywords, and I cannot prefix them with when I tried: #[my_macro(outputs=[out1, async])
fn foo(in1: u8) -> (bool, String) {
todo!();
} I was surprised the I found in your repo where I think you are checking if the ident is a keyword. Now following the Rust Reference about the keywords I would like to have my attribute to refuse those idents as valid variable names only if the user's crate is using edition 2018 and + but to allow them if it's edition 2015. I then researched how can I know what are the keywords according to the edition, I imagine that maybe the compilier expose something like that. I found this "Rust Compiler Development Guide": Lexing and Parsing I understand the rust compiler's lexer and parser are going to be extracted into libraries... Anyway, this whole thing is pretty complex and I am not knowledgeable enough to know what is relevant.... My questions to you @dtolnay:1.) Is it possible for a proc macro to detect the edition of the user's crate ? (If possible, how please ?)
(Thank you for all your wonderful libraries, I lost count on how many I daily use, and I learn so much from studying them). |
|
That's surprising because
syn::Ident
says this in its docs:I'm pretty confused as to how this is happening given:
https://github.com/dtolnay/syn/blob/master/src/ident.rs#L20-L35
My apologies if this is working as intended.
The text was updated successfully, but these errors were encountered: