1
Fork 0

libsyntax: make enum variants take refs

This commit is contained in:
Erick Tryzelaar 2013-02-17 10:59:09 -08:00
parent 59ba4fc104
commit bc62bd3782
9 changed files with 149 additions and 103 deletions

View file

@ -193,7 +193,7 @@ pub fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
cx.local_id += 1u; cx.local_id += 1u;
} }
match fk { match fk {
visit::fk_dtor(tps, ref attrs, self_id, parent_id) => { visit::fk_dtor(ref tps, ref attrs, self_id, parent_id) => {
let dt = @spanned { let dt = @spanned {
node: ast::struct_dtor_ { node: ast::struct_dtor_ {
id: id, id: id,
@ -203,7 +203,7 @@ pub fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
}, },
span: sp, span: sp,
}; };
cx.map.insert(id, node_dtor(/* FIXME (#2543) */ copy tps, dt, cx.map.insert(id, node_dtor(/* FIXME (#2543) */ copy *tps, dt,
parent_id, parent_id,
@/* FIXME (#2543) */ copy cx.path)); @/* FIXME (#2543) */ copy cx.path));
} }
@ -286,7 +286,7 @@ pub fn map_item(i: @item, &&cx: @mut Ctx, v: vt) {
map_struct_def(struct_def, node_item(i, item_path), i.ident, cx, map_struct_def(struct_def, node_item(i, item_path), i.ident, cx,
v); v);
} }
item_trait(_, traits, ref methods) => { item_trait(_, ref traits, ref methods) => {
for traits.each |p| { for traits.each |p| {
cx.map.insert(p.ref_id, node_item(i, item_path)); cx.map.insert(p.ref_id, node_item(i, item_path));
} }

View file

@ -327,8 +327,8 @@ pub impl inlined_item_utils for inlined_item {
ii_item(i) => (v.visit_item)(i, e, v), ii_item(i) => (v.visit_item)(i, e, v),
ii_foreign(i) => (v.visit_foreign_item)(i, e, v), ii_foreign(i) => (v.visit_foreign_item)(i, e, v),
ii_method(_, m) => visit::visit_method_helper(m, e, v), ii_method(_, m) => visit::visit_method_helper(m, e, v),
ii_dtor(ref dtor, _, tps, parent_id) => { ii_dtor(/*bad*/ copy dtor, _, /*bad*/ copy tps, parent_id) => {
visit::visit_struct_dtor_helper((*dtor), tps, parent_id, e, v); visit::visit_struct_dtor_helper(dtor, tps, parent_id, e, v);
} }
} }
} }

View file

