From 5c0d674a45dca39d32e3b30af48e2faf718d43d7 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sun, 13 Jan 2013 12:02:16 -0800 Subject: [PATCH] convert ast::foreign_item to a struct --- src/librustc/middle/trans/type_use.rs | 3 ++- src/librustdoc/tystr_pass.rs | 2 +- src/libsyntax/ast.rs | 15 ++++++------ src/libsyntax/fold.rs | 34 +++++++++++++++------------ src/libsyntax/parse/parser.rs | 24 +++++++++---------- 5 files changed, 42 insertions(+), 36 deletions(-) diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index e17a9c8c0ede..f59c42315deb 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -107,7 +107,8 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ast_map::node_variant(_, _, _) => { for uint::range(0u, n_tps) |n| { cx.uses[n] |= use_repr;} } - ast_map::node_foreign_item(i@@{node: foreign_item_fn(*), _}, + ast_map::node_foreign_item(i@@foreign_item { node: foreign_item_fn(*), + _ }, abi, _) => { if abi == foreign_abi_rust_intrinsic { let flags = match cx.ccx.sess.str_of(i.ident) { diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index ae1b7577ad83..d782b54c80a7 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -72,7 +72,7 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> { ident: ident, node: ast::item_fn(decl, _, tys, _), _ }, _) | - ast_map::node_foreign_item(@{ + ast_map::node_foreign_item(@ast::foreign_item { ident: ident, node: ast::foreign_item_fn(decl, _, tys), _ }, _, _) => { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a6e66cbf46a2..5d822b317729 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1574,13 +1574,14 @@ type struct_dtor_ = {id: node_id, #[auto_encode] #[auto_decode] -type foreign_item = - {ident: ident, - attrs: ~[attribute], - node: foreign_item_, - id: node_id, - span: span, - vis: visibility}; +struct foreign_item { + ident: ident, + attrs: ~[attribute], + node: foreign_item_, + id: node_id, + span: span, + vis: visibility, +} #[auto_encode] #[auto_decode] diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 2a832fc5f12e..a5cb9dcfaa20 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -178,25 +178,29 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) let fold_arg = |x| fold_arg_(x, fld); let fold_attribute = |x| fold_attribute_(x, fld); - return @{ident: fld.fold_ident(ni.ident), - attrs: vec::map(ni.attrs, |x| fold_attribute(*x)), - node: - match ni.node { + @ast::foreign_item { + ident: fld.fold_ident(ni.ident), + attrs: vec::map(ni.attrs, |x| fold_attribute(*x)), + node: + match ni.node { foreign_item_fn(fdec, purity, typms) => { - foreign_item_fn( - {inputs: vec::map(fdec.inputs, |a| fold_arg(*a)), - output: fld.fold_ty(fdec.output), - cf: fdec.cf}, - purity, - fold_ty_params(typms, fld)) + foreign_item_fn( + { + inputs: fdec.inputs.map(|a| fold_arg(*a)), + output: fld.fold_ty(fdec.output), + cf: fdec.cf, + }, + purity, + fold_ty_params(typms, fld)) } foreign_item_const(t) => { - foreign_item_const(fld.fold_ty(t)) + foreign_item_const(fld.fold_ty(t)) } - }, - id: fld.new_id(ni.id), - span: fld.new_span(ni.span), - vis: ni.vis}; + }, + id: fld.new_id(ni.id), + span: fld.new_span(ni.span), + vis: ni.vis, + } } fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2a8014a218cc..7d247afaa530 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3123,12 +3123,12 @@ impl Parser { let (decl, _) = self.parse_fn_decl(|p| p.parse_arg()); let mut hi = self.span.hi; self.expect(token::SEMI); - return @{ident: t.ident, - attrs: attrs, - node: foreign_item_fn(decl, purity, t.tps), - id: self.get_id(), - span: mk_sp(lo, hi), - vis: vis}; + @ast::foreign_item { ident: t.ident, + attrs: attrs, + node: foreign_item_fn(decl, purity, t.tps), + id: self.get_id(), + span: mk_sp(lo, hi), + vis: vis } } fn parse_item_foreign_const(vis: ast::visibility, @@ -3140,12 +3140,12 @@ impl Parser { let ty = self.parse_ty(false); let hi = self.span.hi; self.expect(token::SEMI); - return @{ident: ident, - attrs: attrs, - node: foreign_item_const(move ty), - id: self.get_id(), - span: mk_sp(lo, hi), - vis: vis}; + @ast::foreign_item { ident: ident, + attrs: attrs, + node: foreign_item_const(ty), + id: self.get_id(), + span: mk_sp(lo, hi), + vis: vis } } fn parse_fn_purity() -> purity {