diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 82c477a7d96..a8f294820af 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -2515,9 +2515,11 @@ fn parse_crate_directives(p: parser, term: token::token, } let cdirs: [@ast::crate_directive] = []; + let first_outer_attr = first_outer_attr; while p.peek() != term { let cdir = @parse_crate_directive(p, first_outer_attr); cdirs += [cdir]; + first_outer_attr = []; } ret cdirs; } diff --git a/src/test/run-pass/dupe-first-attr.rc b/src/test/run-pass/dupe-first-attr.rc new file mode 100644 index 00000000000..65798b048f9 --- /dev/null +++ b/src/test/run-pass/dupe-first-attr.rc @@ -0,0 +1,11 @@ +// Regression test for a problem with the first mod attribute +// being applied to every mod + +#[cfg(target_os = "linux")] +mod hello; + +#[cfg(target_os = "macos")] +mod hello; + +#[cfg(target_os = "win32")] +mod hello; \ No newline at end of file