about summary refs log tree commit diff
path: root/src/comp/front
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-06-16 16:38:23 -0700
committerBrian Anderson <banderson@mozilla.com>2011-06-16 17:23:20 -0700
commitffa7c76ed2496309330f8e738d4cd5a1e8fb0c81 (patch)
tree5c096f7b09a0559b2a2c96e0bd3189974e9a387d /src/comp/front
parente83a115d7987aead4d4ea33b0ca4dda6cd9aa0f0 (diff)
downloadrust-ffa7c76ed2496309330f8e738d4cd5a1e8fb0c81.tar.gz
rust-ffa7c76ed2496309330f8e738d4cd5a1e8fb0c81.zip
rustc: Change print_file to print_crate
The pretty-printer needs access to the crate attributes in order to reproduce
inner crate attributes in standalone .rs files

Issue #487
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/ast.rs4
-rw-r--r--src/comp/front/parser.rs12
2 files changed, 10 insertions, 6 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index 303c8b2909c..86971de7cf1 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -76,7 +76,9 @@ fn def_id_of_def(def d) -> def_id {
 
 type crate = spanned[crate_];
 
-type crate_ = rec(vec[@crate_directive] directives, _mod module);
+type crate_ = rec(vec[@crate_directive] directives,
+                  _mod module,
+                  vec[attribute] attrs);
 
 tag meta_visibility { export_meta; local_meta; }
 
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 33ddcc6d57d..364cd3b846e 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -2285,13 +2285,14 @@ 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();
-    // 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));
+    ret @spanned(lo, p.get_lo_pos(), rec(directives=cdirs,
+                                         module=m,
+                                         attrs=crate_attrs._0));
 }
 
 
@@ -2381,8 +2382,7 @@ fn parse_crate_directives(&parser p, token::token term) ->
 fn parse_crate_from_crate_file(&parser p) -> @ast::crate {
     auto lo = p.get_lo_pos();
     auto prefix = std::fs::dirname(p.get_filemap().name);
-    // FIXME (issue #487): Do something with these attrs
-    auto attrs = parse_inner_attrs(p);
+    auto crate_attrs = parse_inner_attrs(p);
     auto cdirs = parse_crate_directives(p, token::EOF);
     let vec[str] deps = [];
     auto cx =
@@ -2396,7 +2396,9 @@ fn parse_crate_from_crate_file(&parser p) -> @ast::crate {
         eval::eval_crate_directives_to_mod(cx, p.get_env(), cdirs, prefix);
     auto hi = p.get_hi_pos();
     expect(p, token::EOF);
-    ret @spanned(lo, hi, rec(directives=cdirs, module=m));
+    ret @spanned(lo, hi, rec(directives=cdirs,
+                             module=m,
+                             attrs=crate_attrs));
 }
 //
 // Local Variables: