std/rustc/rustpkg/syntax: Support the extern mod = ...
form
This commit allows you to write: extern mod x = "a/b/c"; which means rustc will search in the RUST_PATH for a package with ID a/b/c, and bind it to the name `x` if it's found. Incidentally, move get_relative_to from back::rpath into std::path
This commit is contained in:
parent
e751c90513
commit
96fd606ddd
29 changed files with 819 additions and 602 deletions
|
@ -4169,8 +4169,16 @@ impl Parser {
|
|||
self.this_token_to_str()));
|
||||
}
|
||||
|
||||
let (sort, ident) = match *self.token {
|
||||
token::IDENT(*) => (ast::named, self.parse_ident()),
|
||||
let (sort, maybe_path, ident) = match *self.token {
|
||||
token::IDENT(*) => {
|
||||
let the_ident = self.parse_ident();
|
||||
let path = if *self.token == token::EQ {
|
||||
self.bump();
|
||||
Some(self.parse_str())
|
||||
}
|
||||
else { None };
|
||||
(ast::named, path, the_ident)
|
||||
}
|
||||
_ => {
|
||||
if must_be_named_mod {
|
||||
self.span_fatal(*self.span,
|
||||
|
@ -4179,7 +4187,7 @@ impl Parser {
|
|||
self.this_token_to_str()));
|
||||
}
|
||||
|
||||
(ast::anonymous,
|
||||
(ast::anonymous, None,
|
||||
special_idents::clownshoes_foreign_mod)
|
||||
}
|
||||
};
|
||||
|
@ -4218,7 +4226,7 @@ impl Parser {
|
|||
let metadata = self.parse_optional_meta();
|
||||
self.expect(&token::SEMI);
|
||||
iovi_view_item(ast::view_item {
|
||||
node: view_item_extern_mod(ident, metadata, self.get_id()),
|
||||
node: view_item_extern_mod(ident, maybe_path, metadata, self.get_id()),
|
||||
attrs: attrs,
|
||||
vis: visibility,
|
||||
span: mk_sp(lo, self.last_span.hi)
|
||||
|
@ -4800,8 +4808,13 @@ impl Parser {
|
|||
} else if self.eat_keyword(keywords::Extern) {
|
||||
self.expect_keyword(keywords::Mod);
|
||||
let ident = self.parse_ident();
|
||||
let path = if *self.token == token::EQ {
|
||||
self.bump();
|
||||
Some(self.parse_str())
|
||||
}
|
||||
else { None };
|
||||
let metadata = self.parse_optional_meta();
|
||||
view_item_extern_mod(ident, metadata, self.get_id())
|
||||
view_item_extern_mod(ident, path, metadata, self.get_id())
|
||||
} else {
|
||||
self.bug("expected view item");
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue