Skip to content
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

1.38 regression ? proc-macro derive panicked if there is r# in front of the attribute name #64924

Open
fdubois1 opened this issue Sep 30, 2019 · 7 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fdubois1
Copy link

fdubois1 commented Sep 30, 2019

I have a macro and it defines an attribute called "async". When I use it, I add r# in front of it. I have this :

#[cowrpc(r#async)]
struct Handshake {
...
}

Since 1.38.0, it fails with

error: proc-macro derive panicked
 --> src/cow/den_server_iface.rs:3:10
  |
3 | #[derive(CowRpcIface)]
  |          ^^^^^^^^^^^
  |
  = help: message: "r#async" is not a valid ident

error: proc-macro derive panicked

It was building without any error before. What is different with 1.38?

@fdubois1 fdubois1 changed the title proc-macro derive panicked 1.38 regression ? proc-macro derive panicked if there is r# in front of the attribute name Sep 30, 2019
@jonas-schievink jonas-schievink added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Sep 30, 2019
@petrochenkov
Copy link
Contributor

Looks very similar to #63894 (pretty-printing change making raw identifiers to be printed precisely).

@petrochenkov
Copy link
Contributor

I suspect the attribute or derive expects identifier async in its input, but doesn't expect r#async.

(It would be nice if someone could check how the expanded code looks like and whether my guess is correct.)

@fdubois1
Copy link
Author

@petrochenkov How can I see what the expanded code looks like ?

Thanks

@petrochenkov
Copy link
Contributor

cargo expand is able to show expanded code for whole crates with dependencies.

@fdubois1
Copy link
Author

FYI, here is the macro: https://github.com/Devolutions/cowrpc-rs/tree/master/cowrpc_derive/src

I looked the code generated in my case. I'm not sure to understand your point when you say that it expects identifier async in its input. I looked the macro code (https://github.com/Devolutions/cowrpc-rs/tree/master/cowrpc_derive/src), it is true that it compare the ident name with "async" (https://github.com/Devolutions/cowrpc-rs/blob/master/cowrpc_derive/src/iface/attr.rs#L30), but it would raise an error if you provide something that macro doesn't support, for example #[cowrpc(foostring)] would raise an error "There is no word attribute you can use on data types with cowrpc".

I can see that we use syn: 0.13 and proc-macro2: 0.3. I guess the error message is comming at the beginning when we do syn::parse(input)... but if we didn't change the dependencies, should not be a problem...

FYI, I updated the code to edition 2018 where async is now a reserved word. It changed code to add lot of r# in front of async, but should not be a problem.

Thanks for your help

@o0Ignition0o
Copy link
Contributor

@rustbot modify labels to +I-prioritize

@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 27, 2020
@spastorino spastorino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 28, 2020
@LeSeulArtichaut LeSeulArtichaut added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jun 3, 2020
@LeSeulArtichaut
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants