-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Rust passes invalid syntax to procedural macros when expanding other macros #47358
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I believe that this should be resolved by #48465. |
macro_rules! foo {
($x:expr) => {
#[export_name = $x] pub fn foo() {}
}
}
foo!(concat!("ma", "in"));
// Errors about `concat!` not being parseable.
// #[export_name = concat!("ma", "in")] pub fn foo() {}
fn main() {} This showcases that we actually expand macro invocations within a Should we just support macro invocations in attributes at the top-level and expanding them? cc @rust-lang/compiler @jseyfried @petrochenkov |
Look at that, eager expansion!
Yes please! |
@durka It's not eager! The invocation stays in there until macro expansion reaches it accidentally-ish. |
I'm going to remove the I-nominated tag. We're not prioritzing this, but I agree with @alexcrichton that this is something we ought to "figure out' as part of macros 1.2 etc. |
Maybe change the title to "Rethink proc macro expansion order" or something? |
I'll close this in favor of #55414 where the discussion regarding cases like this case is happening. |
Here's an example of the issue: https://play.rust-lang.org/?gist=1fcdc0a76f5c4dd0f2da855e497ea298&version=stable
In that code I use
#[doc=$doc]
, which is expanded to invalid syntax#[doc=concat!("Hello", "world", "!")]
before being passed to the serde Deserialize procedural macro.This uses the same expansion as #42164
The text was updated successfully, but these errors were encountered: