Closed
Description
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
Activity
abonander commentedon Mar 8, 2018
I believe that this should be resolved by #48465.
eddyb commentedon Mar 26, 2018
This showcases that we actually expand macro invocations within a
NtExpr
which was probably never intended. Are attributes the only place where we embed aTokenStream
like that?Should we just support macro invocations in attributes at the top-level and expanding them?
There's probably a good reason to avoid expanding macros nested arbitrarily just because it went through
$x:expr
in amacro_rules
, but it needs some discussion.cc @rust-lang/compiler @jseyfried @petrochenkov
durka commentedon Mar 26, 2018
Look at that, eager expansion!
Yes please!
eddyb commentedon Mar 27, 2018
@durka It's not eager! The invocation stays in there until macro expansion reaches it accidentally-ish.
7 remaining items