@ -127,24 +127,24 @@ pub fn expand_auto_encode(
do vec::flat_map(in_items) |item| { do vec::flat_map(in_items) |item| {
if item.attrs.any(is_auto_encode) { if item.attrs.any(is_auto_encode) {
match item.node { match item.node {
ast::item_struct(@ast::struct_def { fields, _}, tps) => { ast::item_struct(ref struct_def, ref tps) => {
let ser_impl = mk_struct_ser_impl( let ser_impl = mk_struct_ser_impl(
cx, cx,
item.span, item.span,
item.ident, item.ident,
fields, struct_def.fields,
tps *tps
); );
~[filter_attrs(*item), ser_impl] ~[filter_attrs(*item), ser_impl]
}, },
ast::item_enum(ref enum_def, tps) => { ast::item_enum(ref enum_def, ref tps) => {
let ser_impl = mk_enum_ser_impl( let ser_impl = mk_enum_ser_impl(
cx, cx,
item.span, item.span,
item.ident, item.ident,
(*enum_def), *enum_def,
tps *tps
); );
~[filter_attrs(*item), ser_impl] ~[filter_attrs(*item), ser_impl]
@ -182,24 +182,24 @@ pub fn expand_auto_decode(
do vec::flat_map(in_items) |item| { do vec::flat_map(in_items) |item| {
if item.attrs.any(is_auto_decode) { if item.attrs.any(is_auto_decode) {
match item.node { match item.node {
ast::item_struct(@ast::struct_def { fields, _}, tps) => { ast::item_struct(ref struct_def, ref tps) => {
let deser_impl = mk_struct_deser_impl( let deser_impl = mk_struct_deser_impl(
cx, cx,
item.span, item.span,
item.ident, item.ident,
fields, struct_def.fields,
tps *tps
); );
~[filter_attrs(*item), deser_impl] ~[filter_attrs(*item), deser_impl]
}, },
ast::item_enum(ref enum_def, tps) => { ast::item_enum(ref enum_def, ref tps) => {
let deser_impl = mk_enum_deser_impl( let deser_impl = mk_enum_deser_impl(
cx, cx,
item.span, item.span,
item.ident, item.ident,
(*enum_def), *enum_def,
tps *tps
); );
~[filter_attrs(*item), deser_impl] ~[filter_attrs(*item), deser_impl]
@ -410,7 +410,7 @@ fn mk_impl(
ident: ast::ident, ident: ast::ident,
ty_param: ast::ty_param, ty_param: ast::ty_param,
path: @ast::path, path: @ast::path,
tps: ~[ast::ty_param], tps: &[ast::ty_param],
f: fn(@ast::Ty) -> @ast::method f: fn(@ast::Ty) -> @ast::method
) -> @ast::item { ) -> @ast::item {
// All the type parameters need to bound to the trait. // All the type parameters need to bound to the trait.
@ -458,7 +458,7 @@ fn mk_ser_impl(
cx: ext_ctxt, cx: ext_ctxt,
span: span, span: span,
ident: ast::ident, ident: ast::ident,
tps: ~[ast::ty_param], tps: &[ast::ty_param],
body: @ast::expr body: @ast::expr
) -> @ast::item { ) -> @ast::item {
// Make a path to the std::serialize::Encodable typaram. // Make a path to the std::serialize::Encodable typaram.
@ -666,8 +666,8 @@ fn mk_struct_ser_impl(
cx: ext_ctxt, cx: ext_ctxt,
span: span, span: span,
ident: ast::ident, ident: ast::ident,
fields: ~[@ast::struct_field], fields: &[@ast::struct_field],
tps: ~[ast::ty_param] tps: &[ast::ty_param]
) -> @ast::item { ) -> @ast::item {
let fields = do mk_struct_fields(fields).mapi |idx, field| { let fields = do mk_struct_fields(fields).mapi |idx, field| {
// ast for `|| self.$(name).encode(__s)` // ast for `|| self.$(name).encode(__s)`
@ -808,7 +808,7 @@ struct field {
mutbl: ast::mutability, mutbl: ast::mutability,
} }
fn mk_struct_fields(fields: ~[@ast::struct_field]) -> ~[field] { fn mk_struct_fields(fields: &[@ast::struct_field]) -> ~[field] {
do fields.map |field| { do fields.map |field| {
let (ident, mutbl) = match field.node.kind { let (ident, mutbl) = match field.node.kind {
ast::named_field(ident, mutbl, _) => (ident, mutbl), ast::named_field(ident, mutbl, _) => (ident, mutbl),

View file

@ -54,27 +54,27 @@ pub impl proto::visitor<(), (), ()> for ext_ctxt {
fn visit_message(&self, name: ~str, _span: span, _tys: &[@ast::Ty], fn visit_message(&self, name: ~str, _span: span, _tys: &[@ast::Ty],
this: state, next: Option<next_state>) { this: state, next: Option<next_state>) {
match next { match next {
Some(next_state { state: ref next, tys: next_tys }) => { Some(ref next_state) => {
let proto = this.proto; let proto = this.proto;
if !proto.has_state((*next)) { if !proto.has_state(next_state.state) {
// This should be a span fatal, but then we need to // This should be a span fatal, but then we need to
// track span information. // track span information.
self.span_err( self.span_err(
proto.get_state((*next)).span, proto.get_state(next_state.state).span,
fmt!("message %s steps to undefined state, %s", fmt!("message %s steps to undefined state, %s",
name, (*next))); name, next_state.state));
} }
else { else {
let next = proto.get_state((*next)); let next = proto.get_state(next_state.state);
if next.ty_params.len() != next_tys.len() { if next.ty_params.len() != next_state.tys.len() {
self.span_err( self.span_err(
next.span, // use a real span next.span, // use a real span
fmt!("message %s target (%s) \ fmt!("message %s target (%s) \
needs %u type parameters, but got %u", needs %u type parameters, but got %u",
name, next.name, name, next.name,
next.ty_params.len(), next.ty_params.len(),
next_tys.len())); next_state.tys.len()));
} }
} }
} }

View file

@ -50,16 +50,13 @@ pub impl gen_send for message {
fn gen_send(&self, cx: ext_ctxt, try: bool) -> @ast::item { fn gen_send(&self, cx: ext_ctxt, try: bool) -> @ast::item {
debug!("pipec: gen_send"); debug!("pipec: gen_send");
match *self { match *self {
message(ref _id, span, tys, this, message(ref _id, span, ref tys, this, Some(ref next_state)) => {
Some(next_state {state: ref next, tys: next_tys})) => {
debug!("pipec: next state exists"); debug!("pipec: next state exists");
let next = this.proto.get_state((*next)); let next = this.proto.get_state(next_state.state);
assert next_tys.len() == next.ty_params.len(); assert next_state.tys.len() == next.ty_params.len();
let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str())); let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str()));
let args_ast = (arg_names, tys).map( let args_ast = (arg_names, *tys).map(|n, t| cx.arg(*n, *t));
|n, t| cx.arg(*n, *t)
);
let pipe_ty = cx.ty_path_ast_builder( let pipe_ty = cx.ty_path_ast_builder(
path(~[this.data_name()], span) path(~[this.data_name()], span)
@ -119,7 +116,7 @@ pub impl gen_send for message {
let mut rty = cx.ty_path_ast_builder(path(~[next.data_name()], let mut rty = cx.ty_path_ast_builder(path(~[next.data_name()],
span) span)
.add_tys(next_tys)); .add_tys(next_state.tys));
if try { if try {
rty = cx.ty_option(rty); rty = cx.ty_option(rty);
} }
@ -134,13 +131,13 @@ pub impl gen_send for message {
cx.expr_block(body)) cx.expr_block(body))
} }
message(ref _id, span, tys, this, None) => { message(ref _id, span, ref tys, this, None) => {
debug!("pipec: no next state"); debug!("pipec: no next state");
let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str())); let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str()));
let args_ast = (arg_names, tys).map( let args_ast = do (arg_names, *tys).map |n, t| {
|n, t| cx.arg(cx.ident_of(*n), *t) cx.arg(cx.ident_of(*n), *t)
); };
let args_ast = vec::append( let args_ast = vec::append(
~[cx.arg(cx.ident_of(~"pipe"), ~[cx.arg(cx.ident_of(~"pipe"),
@ -219,8 +216,8 @@ pub impl to_type_decls for state {
let message(name, span, tys, this, next) = *m; let message(name, span, tys, this, next) = *m;
let tys = match next { let tys = match next {
Some(next_state { state: ref next, tys: next_tys }) => { Some(ref next_state) => {
let next = this.proto.get_state((*next)); let next = this.proto.get_state((next_state.state));
let next_name = cx.str_of(next.data_name()); let next_name = cx.str_of(next.data_name());
let dir = match this.dir { let dir = match this.dir {
@ -232,7 +229,7 @@ pub impl to_type_decls for state {
cx.ty_path_ast_builder( cx.ty_path_ast_builder(
path(~[cx.ident_of(dir), path(~[cx.ident_of(dir),
cx.ident_of(next_name)], span) cx.ident_of(next_name)], span)
.add_tys(next_tys))) .add_tys(next_state.tys)))
} }
None => tys None => tys
}; };

View file

@ -59,12 +59,13 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
arg_reader as reader, argument_gram); arg_reader as reader, argument_gram);
// Extract the arguments: // Extract the arguments:
let lhses:~[@named_match] = match argument_map.get(&lhs_nm) { let lhses = match argument_map.get(&lhs_nm) {
@matched_seq(s, _) => s, @matched_seq(ref s, _) => /* FIXME (#2543) */ copy *s,
_ => cx.span_bug(sp, ~"wrong-structured lhs") _ => cx.span_bug(sp, ~"wrong-structured lhs")
}; };
let rhses:~[@named_match] = match argument_map.get(&rhs_nm) {
@matched_seq(s, _) => s, let rhses = match argument_map.get(&rhs_nm) {
@matched_seq(ref s, _) => /* FIXME (#2543) */ copy *s,
_ => cx.span_bug(sp, ~"wrong-structured rhs") _ => cx.span_bug(sp, ~"wrong-structured rhs")
}; };

View file

@ -82,10 +82,10 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item {
node: node:
match mi.node { match mi.node {
meta_word(ref id) => meta_word((*id)), meta_word(ref id) => meta_word((*id)),
meta_list(ref id, mis) => { meta_list(ref id, ref mis) => {
let fold_meta_item = |x|fold_meta_item_(x, fld); let fold_meta_item = |x| fold_meta_item_(x, fld);
meta_list(/* FIXME: (#2543) */ copy (*id), meta_list(/* FIXME: (#2543) */ copy *id,
vec::map(mis, |e| fold_meta_item(*e))) mis.map(|e| fold_meta_item(*e)))
} }
meta_name_value(ref id, s) => { meta_name_value(ref id, s) => {
meta_name_value((*id), /* FIXME (#2543) */ copy s) meta_name_value((*id), /* FIXME (#2543) */ copy s)
@ -215,42 +215,44 @@ fn noop_fold_struct_field(&&sf: @struct_field, fld: ast_fold)
pub fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { pub fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
match i { match i {
item_const(t, e) => item_const(fld.fold_ty(t), fld.fold_expr(e)), item_const(t, e) => item_const(fld.fold_ty(t), fld.fold_expr(e)),
item_fn(decl, purity, typms, ref body) => { item_fn(ref decl, purity, ref typms, ref body) => {
item_fn(fold_fn_decl(decl, fld), item_fn(fold_fn_decl(/* FIXME (#2543) */ copy *decl, fld),
purity, purity,
fold_ty_params(typms, fld), fold_ty_params(/* FIXME (#2543) */ copy *typms, fld),
fld.fold_block((*body))) fld.fold_block(*body))
} }
item_mod(m) => item_mod(fld.fold_mod(m)), item_mod(m) => item_mod(fld.fold_mod(m)),
item_foreign_mod(nm) => item_foreign_mod(fld.fold_foreign_mod(nm)), item_foreign_mod(nm) => item_foreign_mod(fld.fold_foreign_mod(nm)),
item_ty(t, typms) => item_ty(fld.fold_ty(t), item_ty(t, typms) => item_ty(fld.fold_ty(t),
fold_ty_params(typms, fld)), fold_ty_params(typms, fld)),
item_enum(ref enum_definition, typms) => { item_enum(ref enum_definition, ref typms) => {
item_enum(ast::enum_def(ast::enum_def_ { item_enum(ast::enum_def(ast::enum_def_ {
variants: enum_definition.variants.map( variants: enum_definition.variants.map(
|x| fld.fold_variant(*x)), |x| fld.fold_variant(*x)),
common: enum_definition.common.map( common: enum_definition.common.map(
|x| fold_struct_def(*x, fld)), |x| fold_struct_def(*x, fld)),
}), fold_ty_params(typms, fld)) }), fold_ty_params(/* FIXME (#2543) */ copy *typms, fld))
} }
item_struct(struct_def, typms) => { item_struct(ref struct_def, ref typms) => {
let struct_def = fold_struct_def(struct_def, fld); let struct_def = fold_struct_def(
item_struct(struct_def, /* FIXME (#2543) */ copy typms) /* FIXME (#2543) */ copy *struct_def,
fld);
item_struct(struct_def, /* FIXME (#2543) */ copy *typms)
} }
item_impl(tps, ifce, ty, ref methods) => { item_impl(ref tps, ifce, ty, ref methods) => {
item_impl(fold_ty_params(tps, fld), item_impl(fold_ty_params(/* FIXME (#2543) */ copy *tps, fld),
ifce.map(|p| fold_trait_ref(*p, fld)), ifce.map(|p| fold_trait_ref(*p, fld)),
fld.fold_ty(ty), fld.fold_ty(ty),
methods.map(|x| fld.fold_method(*x))) methods.map(|x| fld.fold_method(*x)))
} }
item_trait(tps, traits, ref methods) => { item_trait(ref tps, ref traits, ref methods) => {
let methods = do methods.map |method| { let methods = do methods.map |method| {
match *method { match *method {
required(*) => copy *method, required(*) => copy *method,
provided(method) => provided(fld.fold_method(method)) provided(method) => provided(fld.fold_method(method))
} }
}; };
item_trait(fold_ty_params(tps, fld), item_trait(fold_ty_params(/* FIXME (#2543) */ copy *tps, fld),
traits.map(|p| fold_trait_ref(*p, fld)), traits.map(|p| fold_trait_ref(*p, fld)),
methods) methods)
} }
@ -466,14 +468,14 @@ pub fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
expr_match(fld.fold_expr(expr), expr_match(fld.fold_expr(expr),
vec::map((*arms), |x| fld.fold_arm(*x))) vec::map((*arms), |x| fld.fold_arm(*x)))
} }
expr_fn(proto, decl, ref body, _) => { expr_fn(proto, ref decl, ref body, _) => {
expr_fn(proto, expr_fn(proto,
fold_fn_decl(decl, fld), fold_fn_decl(/* FIXME (#2543) */ copy *decl, fld),
fld.fold_block(*body), fld.fold_block(*body),
@()) @())
} }
expr_fn_block(decl, ref body) => { expr_fn_block(ref decl, ref body) => {
expr_fn_block(fold_fn_decl(decl, fld), expr_fn_block(fold_fn_decl(/* FIXME (#2543) */ copy *decl, fld),
fld.fold_block(*body)) fld.fold_block(*body))
} }
expr_block(ref blk) => expr_block(fld.fold_block((*blk))), expr_block(ref blk) => expr_block(fld.fold_block((*blk))),

View file

@ -495,9 +495,16 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
end(s); // end the outer cbox end(s); // end the outer cbox
} }
ast::item_fn(decl, purity, typarams, ref body) => { ast::item_fn(ref decl, purity, ref typarams, ref body) => {
print_fn(s, decl, Some(purity), item.ident, typarams, None, print_fn(
item.vis); s,
/* FIXME (#2543) */ copy *decl,
Some(purity),
item.ident,
/* FIXME (#2543) */ copy *typarams,
None,
item.vis
);
word(s.s, ~" "); word(s.s, ~" ");
print_block_with_attrs(s, (*body), item.attrs); print_block_with_attrs(s, (*body), item.attrs);
} }
@ -539,9 +546,15 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
word(s.s, ~";"); word(s.s, ~";");
end(s); // end the outer ibox end(s); // end the outer ibox
} }
ast::item_enum(ref enum_definition, params) => { ast::item_enum(ref enum_definition, ref params) => {
print_enum_def(s, (*enum_definition), params, item.ident, print_enum_def(
item.span, item.vis); s,
*enum_definition,
/* FIXME (#2543) */ copy *params,
item.ident,
item.span,
item.vis
);
} }
ast::item_struct(struct_def, tps) => { ast::item_struct(struct_def, tps) => {
head(s, visibility_qualified(item.vis, ~"struct")); head(s, visibility_qualified(item.vis, ~"struct"));
@ -577,13 +590,13 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
bclose(s, item.span); bclose(s, item.span);
} }
} }
ast::item_trait(tps, traits, ref methods) => { ast::item_trait(ref tps, ref traits, ref methods) => {
head(s, visibility_qualified(item.vis, ~"trait")); head(s, visibility_qualified(item.vis, ~"trait"));
print_ident(s, item.ident); print_ident(s, item.ident);
print_type_params(s, tps); print_type_params(s, /* FIXME (#2543) */ copy *tps);
if vec::len(traits) != 0u { if traits.len() != 0u {
word(s.s, ~":"); word(s.s, ~":");
for vec::each(traits) |trait_| { for traits.each |trait_| {
nbsp(s); nbsp(s);
print_path(s, trait_.path, false); print_path(s, trait_.path, false);
} }
@ -619,7 +632,7 @@ pub fn print_enum_def(s: @ps, enum_definition: ast::enum_def,
ident == enum_definition.variants[0].node.name; ident == enum_definition.variants[0].node.name;
if newtype { if newtype {
match enum_definition.variants[0].node.kind { match enum_definition.variants[0].node.kind {
ast::tuple_variant_kind(args) if args.len() == 1 => {} ast::tuple_variant_kind(ref args) if args.len() == 1 => {}
_ => newtype = false _ => newtype = false
} }
} }
@ -1325,24 +1338,24 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
} }
bclose_(s, expr.span, match_indent_unit); bclose_(s, expr.span, match_indent_unit);
} }
ast::expr_fn(sigil, decl, ref body, _) => { ast::expr_fn(sigil, ref decl, ref body, _) => {
// containing cbox, will be closed by print-block at } // containing cbox, will be closed by print-block at }
cbox(s, indent_unit); cbox(s, indent_unit);
// head-box, will be closed by print-block at start // head-box, will be closed by print-block at start
ibox(s, 0u); ibox(s, 0u);
print_fn_header_info(s, None, None, ast::Many, print_fn_header_info(s, None, None, ast::Many,
Some(sigil), ast::inherited); Some(sigil), ast::inherited);
print_fn_args_and_ret(s, decl, None); print_fn_args_and_ret(s, /* FIXME (#2543) */ copy *decl, None);
space(s.s); space(s.s);
print_block(s, (*body)); print_block(s, (*body));
} }
ast::expr_fn_block(decl, ref body) => { ast::expr_fn_block(ref decl, ref body) => {
// in do/for blocks we don't want to show an empty // in do/for blocks we don't want to show an empty
// argument list, but at this point we don't know which // argument list, but at this point we don't know which
// we are inside. // we are inside.
// //
// if !decl.inputs.is_empty() { // if !decl.inputs.is_empty() {
print_fn_block_args(s, decl); print_fn_block_args(s, /* FIXME (#2543) */ copy *decl);
space(s.s); space(s.s);
// } // }
assert (*body).node.stmts.is_empty(); assert (*body).node.stmts.is_empty();
@ -1809,10 +1822,15 @@ pub fn print_meta_item(s: @ps, &&item: @ast::meta_item) {
word_space(s, ~"="); word_space(s, ~"=");
print_literal(s, @value); print_literal(s, @value);
} }
ast::meta_list(ref name, items) => { ast::meta_list(ref name, ref items) => {
word(s.s, (*name)); word(s.s, (*name));
popen(s); popen(s);
commasep(s, consistent, items, print_meta_item); commasep(
s,
consistent,
/* FIXME (#2543) */ copy *items,
print_meta_item
);
pclose(s); pclose(s);
} }
} }

View file

@ -137,11 +137,20 @@ pub fn visit_item<E>(i: @item, e: E, v: vt<E>) {
(v.visit_ty)(t, e, v); (v.visit_ty)(t, e, v);
(v.visit_expr)(ex, e, v); (v.visit_expr)(ex, e, v);
} }
item_fn(decl, purity, tp, ref body) => { item_fn(ref decl, purity, ref tp, ref body) => {
(v.visit_fn)(fk_item_fn(/* FIXME (#2543) */ copy i.ident, (v.visit_fn)(
/* FIXME (#2543) */ copy tp, fk_item_fn(
purity), decl, (*body), /* FIXME (#2543) */ copy i.ident,
i.span, i.id, e, v); /* FIXME (#2543) */ copy *tp,
purity
),
/* FIXME (#2543) */ copy *decl,
(*body),
i.span,
i.id,
e,
v
);
} }
item_mod(m) => (v.visit_mod)(m, i.span, i.id, e, v), item_mod(m) => (v.visit_mod)(m, i.span, i.id, e, v),
item_foreign_mod(nm) => { item_foreign_mod(nm) => {
@ -152,9 +161,14 @@ pub fn visit_item<E>(i: @item, e: E, v: vt<E>) {
(v.visit_ty)(t, e, v); (v.visit_ty)(t, e, v);
(v.visit_ty_params)(tps, e, v); (v.visit_ty_params)(tps, e, v);
} }
item_enum(ref enum_definition, tps) => { item_enum(ref enum_definition, ref tps) => {
(v.visit_ty_params)(tps, e, v); (v.visit_ty_params)(/* FIXME (#2543) */ copy *tps, e, v);
visit_enum_def((*enum_definition), tps, e, v); visit_enum_def(
*enum_definition,
/* FIXME (#2543) */ copy *tps,
e,
v
);
} }
item_impl(tps, traits, ty, methods) => { item_impl(tps, traits, ty, methods) => {
(v.visit_ty_params)(tps, e, v); (v.visit_ty_params)(tps, e, v);
@ -170,8 +184,8 @@ pub fn visit_item<E>(i: @item, e: E, v: vt<E>) {
(v.visit_ty_params)(tps, e, v); (v.visit_ty_params)(tps, e, v);
(v.visit_struct_def)(struct_def, i.ident, tps, i.id, e, v); (v.visit_struct_def)(struct_def, i.ident, tps, i.id, e, v);
} }
item_trait(tps, traits, ref methods) => { item_trait(ref tps, ref traits, ref methods) => {
(v.visit_ty_params)(tps, e, v); (v.visit_ty_params)(/* FIXME (#2543) */ copy *tps, e, v);
for traits.each |p| { visit_path(p.path, e, v); } for traits.each |p| { visit_path(p.path, e, v); }
for (*methods).each |m| { for (*methods).each |m| {
(v.visit_trait_method)(*m, e, v); (v.visit_trait_method)(*m, e, v);
@ -460,13 +474,27 @@ pub fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
(v.visit_expr)(x, e, v); (v.visit_expr)(x, e, v);
for (*arms).each |a| { (v.visit_arm)(*a, e, v); } for (*arms).each |a| { (v.visit_arm)(*a, e, v); }
} }
expr_fn(proto, decl, ref body, _) => { expr_fn(proto, ref decl, ref body, _) => {
(v.visit_fn)(fk_anon(proto), decl, (*body), (v.visit_fn)(
ex.span, ex.id, e, v); fk_anon(proto),
/* FIXME (#2543) */ copy *decl,
*body,
ex.span,
ex.id,
e,
v
);
} }
expr_fn_block(decl, ref body) => { expr_fn_block(ref decl, ref body) => {
(v.visit_fn)(fk_fn_block, decl, (*body), (v.visit_fn)(
ex.span, ex.id, e, v); fk_fn_block,
/* FIXME (#2543) */ copy *decl,
*body,
ex.span,
ex.id,
e,
v
);
} }
expr_block(ref b) => (v.visit_block)((*b), e, v), expr_block(ref b) => (v.visit_block)((*b), e, v),
expr_assign(a, b) => { expr_assign(a, b) => {