Skip to content

Commit 6c33f50

Browse files
committed
Fix #6342
1 parent 15e4438 commit 6c33f50

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4186,10 +4186,10 @@ pub impl Parser {
41864186
return iovi_foreign_item(item);
41874187
}
41884188
if (self.is_keyword("fn") || self.is_keyword("pure") ||
4189-
self.is_keyword("unsafe")) {
4189+
self.is_keyword("unsafe")) {
41904190
// FOREIGN FUNCTION ITEM
4191-
let item = self.parse_item_foreign_fn(attrs);
4192-
return iovi_foreign_item(item);
4191+
let item = self.parse_item_foreign_fn(attrs);
4192+
return iovi_foreign_item(item);
41934193
}
41944194
self.parse_macro_use_or_failure(attrs,macros_allowed,lo,visibility)
41954195
}
@@ -4504,7 +4504,12 @@ pub impl Parser {
45044504
let mut foreign_items = ~[];
45054505
loop {
45064506
match self.parse_foreign_item(/*bad*/ copy attrs, macros_allowed) {
4507-
iovi_none => break,
4507+
iovi_none => {
4508+
if *self.token == token::RBRACE {
4509+
break
4510+
}
4511+
self.unexpected();
4512+
},
45084513
iovi_view_item(view_item) => {
45094514
// I think this can't occur:
45104515
self.span_err(view_item.span,

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:unexpected token
12+
extern {
13+
f();
14+
}
15+
16+
fn main() {
17+
}

0 commit comments

Comments
 (0)