Skip to content

Commit 22c4ee3

Browse files
committed
Improve error message for const extern fn
1 parent f89d8d1 commit 22c4ee3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/libsyntax/parse/parser.rs

+4
Original file line numberDiff line numberDiff line change
@@ -5981,6 +5981,10 @@ impl<'a> Parser<'a> {
59815981
return Ok(Some(self.parse_item_foreign_fn(visibility, lo, attrs)?));
59825982
}
59835983

5984+
if self.check_keyword(keywords::Const) {
5985+
return Err(self.span_fatal(self.span, "extern items cannot be `const`"));
5986+
}
5987+
59845988
// FIXME #5668: this will occur for a macro invocation:
59855989
match self.parse_macro_use_or_failure(attrs, true, false, lo, visibility)? {
59865990
Some(item) => {

src/test/parse-fail/removed-syntax-extern-const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
extern {
1414
const i: isize;
15-
//~^ ERROR expected one of `fn`, `pub`, `static`, or `}`, found `const`
15+
//~^ ERROR extern items cannot be `const`
1616
}

0 commit comments

Comments
 (0)