Skip to content

Commit 8fdb3a4

Browse files
committed
Auto merge of #25487 - P1start:extern-crate-unexpected-error, r=huonw
Closes #25468.
2 parents 0becf6a + dadac15 commit 8fdb3a4

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5267,11 +5267,7 @@ impl<'a> Parser<'a> {
52675267
return Ok(Some(try!(self.parse_item_foreign_mod(lo, opt_abi, visibility, attrs))));
52685268
}
52695269

5270-
let span = self.span;
5271-
let token_str = self.this_token_to_string();
5272-
return Err(self.span_fatal(span,
5273-
&format!("expected `{}` or `fn`, found `{}`", "{",
5274-
token_str)))
5270+
try!(self.expect_one_of(&[], &[]));
52755271
}
52765272

52775273
if try!(self.eat_keyword_noexpect(keywords::Virtual) ){
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2015 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+
extern crte foo; //~ ERROR expected one of `crate`, `fn`, or `{`, found `crte`

src/test/parse-fail/extern-expected-fn-or-brace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
// Verifies that the expected token errors for `extern crate` are
1414
// raised
1515

16-
extern "C" mod foo; //~ERROR expected `{` or `fn`, found `mod`
16+
extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found `mod`

0 commit comments

Comments
 (0)