Skip to content

Commit

Permalink
Rollup merge of rust-lang#33336 - birkenfeld:issue-27361, r=sfackler
Browse files Browse the repository at this point in the history
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: rust-lang#27361
  • Loading branch information
steveklabnik committed May 5, 2016
2 parents 9a7e997 + b75f81c commit 5e1487d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6020,7 +6020,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)?));
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/parse-fail/extern-no-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/parse-fail/removed-syntax-extern-const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}

0 comments on commit 5e1487d

Please sign in to comment.