about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorFelix Raimundo <felix.raimundo@telecom-paristech.fr>2014-10-04 02:16:38 +0200
committerFelix Raimundo <felix.raimundo@telecom-paristech.fr>2014-10-04 19:51:22 +0200
commite69f2ab8c071f53a09cca0cca335c7e38270f159 (patch)
tree4f4b82baa518fe49b67149dc2c8fd86d2afe8f49 /src/libsyntax
parentae81c89f34f1ac2cdb596cf216612e94822a8466 (diff)
downloadrust-e69f2ab8c071f53a09cca0cca335c7e38270f159.tar.gz
rust-e69f2ab8c071f53a09cca0cca335c7e38270f159.zip
Changed `extern crate foo as bar;` error message
Closes #17709
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/parser.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 4c877c0b101..f2236b6a463 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4981,18 +4981,27 @@ impl<'a> Parser<'a> {
                                 attrs: Vec<Attribute> )
                                 -> ItemOrViewItem {
 
+        let span = self.span;
         let (maybe_path, ident) = match self.token {
             token::IDENT(..) => {
                 let the_ident = self.parse_ident();
-                self.expect_one_of(&[], &[token::EQ, token::SEMI]);
-                let path = if self.token == token::EQ {
-                    self.bump();
+                let path = if self.eat(&token::EQ) {
                     let path = self.parse_str();
                     let span = self.span;
                     self.obsolete(span, ObsoleteExternCrateRenaming);
                     Some(path)
-                } else {None};
-
+                } else if self.eat_keyword(keywords::As) {
+                    // skip the ident if there is one
+                    if is_ident(&self.token) { self.bump(); }
+
+                    self.span_err(span,
+                                  format!("expected `;`, found `as`; perhaps you meant \
+                                          to enclose the crate name `{}` in a string?",
+                                          the_ident.as_str()).as_slice());
+                    None
+                } else {
+                    None
+                };
                 self.expect(&token::SEMI);
                 (path, the_ident)
             },