diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-06-16 14:59:51 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-06-16 17:23:20 -0700 |
| commit | 62939e41b23ebcb0fb4fd1f2abefe360d313fe56 (patch) | |
| tree | e7d3e142a303612a2d1e105e70d8b4a0dce71a3a /src | |
| parent | 40746fa447b78a27b649db41a6bfe63f6645d5eb (diff) | |
| download | rust-62939e41b23ebcb0fb4fd1f2abefe360d313fe56.tar.gz rust-62939e41b23ebcb0fb4fd1f2abefe360d313fe56.zip | |
rustc: Parse inner items of file-level modules linked from crate files
Issue #487
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/front/eval.rs | 12 | ||||
| -rw-r--r-- | src/test/run-pass/crate-attributes-src/foo.rs | 8 | ||||
| -rw-r--r-- | src/test/run-pass/crate-attributes.rc | 3 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/comp/front/eval.rs b/src/comp/front/eval.rs index 9c1fad981ae..3366ddf51ab 100644 --- a/src/comp/front/eval.rs +++ b/src/comp/front/eval.rs @@ -10,6 +10,7 @@ import ast::ident; import front::parser::parser; import front::parser::spanned; import front::parser::new_parser; +import front::parser::parse_inner_attributes; import front::parser::parse_mod_items; import util::common; import util::common::filename; @@ -287,16 +288,19 @@ fn eval_crate_directive(ctx cx, env e, @ast::crate_directive cdir, str prefix, auto p0 = new_parser(cx.sess, e, start_id, full_path, cx.chpos, cx.next_ann); - auto m0 = parse_mod_items(p0, token::EOF, []); + auto inner_attrs = parse_inner_attributes(p0); + auto first_item_outer_attrs = inner_attrs._1; + auto m0 = parse_mod_items(p0, token::EOF, + first_item_outer_attrs); auto next_id = p0.next_def_id(); // Thread defids and chpos through the parsers cx.p.set_def(next_id._1); cx.chpos = p0.get_chpos(); cx.next_ann = p0.next_ann_num(); - auto i = - front::parser::mk_item(cx.p, cdir.span.lo, cdir.span.hi, id, - ast::item_mod(m0), []); + auto i = front::parser::mk_item(cx.p, cdir.span.lo, cdir.span.hi, + id, ast::item_mod(m0), + inner_attrs._0); vec::push[@ast::item](items, i); } case (ast::cdir_dir_mod(?id, ?dir_opt, ?cdirs)) { diff --git a/src/test/run-pass/crate-attributes-src/foo.rs b/src/test/run-pass/crate-attributes-src/foo.rs new file mode 100644 index 00000000000..5ab36dfe00d --- /dev/null +++ b/src/test/run-pass/crate-attributes-src/foo.rs @@ -0,0 +1,8 @@ +// These are attributes of the foo module +#[attr1 = "val"]; +#[attr2 = "val"]; + +// Attributes of the following function +#[attr1 = "val"] +#[attr2 = "val"] +fn main() { } diff --git a/src/test/run-pass/crate-attributes.rc b/src/test/run-pass/crate-attributes.rc new file mode 100644 index 00000000000..c0ed56556b8 --- /dev/null +++ b/src/test/run-pass/crate-attributes.rc @@ -0,0 +1,3 @@ +mod m = "crate-attributes-src" { + mod foo; +} \ No newline at end of file |
