Skip to content

Commit e83a115

Browse files
committed
rustc: Parse crate attributes in standalone .rs files
Issue #487
1 parent ffae642 commit e83a115

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/comp/front/parser.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,11 @@ fn parse_native_view(&parser p) -> vec[@ast::view_item] {
22852285

22862286
fn parse_crate_from_source_file(&parser p) -> @ast::crate {
22872287
auto lo = p.get_lo_pos();
2288-
auto m = parse_mod_items(p, token::EOF, []);
2288+
// FIXME (issue #487): Do something with these attrs
2289+
auto crate_attrs = parse_inner_attrs_and_next(p);
2290+
auto first_item_outer_attrs = crate_attrs._1;
2291+
auto m = parse_mod_items(p, token::EOF,
2292+
first_item_outer_attrs);
22892293
let vec[@ast::crate_directive] cdirs = [];
22902294
ret @spanned(lo, p.get_lo_pos(), rec(directives=cdirs, module=m));
22912295
}

src/test/run-pass/item-attributes.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// xfail-stage0
22

3+
// These are attributes of the implicit crate. Really this just needs to parse
4+
// for completeness since .rs files linked from .rc files support this
5+
// notation to specify their module's attributes
6+
#[attr1 = "val"];
7+
#[attr2 = "val"];
8+
39
// These are are attributes of the following mod
410
#[attr1 = "val"]
511
#[attr2 = "val"]

0 commit comments

Comments
 (0)