-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Reevaluate extern mod
as syntax for importing crates.
#9880
Comments
Nominating. |
+1. I always feel embarrassed when I have to explain this to someone. |
The For example, this creates two interchangeable paths to the same module tree:
While this creates two distinct modules:
|
1.0, backcompat |
"crate" seems to be the consensus. |
@huonw can mentor |
If someone does want some mentorship, feel free to contact me by commenting here, on IRC (nick: dbaupp) or via email (in my profile). |
I'll work on this one |
I like |
Do we really want to add another keyword with just one use case? // A procedural macro can expand to an ExternCrate AST node.
extern_crate! extra;
// Similar here, though attributes may not map as well to the AST.
#[extern_crate(extra)];
// These should still work (do we allow visibility on extern mod?):
#[cfg(foo="bar")]
pub extern_crate! foobar; |
Would |
@sfackler not 100% but I think that in the case of |
For the record,
Example: extern mod extra;
mod foo {
extern mod extra;
pub fn bar() {
let x: ::extra::arc::Arc<uint> = ::foo::extra::arc::Arc::new(5u);
println!("{:?}", x);
}
}
fn main() {
foo::bar();
} |
@sfackler I would like to see context-sensitive keywords as you suggest, but I don't believe Rust currently has any. If we were to start using context-sensitive keywords, I'd also like to see |
@brson What is the final decision here? |
@Kimundi what about changing (But they also maybe may be, if you're using package IDs or attributes or whatever to bring in e.g. different versions of the same library. Of course you could check "are these extern mods actually referring to the same thing" (and perhaps we already do?), but if they're always distinct then you don't have to care.) |
@flaper87 let's make crate a full keyword. It can be contextualized later if we agree on it. |
@brson roger that! |
I still don't think adding a It would be simple enough to change the |
+1 for
|
This patch adds a new keyword `crate` which is intended to replace mod in the context of `extern mod` as part of the issue rust-lang#9880. The patch doesn't replace all `extern mod` cases since it is necessary to first push a new snapshot 0. The implementation could've been less invasive than this. However I preferred to take this chance to split the `parse_item_foreign_mod` method and pull the `extern crate` part out of there, hence the new method `parse_item_foreign_crate`.
The first setp for #9880 is to add a new `crate` keyword. This PR does exactly that. I took a chance to refactor `parse_item_foreign_mod` and I broke it down into 2 separate methods to isolate each feature. The next step will be to push a new stage0 snapshot and then get rid of all `extern mod` around the code.
The patch that introduced the |
It's not that well loved. It doesn't have anything to do with other uses of
extern
, and lexically it must be written in a different position than otherextern
things.The text was updated successfully, but these errors were encountered: