From 1c16accfc204b447b128ed17545e88d947144682 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 12 Aug 2014 19:25:05 -0700 Subject: 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. --- src/libsyntax/parse/parser.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f6db577a004..50db5029904 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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 -- cgit 1.4.1-3-g733a5