Skip to content

Commit 7aee9f7

Browse files
committed
rustc: Fix a bug in cdir attribute parsing
The first attribute of the first mod was being applied to every mod.
1 parent 3e303af commit 7aee9f7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/comp/syntax/parse/parser.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,9 +2515,11 @@ fn parse_crate_directives(p: parser, term: token::token,
25152515
}
25162516

25172517
let cdirs: [@ast::crate_directive] = [];
2518+
let first_outer_attr = first_outer_attr;
25182519
while p.peek() != term {
25192520
let cdir = @parse_crate_directive(p, first_outer_attr);
25202521
cdirs += [cdir];
2522+
first_outer_attr = [];
25212523
}
25222524
ret cdirs;
25232525
}

src/test/run-pass/dupe-first-attr.rc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Regression test for a problem with the first mod attribute
2+
// being applied to every mod
3+
4+
#[cfg(target_os = "linux")]
5+
mod hello;
6+
7+
#[cfg(target_os = "macos")]
8+
mod hello;
9+
10+
#[cfg(target_os = "win32")]
11+
mod hello;

0 commit comments

Comments
 (0)