-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Extended key value attributes are parsed too eagerly #85882
Comments
Any parsing is performed before handling This issue is a duplicate of #82768, which suggests a workaround (for older versions of rustc, since arbitrary expressions in key-value attributes are now stable). |
Sure, my point was more that it mismatches with my expectation that the item after the |
That's true for fn-like macro inputs, but attribute macros always receive valid Rust syntax as input. |
Thanks for the link, and the explanation, I think we can close this one anyway as it seems to be known, and the impact isn't as bad as initially thought. |
Consider the following rust code, I would have expected the below to compile on stable today when compiled with
rustc src/lib.rs
, but in fact it fails to compile citing that arbitrary key values are unstable. Which implies that theinclude_str!
parsing is being handled ahead of handling thecfg
predicate. While this specific example won't be an issue when this becomes stable in 1.54.0, but it does point to this feature having some surprising behaviour at the moment, I would have expected thecfg
predicate on the module to have been evaluated to false and the whole module would be skipped, regardless of what I used on the right hand side ofdoc
.There's a workaround if you're okay with double wrapping the modules, as if you embed it in a declarative macro, it will behave how you expect.
The text was updated successfully, but these errors were encountered: