-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Support macro re-export #17103
Comments
Hm, we know the crate from which a macro was imported at expansion time. We could introduce a special metavar We could also arrange that |
I have this working on a branch. As short-term kludges go, this one has a lot to recommend it:
This doesn't affect procedural macros at all. I'll update #17100 once this lands. |
I haven't looked that deeply at the branch, but how does this interact if the crate is imported outside of the crate root or with a nonstandard name? |
It does handle renaming. I hadn't thought about |
I've only seen it used in test modules, but it's definitely something you can do. Supporting non-root crate names will be a bit awkward since you need relative paths in some context and absolute paths in others. Maybe insert a gensymed import of the crate at the crate root? |
Non-crate root macros are currently broken anyway. |
What do you mean? |
We could always have |
#![feature(phase)]
mod foo {
#[phase(plugin, link)] extern crate log;
fn bar() {
debug!("hi")
}
}
fn main() {}
|
Right now, |
That will break if you try to do something like |
Is there any reason |
Dunno, but it's currently a parser error. |
It seems harmless, the path will just be absolute either way. That can be a followup PR, since the std lib macros don't need |
Wouldn't |
|
Oh, right.
|
@kmcallister there were some extensive discussion about the macro system at the last work week, but it appears that we didn't take very good notes during that sadly. You may want to sync up with @pcwalton or @nikomatsakis before going too far down this road as I remember we came up with fairly concrete plans, but they involved possibly significant changes to resolve. |
Based on the discussion at the work week, I've been working on expanding my name resolution prototype to include macro import/export and expansion. So far I've not quite gotten there -- most of the work has been on expanding it to support lazy glob resolution and two namespaces. |
@nikomatsakis, @alexcrichton: Do you think I should revive this PR as a near-term fix (along with a re-tooled #17100) or is the new name resolution work close to ready? |
We've been hesitant in the past to make any major adjustments to the macro system (which I think this falls into the category of). We still feel that macros are not quite where they need to be, and I'm not sure what something like I would prefer to discuss this a bit more before moving forward. I know this is a huge pain point with macros! Such a feature would likely require an RFC to move forward (this is a large modification to macros, a language feature). We can discuss in the upcoming weekly meeting however to test the waters of whether we'd like to move forward with this now. |
Okay. I'll prepare an RFC ahead of the meeting tomorrow. |
…rsion-of-node-in-metrics-yml, r=lnicola fix: usage of `deprecated` version of `Node.js` fixes rust-lang#17103.
…rsion-of-node-in-metrics-yml, r=lnicola fix: usage of `deprecated` version of `Node.js` fixes rust-lang#17103.
The mechanics should be easy because exported macros are just stored as strings in crate metadata. But it won't be very useful unless names mentioned by macros can change to follow the re-export. If we can find a pleasing solution to this problem, we can eliminate a lot of duplicated code e.g. between
libcore/macros.rs
andlibstd/macros.rs
.The text was updated successfully, but these errors were encountered: