-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
unnecessary parentheses around type
in attribute macro
#106939
Comments
The problem is that the tokens include the parentheses. You can use parse_args to parse the argument as a |
Hi, thank you very much this indeed solved the problem. I did not even realize the warning came from the parentheses actually being unused, I thought that warning was emitted even before my macro was expanded. I'm wondering if there would be any way to improve the diagnostic here? |
rust-lang/rust#106939 thanks clubby789!
rust-lang/rust#106939 thanks clubby789!
Sadly we somewhat rely on proc macros being well-formed, but we should make more of an effort helping proc-macro authors debug their own code. |
I've encountered similar when writing my (perhaps overly complex and overly ambition) proc macro - at a certain level of complexity, a lot of these errors for me originate either from: By (b), I mean that there are certain things, like applying a 'template' of expanded code to the user-provided syntax, that are likely to violate a number of lints (e.g. like in this issue, or more commonly things like unnecessary borrows which are sometimes necessary, depending on the types used in the syntax by the user), where you want to allow those lints on that expanded code, but then within those there might be syntax which you do want to be linted, because it was defined by the user (or mostly defined). I realize this is not the place to discuss these errors, it's just what immediately came to mind when seeing the issue. I'm not sure where the correct place to discuss them would be if I were to do that. |
https://internals.rust-lang.org/ and https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics |
Code
Since this is related to proc_macro reproducing is slightly troublesome. The original problem originated here: https://github.com/lesurp/OptionalStruct/blob/master/tests/nested.rs
Simplified call site:
Note that the macro is not a
derive
macro (and the attributeoptional_rename
not a derive macro helper attributes).Current output
Desired output
Rationale and extra context
The parentheses are read as part of the type, but they are part of the attribute definition.
Other cases
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: