libsyntax: Accept use foo as bar; in lieu of use bar as foo;

The old syntax will be removed after a snapshot.

RFC #47.

Issue #16461.
This commit is contained in:
Patrick Walton 2014-08-12 19:25:05 -07:00
parent 404978ea72
commit 1c16accfc2
29 changed files with 51 additions and 43 deletions

View file

@ -5309,6 +5309,7 @@ impl<'a> Parser<'a> {
match self.token {
token::EQ => {
// x = foo::bar
// NOTE(stage0, #16461, pcwalton): Deprecate after snapshot.
self.bump();
let path_lo = self.span.lo;
path = vec!(self.parse_ident());
@ -5391,7 +5392,7 @@ impl<'a> Parser<'a> {
}
_ => ()
}
let last = *path.get(path.len() - 1u);
let mut rename_to = *path.get(path.len() - 1u);
let path = ast::Path {
span: mk_sp(lo, self.span.hi),
global: false,
@ -5403,9 +5404,12 @@ impl<'a> Parser<'a> {
}
}).collect()
};
if self.eat_keyword(keywords::As) {
rename_to = self.parse_ident()
}
return box(GC) spanned(lo,
self.last_span.hi,
ViewPathSimple(last, path, ast::DUMMY_NODE_ID));
ViewPathSimple(rename_to, path, ast::DUMMY_NODE_ID));
}
/// Parses a sequence of items. Stops when it finds program