diff options
| author | bors <bors@rust-lang.org> | 2014-08-14 21:01:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-08-14 21:01:19 +0000 |
| commit | f8e0ede92157995665c7caf4ae115354139be46d (patch) | |
| tree | e32787163f380bfa88b723f29541eed9c83728cf /src/libsyntax/parse | |
| parent | a8c8e3f80fd0355b2bb91337c6ad0bb0a38d5485 (diff) | |
| parent | 1c16accfc204b447b128ed17545e88d947144682 (diff) | |
| download | rust-f8e0ede92157995665c7caf4ae115354139be46d.tar.gz rust-f8e0ede92157995665c7caf4ae115354139be46d.zip | |
auto merge of #16468 : pcwalton/rust/as-renaming-import, r=alexcrichton
The old syntax will be removed after a snapshot. RFC #47. Issue #16461. r? @brson
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f272f7e1887..8c448b5a0b0 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5317,6 +5317,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()); @@ -5399,7 +5400,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, @@ -5411,9 +5412,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 |
