Skip to content

Commit 7905ffa

Browse files
committed
---
yaml --- r: 3141 b: refs/heads/master c: 6c2f322 h: refs/heads/master i: 3139: 470565e v: v3
1 parent 8036d8e commit 7905ffa

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 67360ae61808453d308496f90e0b3faa3e8efee3
2+
refs/heads/master: 6c2f322f827ca2f2109bceab0b9630e624ac8810

trunk/src/comp/front/parser.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,19 @@ fn parse_source_stmt(&parser p) -> @ast::stmt {
14511451
}
14521452
}
14531453

1454-
alt (parse_item(p, item_attrs)) {
1454+
auto maybe_item = parse_item(p, item_attrs);
1455+
1456+
// If we have attributes then we should have an item
1457+
if (vec::len(item_attrs) > 0u) {
1458+
alt (maybe_item) {
1459+
case (got_item(_)) { /* fallthrough */ }
1460+
case (_) {
1461+
ret p.err("expected item");
1462+
}
1463+
}
1464+
}
1465+
1466+
alt (maybe_item) {
14551467
case (got_item(?i)) {
14561468
auto hi = i.span.hi;
14571469
auto decl = @spanned(lo, hi, ast::decl_item(i));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// xfail-stage0
2+
// error-pattern:expected item
3+
4+
fn f() {
5+
#[foo = "bar"]
6+
auto x = 10;
7+
}
8+
9+
fn main() {
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// xfail-stage0
2+
// error-pattern:expected item
3+
4+
#[foo = "bar"]
5+
use std;
6+
7+
fn main() {
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// xfail-stage0
2+
// error-pattern:expected item
3+
4+
fn f() {
5+
#[foo = "bar"]
6+
}
7+
8+
fn main() {
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// xfail-stage0
2+
// error-pattern:expected item
3+
4+
fn main() {
5+
}
6+
7+
#[foo = "bar"]

0 commit comments

Comments
 (0)