From 0b9e23146b75c02dd9059dc754070884595f3104 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 14 Jan 2013 19:06:59 -0800 Subject: [PATCH] convert ast::crate_ into a struct. --- src/librustc/front/core_inject.rs | 2 +- src/librustc/front/intrinsic_inject.rs | 9 +++++++-- src/librustc/front/test.rs | 3 ++- src/libsyntax/ast.rs | 9 +++++---- src/libsyntax/fold.rs | 8 ++++---- src/libsyntax/parse/parser.rs | 8 ++++---- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/librustc/front/core_inject.rs b/src/librustc/front/core_inject.rs index e3de8448130..7345c76fc3b 100644 --- a/src/librustc/front/core_inject.rs +++ b/src/librustc/front/core_inject.rs @@ -69,7 +69,7 @@ fn inject_libcore_ref(sess: Session, new_module = fld.fold_mod(new_module); // XXX: Bad copy. - let new_crate = { module: new_module, ..copy crate }; + let new_crate = ast::crate_ { module: new_module, ..copy crate }; (new_crate, span) }, fold_mod: |module, fld| { diff --git a/src/librustc/front/intrinsic_inject.rs b/src/librustc/front/intrinsic_inject.rs index 14d31e2f841..169fe59e4b4 100644 --- a/src/librustc/front/intrinsic_inject.rs +++ b/src/librustc/front/intrinsic_inject.rs @@ -37,8 +37,13 @@ fn inject_intrinsic(sess: Session, crate: @ast::crate) -> @ast::crate { let items = vec::append(~[item], crate.node.module.items); @ast::spanned { - node: { module: { items: items ,.. /*bad*/copy crate.node.module }, - .. /*bad*/copy crate.node}, + node: ast::crate_ { + module: { + items: items, + .. /*bad*/copy crate.node.module + }, + .. /*bad*/copy crate.node + }, .. /*bad*/copy *crate } } diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 979cc902cc7..f0380c78634 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -113,7 +113,8 @@ fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) -> // Add a special __test module to the crate that will contain code // generated for the test harness - return {module: add_test_module(cx, /*bad*/copy folded.module),.. folded}; + ast::crate_ { module: add_test_module(cx, /*bad*/copy folded.module), + .. folded } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 7f6a6429f16..0dd0555e8e8 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -293,10 +293,11 @@ type crate_cfg = ~[@meta_item]; type crate = spanned; -type crate_ = - {module: _mod, - attrs: ~[attribute], - config: crate_cfg}; +struct crate_ { + module: _mod, + attrs: ~[attribute], + config: crate_cfg, +} type meta_item = spanned; diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index b99a1a02540..c4c3b854e55 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -165,11 +165,11 @@ fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ { let fold_meta_item = |x| fold_meta_item_(x, fld); let fold_attribute = |x| fold_attribute_(x, fld); - return { + crate_ { module: fld.fold_mod(c.module), - attrs: vec::map(c.attrs, |x| fold_attribute(*x)), - config: vec::map(c.config, |x| fold_meta_item(*x)) - }; + attrs: c.attrs.map(|x| fold_attribute(*x)), + config: c.config.map(|x| fold_meta_item(*x)), + } } fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a5330b113dd..ce1e67be79e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3855,10 +3855,10 @@ impl Parser { let crate_attrs = self.parse_inner_attrs_and_next(); let first_item_outer_attrs = crate_attrs.next; let m = self.parse_mod_items(token::EOF, first_item_outer_attrs); - return @spanned(lo, self.span.lo, - {module: m, - attrs: crate_attrs.inner, - config: self.cfg}); + @spanned(lo, self.span.lo, + ast::crate_ { module: m, + attrs: crate_attrs.inner, + config: self.cfg }) } fn parse_str() -> @~str {