File tree Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Expand file tree Collapse file tree 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> {
49804980 attrs : Vec < Attribute > )
49814981 -> ItemOrViewItem {
49824982
4983+ let span = self . span ;
49834984 let ( maybe_path, ident) = match self . token {
49844985 token:: IDENT ( ..) => {
49854986 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 ) {
49894988 let path = self . parse_str ( ) ;
49904989 let span = self . span ;
49914990 self . obsolete ( span, ObsoleteExternCrateRenaming ) ;
49924991 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+ } ;
49955004 self . expect ( & token:: SEMI ) ;
49965005 ( path, the_ident)
49975006 } ,
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 1111// Verifies that the expected token errors for `extern crate` are
1212// raised
1313
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