-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow macros to be used in literals and/or meta items #1516
Comments
Talking about this on IRC, an alternate way to accomplish this would be to have |
I'm in favor of having |
I would personally want to avoid literally using the In general this may just mean, however, that the compiler's story for supporting code generation isn't the best. I think that C/C++ take care of this by having header include paths so it may be the case that parser lookup paths are just the same? |
There may be motivation for the original idea beyond |
On Tue, Mar 01, 2016 at 08:10:52AM -0800, Alex Crichton wrote:
Yes, this is what I actually meant. Basically the ability to have more than one "root path" for finding modules. Many compilers offer a facility like this (e.g., javac has
Well the other big thing is of course #line-style directives... |
Similar to what @durka pointed out, I have a macro that generates a trait, and I want to document some of the trait items by doing: #[doc=concat!("The type of `Future` returned by ", stringify!($fn_name))]
type Fut: Future<Item=T, Error=E>; As a workaround, I use a plugin that replaces |
Inside macro bodies eager expansion should work? |
@Ericson2314 something like this doesn't work; is that what you meant? |
I think @Ericson2314 is referring to #1628, which creates new syntax for eager expansion within macro bodies. If that is accepted, then |
Update: You still cannot put a macro in fn foo() {
#[path=env!("xyz")] mod foo;
}
This has been reported at rust-lang/rust#48250. |
In this reddit comment Perceptes mentioned one idea to cut down down on some of the syntex boilerplate would be to use the
#[path = ...]
attribute to point to one of the generated files, as in this:Unfortunately this is currently illegal, because macros cannot be used in the position of a literal. It would be nice if we supported this functionality.
The text was updated successfully, but these errors were encountered: