about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-08-12 19:25:05 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-08-14 13:24:50 -0700
commit1c16accfc204b447b128ed17545e88d947144682 (patch)
treec1dded87a5073e546f314996488e86f57cc8a924 /src/libsyntax/parse/parser.rs
parent404978ea722c0257cc763540c93243e8a21f82ed (diff)
downloadrust-1c16accfc204b447b128ed17545e88d947144682.tar.gz
rust-1c16accfc204b447b128ed17545e88d947144682.zip
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.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs8
1 files changed, 6 insertions, 2 deletions
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