Skip to content

Commit 27ab663

Browse files
committed
rustc: Don't ignore attributes inside empty mods. Closes #1655
1 parent ffa77dd commit 27ab663

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/comp/syntax/parse/parser.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,6 @@ fn parse_mod_items(p: parser, term: token::token,
20682068
let initial_attrs = first_item_attrs;
20692069
while p.token != term {
20702070
let attrs = initial_attrs + parse_outer_attributes(p);
2071-
initial_attrs = [];
20722071
#debug["parse_mod_items: parse_item(attrs=%?)", attrs];
20732072
alt parse_item(p, attrs) {
20742073
some(i) { items += [i]; }
@@ -2078,7 +2077,14 @@ fn parse_mod_items(p: parser, term: token::token,
20782077
}
20792078
}
20802079
#debug["parse_mod_items: attrs=%?", attrs];
2080+
initial_attrs = [];
2081+
}
2082+
2083+
if vec::is_not_empty(initial_attrs) {
2084+
// We parsed attributes for the first item but didn't find the item
2085+
p.fatal("expected item");
20812086
}
2087+
20822088
ret {view_items: view_items, items: items};
20832089
}
20842090

src/test/compile-fail/issue-1655.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// error-pattern:expected item
2+
mod blade_runner {
3+
#[doc(
4+
brief = "Blade Runner is probably the best movie ever",
5+
desc = "I like that in the world of Blade Runner it is always
6+
raining, and that it's always night time. And Aliens
7+
was also a really good movie.
8+
9+
Alien 3 was crap though."
10+
)]
11+
}

0 commit comments

Comments
 (0)