Rollup merge of #33336 - birkenfeld:issue-27361, r=sfackler

parser: do not try to continue with `unsafe` on foreign fns

The changed line makes it look like `unsafe` is allowed, but the first statement of `parse_item_foreign_fn` is:

```
self.expect_keyword(keywords::Fn)?;
```

So we get the strange "expected one of `fn`, `pub`, `static`, or `unsafe`, found `unsafe`".

Fixes: #27361
This commit is contained in:
Steve Klabnik 2016-05-07 15:35:17 -04:00
commit a8162171fd
3 changed files with 3 additions and 3 deletions

View File

@ -6013,7 +6013,7 @@ impl<'a> Parser<'a> {
// FOREIGN STATIC ITEM
return Ok(Some(self.parse_item_foreign_static(visibility, lo, attrs)?));
}
if self.check_keyword(keywords::Fn) || self.check_keyword(keywords::Unsafe) {
if self.check_keyword(keywords::Fn) {
// FOREIGN FUNCTION ITEM
return Ok(Some(self.parse_item_foreign_fn(visibility, lo, attrs)?));
}

View File

@ -11,7 +11,7 @@
// compile-flags: -Z parse-only
extern {
f(); //~ ERROR expected one of `fn`, `pub`, `static`, `unsafe`, or `}`, found `f`
f(); //~ ERROR expected one of `fn`, `pub`, `static`, or `}`, found `f`
}
fn main() {

View File

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