File tree 3 files changed +29
-6
lines changed
3 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -4980,18 +4980,27 @@ impl<'a> Parser<'a> {
4980
4980
attrs : Vec < Attribute > )
4981
4981
-> ItemOrViewItem {
4982
4982
4983
+ let span = self . span ;
4983
4984
let ( maybe_path, ident) = match self . token {
4984
4985
token:: IDENT ( ..) => {
4985
4986
let the_ident = self . parse_ident ( ) ;
4986
- self . expect_one_of ( & [ ] , & [ token:: EQ , token:: SEMI ] ) ;
4987
- let path = if self . token == token:: EQ {
4988
- self . bump ( ) ;
4987
+ let path = if self . eat ( & token:: EQ ) {
4989
4988
let path = self . parse_str ( ) ;
4990
4989
let span = self . span ;
4991
4990
self . obsolete ( span, ObsoleteExternCrateRenaming ) ;
4992
4991
Some ( path)
4993
- } else { None } ;
4994
-
4992
+ } else if self . eat_keyword ( keywords:: As ) {
4993
+ // skip the ident if there is one
4994
+ if is_ident ( & self . token ) { self . bump ( ) ; }
4995
+
4996
+ self . span_err ( span,
4997
+ format ! ( "expected `;`, found `as`; perhaps you meant \
4998
+ to enclose the crate name `{}` in a string?",
4999
+ the_ident. as_str( ) ) . as_slice ( ) ) ;
5000
+ None
5001
+ } else {
5002
+ None
5003
+ } ;
4995
5004
self . expect ( & token:: SEMI ) ;
4996
5005
( path, the_ident)
4997
5006
} ,
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // Tests that the proper help is displayed in the error message
12
+
13
+ extern crate foo as bar;
14
+ //~^ ERROR expected `;`, found `as`; perhaps you meant to enclose the crate name `foo` in a string?
Original file line number Diff line number Diff line change 11
11
// Verifies that the expected token errors for `extern crate` are
12
12
// raised
13
13
14
- extern crate foo { } //~ERROR expected one of `=`, `;`, found `{`
14
+ extern crate foo { } //~ERROR expected `;`, found `{`
You can’t perform that action at this time.
0 commit comments