From e83a115d7987aead4d4ea33b0ca4dda6cd9aa0f0 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 16 Jun 2011 16:09:43 -0700 Subject: [PATCH] rustc: Parse crate attributes in standalone .rs files Issue #487 --- src/comp/front/parser.rs | 6 +++++- src/test/run-pass/item-attributes.rs | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index f1121c814aa9..33ddcc6d57d0 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -2285,7 +2285,11 @@ fn parse_native_view(&parser p) -> vec[@ast::view_item] { fn parse_crate_from_source_file(&parser p) -> @ast::crate { auto lo = p.get_lo_pos(); - auto m = parse_mod_items(p, token::EOF, []); + // FIXME (issue #487): Do something with these attrs + auto crate_attrs = parse_inner_attrs_and_next(p); + auto first_item_outer_attrs = crate_attrs._1; + auto m = parse_mod_items(p, token::EOF, + first_item_outer_attrs); let vec[@ast::crate_directive] cdirs = []; ret @spanned(lo, p.get_lo_pos(), rec(directives=cdirs, module=m)); } diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index f9a8c6134869..667e537ca378 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -1,5 +1,11 @@ // xfail-stage0 +// These are attributes of the implicit crate. Really this just needs to parse +// for completeness since .rs files linked from .rc files support this +// notation to specify their module's attributes +#[attr1 = "val"]; +#[attr2 = "val"]; + // These are are attributes of the following mod #[attr1 = "val"] #[attr2 = "val"]