Skip to content

Commit 04097c6

Browse files
committed
Rollup merge of rust-lang#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: rust-lang#27361
2 parents a26f6ba + b75f81c commit 04097c6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6020,7 +6020,7 @@ impl<'a> Parser<'a> {
60206020
// FOREIGN STATIC ITEM
60216021
return Ok(Some(self.parse_item_foreign_static(visibility, lo, attrs)?));
60226022
}
6023-
if self.check_keyword(keywords::Fn) || self.check_keyword(keywords::Unsafe) {
6023+
if self.check_keyword(keywords::Fn) {
60246024
// FOREIGN FUNCTION ITEM
60256025
return Ok(Some(self.parse_item_foreign_fn(visibility, lo, attrs)?));
60266026
}

src/test/parse-fail/extern-no-fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// compile-flags: -Z parse-only
1212

1313
extern {
14-
f(); //~ ERROR expected one of `fn`, `pub`, `static`, `unsafe`, or `}`, found `f`
14+
f(); //~ ERROR expected one of `fn`, `pub`, `static`, or `}`, found `f`
1515
}
1616

1717
fn main() {

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`, `unsafe`, or `}`, found `const`
15+
//~^ ERROR expected one of `fn`, `pub`, `static`, or `}`, found `const`
1616
}

0 commit comments

Comments
 (0)