Skip to content

Commit

Permalink
Fix #6342
Browse files Browse the repository at this point in the history
  • Loading branch information
yjh0502 committed May 22, 2013
1 parent 15e4438 commit 6c33f50
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -4186,10 +4186,10 @@ pub impl Parser {
return iovi_foreign_item(item);
}
if (self.is_keyword("fn") || self.is_keyword("pure") ||
self.is_keyword("unsafe")) {
self.is_keyword("unsafe")) {
// FOREIGN FUNCTION ITEM
let item = self.parse_item_foreign_fn(attrs);
return iovi_foreign_item(item);
let item = self.parse_item_foreign_fn(attrs);
return iovi_foreign_item(item);
}
self.parse_macro_use_or_failure(attrs,macros_allowed,lo,visibility)
}
Expand Down Expand Up @@ -4504,7 +4504,12 @@ pub impl Parser {
let mut foreign_items = ~[];
loop {
match self.parse_foreign_item(/*bad*/ copy attrs, macros_allowed) {
iovi_none => break,
iovi_none => {
if *self.token == token::RBRACE {
break
}
self.unexpected();
},
iovi_view_item(view_item) => {
// I think this can't occur:
self.span_err(view_item.span,
Expand Down
17 changes: 17 additions & 0 deletions src/test/compile-fail/extern-no-fn.rs
@@ -0,0 +1,17 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:unexpected token
extern {
f();
}

fn main() {
}

5 comments on commit 6c33f50

@bors
Copy link
Contributor

@bors bors commented on 6c33f50 May 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from graydon
at yjh0502@6c33f50

@bors
Copy link
Contributor

@bors bors commented on 6c33f50 May 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging yjh0502/rust/fix_6342 = 6c33f50 into auto

@bors
Copy link
Contributor

@bors bors commented on 6c33f50 May 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yjh0502/rust/fix_6342 = 6c33f50 merged ok, testing candidate = 4bbbae6

@bors
Copy link
Contributor

@bors bors commented on 6c33f50 May 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 6c33f50 May 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 4bbbae6

Please sign in to comment.