Improve error message for const extern fn

This commit is contained in:
Manish Goregaokar 2017-05-30 14:23:02 -07:00
parent f89d8d1844
commit 22c4ee365c
2 changed files with 5 additions and 1 deletions

View File

@ -5981,6 +5981,10 @@ impl<'a> Parser<'a> {
return Ok(Some(self.parse_item_foreign_fn(visibility, lo, attrs)?));
}
if self.check_keyword(keywords::Const) {
return Err(self.span_fatal(self.span, "extern items cannot be `const`"));
}
// FIXME #5668: this will occur for a macro invocation:
match self.parse_macro_use_or_failure(attrs, true, false, lo, visibility)? {
Some(item) => {

View File

@ -12,5 +12,5 @@
extern {
const i: isize;
//~^ ERROR expected one of `fn`, `pub`, `static`, or `}`, found `const`
//~^ ERROR extern items cannot be `const`
}