diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index b0cb1d22cf7..b2e6446d7ee 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -123,7 +123,7 @@ fn map_decoded_item(diag: span_handler, fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: codemap::span, id: node_id, cx: ctx, v: vt) { for decl.inputs.each {|a| - cx.map.insert(a.id, node_arg(a, cx.local_id)); + cx.map.insert(a.id, node_arg(/* FIXME: bad */ copy a, cx.local_id)); cx.local_id += 1u; } alt fk { @@ -133,13 +133,17 @@ fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, dec: /* FIXME: bad */ copy decl, body: /* FIXME: bad */ copy body}, span: sp}; - cx.map.insert(id, node_ctor(/* FIXME: bad */ copy nm, tps, - class_ctor(ct, parent_id), @cx.path)); + cx.map.insert(id, node_ctor(/* FIXME: bad */ copy nm, + /* FIXME: bad */ copy tps, + class_ctor(ct, parent_id), + @/* FIXME: bad */ copy cx.path)); } visit::fk_dtor(tps, self_id, parent_id) { - let dt = @{node: {id: id, self_id: self_id, body: body}, - span: sp}; - cx.map.insert(id, node_dtor(tps, dt, parent_id, @cx.path)); + let dt = @{node: {id: id, self_id: self_id, + body: /* FIXME: bad */ copy body}, span: sp}; + cx.map.insert(id, node_dtor(/* FIXME: bad */ copy tps, dt, + parent_id, + @/* FIXME: bad */ copy cx.path)); } _ {} @@ -148,7 +152,7 @@ fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, } fn map_block(b: blk, cx: ctx, v: vt) { - cx.map.insert(b.node.id, node_block(b)); + cx.map.insert(b.node.id, node_block(/* FIXME: bad */ copy b)); visit::visit_block(b, cx, v); } @@ -182,25 +186,29 @@ fn map_method(impl_did: def_id, impl_path: @path, } fn map_item(i: @item, cx: ctx, v: vt) { - let item_path = @cx.path; + let item_path = @/* FIXME: bad */ copy cx.path; cx.map.insert(i.id, node_item(i, item_path)); alt i.node { item_impl(_, _, _, _, ms) { let impl_did = ast_util::local_def(i.id); for ms.each {|m| - map_method(impl_did, extend(cx, i.ident), m, cx); + map_method(impl_did, extend(cx, /* FIXME: bad */ copy i.ident), m, + cx); } } item_res(decl, tps, _, dtor_id, ctor_id, _) { - cx.map.insert(ctor_id, node_ctor(i.ident, tps, - res_ctor(decl, ctor_id, i.span), + cx.map.insert(ctor_id, node_ctor(/* FIXME: bad */ copy i.ident, + /* FIXME: bad */ copy tps, + res_ctor(/* FIXME: bad */ copy decl, + ctor_id, i.span), item_path)); cx.map.insert(dtor_id, node_item(i, item_path)); } item_enum(vs, _, _) { for vs.each {|v| cx.map.insert(v.node.id, node_variant( - v, i, extend(cx, i.ident))); + /* FIXME: bad */ copy v, i, + extend(cx, /* FIXME: bad */ copy i.ident))); } } item_native_mod(nm) { @@ -209,7 +217,9 @@ fn map_item(i: @item, cx: ctx, v: vt) { either::right(abi) { abi } }; for nm.items.each {|nitem| - cx.map.insert(nitem.id, node_native_item(nitem, abi, @cx.path)); + cx.map.insert(nitem.id, + node_native_item(nitem, abi, + @/* FIXME: bad */ copy cx.path)); } } item_class(tps, ifces, items, ctor, dtor, _) { @@ -219,7 +229,7 @@ fn map_item(i: @item, cx: ctx, v: vt) { vec::iter(ifces) {|p| cx.map.insert(p.id, node_item(i, item_path)); }; let d_id = ast_util::local_def(i.id); - let p = extend(cx, i.ident); + let p = extend(cx, /* FIXME: bad */ copy i.ident); // only need to handle methods vec::iter(ms) {|m| map_method(d_id, p, m, cx); } } @@ -227,9 +237,9 @@ fn map_item(i: @item, cx: ctx, v: vt) { } alt i.node { item_mod(_) | item_native_mod(_) { - cx.path += [path_mod(i.ident)]; + cx.path += [path_mod(/* FIXME: bad */ copy i.ident)]; } - _ { cx.path += [path_name(i.ident)]; } + _ { cx.path += [path_name(/* FIXME: bad */ copy i.ident)]; } } visit::visit_item(i, cx, v); vec::pop(cx.path); @@ -240,7 +250,7 @@ fn map_view_item(vi: @view_item, cx: ctx, _v: vt) { view_item_export(vps) { for vps.each {|vp| let (id, name) = alt vp.node { - view_path_simple(nm, _, id) { (id, nm) } + view_path_simple(nm, _, id) { (id, /* FIXME: bad */ copy nm) } view_path_glob(pth, id) | view_path_list(pth, _, id) { (id, path_to_ident(pth)) } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 204973ade02..af780bc5e38 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -51,7 +51,8 @@ fn mk_name_value_item_str(+name: ast::ident, +value: str) -> @ast::meta_item { ret mk_name_value_item(name, value_lit); } -fn mk_name_value_item(+name: ast::ident, +value: ast::lit) -> @ast::meta_item { +fn mk_name_value_item(+name: ast::ident, +value: ast::lit) + -> @ast::meta_item { ret @dummy_spanned(ast::meta_name_value(name, value)); } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index ecdb8d328fb..04a3c95ce1c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -88,10 +88,11 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item { meta_word(id) { meta_word(fld.fold_ident(id)) } meta_list(id, mis) { let fold_meta_item = bind fold_meta_item_(_, fld); - meta_list(id, vec::map(mis, fold_meta_item)) + meta_list(/* FIXME: bad */ copy id, + vec::map(mis, fold_meta_item)) } meta_name_value(id, s) { - meta_name_value(fld.fold_ident(id), s) + meta_name_value(fld.fold_ident(id), /* FIXME: bad */ copy s) } }, span: fld.new_span(mi.span)}; @@ -121,8 +122,8 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac { mac_embed_type(ty) { mac_embed_type(fld.fold_ty(ty)) } mac_embed_block(blk) { mac_embed_block(fld.fold_block(blk)) } mac_ellipsis { mac_ellipsis } - mac_aq(_,_) { /* fixme */ m.node } - mac_var(_) { /* fixme */ m.node } + mac_aq(_,_) { /* FIXME: bad */ copy m.node } + mac_var(_) { /* FIXME: bad */ copy m.node } }, span: fld.new_span(m.span)}; } @@ -143,7 +144,7 @@ fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound { } fn fold_ty_param(tp: ty_param, fld: ast_fold) -> ty_param { - {ident: tp.ident, + {ident: /* FIXME: bad */ copy tp.ident, id: fld.new_id(tp.id), bounds: @vec::map(*tp.bounds, fold_ty_param_bound(_, fld))} } @@ -166,19 +167,20 @@ fn noop_fold_crate_directive(cd: crate_directive_, fld: ast_fold) -> crate_directive_ { ret alt cd { cdir_src_mod(id, attrs) { - cdir_src_mod(fld.fold_ident(id), attrs) + cdir_src_mod(fld.fold_ident(id), /* FIXME: bad */ copy attrs) } cdir_dir_mod(id, cds, attrs) { cdir_dir_mod(fld.fold_ident(id), - vec::map(cds, fld.fold_crate_directive), attrs) + vec::map(cds, fld.fold_crate_directive), + /* FIXME: bad */ copy attrs) } cdir_view_item(vi) { cdir_view_item(fld.fold_view_item(vi)) } - cdir_syntax(_) { cd } + cdir_syntax(_) { copy cd } } } fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ { - ret vi; + ret /* FIXME: bad */ copy vi; } @@ -220,7 +222,8 @@ fn noop_fold_class_item(&&ci: @class_member, fld: ast_fold) -> @class_member { @{node: alt ci.node { instance_var(ident, t, cm, id, p) { - instance_var(ident, fld.fold_ty(t), cm, id, p) + instance_var(/* FIXME: bad */ copy ident, fld.fold_ty(t), cm, id, + p) } class_method(m) { class_method(fld.fold_method(m)) } }, @@ -256,7 +259,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { id: dtor_id with dtor.node} with dtor}}; item_class( - typms, + /* FIXME: bad */ copy typms, vec::map(ifaces, {|p| fold_iface_ref(p, fld) }), vec::map(items, fld.fold_class_item), {node: {body: ctor_body, @@ -274,7 +277,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { item_iface(tps, rp, methods) { item_iface(fold_ty_params(tps, fld), rp, - methods) + /* FIXME: bad */ copy methods) } item_res(decl, typms, body, did, cid, rp) { item_res(fold_fn_decl(decl, fld), @@ -293,7 +296,7 @@ fn fold_iface_ref(&&p: @iface_ref, fld: ast_fold) -> @iface_ref { fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method { ret @{ident: fld.fold_ident(m.ident), - attrs: m.attrs, + attrs: /* FIXME: bad */ copy m.attrs, tps: fold_ty_params(m.tps, fld), decl: fold_fn_decl(m.decl, fld), body: fld.fold_block(m.body), @@ -328,7 +331,7 @@ fn noop_fold_arm(a: arm, fld: ast_fold) -> arm { fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { ret alt p { - pat_wild { p } + pat_wild { pat_wild } pat_ident(pth, sub) { pat_ident(fld.fold_path(pth), option::map(sub, fld.fold_pat)) } @@ -340,7 +343,8 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { pat_rec(fields, etc) { let mut fs = []; for fields.each {|f| - fs += [{ident: f.ident, pat: fld.fold_pat(f.pat)}]; + fs += [{ident: /* FIXME: bad */ copy f.ident, + pat: fld.fold_pat(f.pat)}]; } pat_rec(fs, etc) } @@ -410,7 +414,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { } expr_unary(binop, ohs) { expr_unary(binop, fld.fold_expr(ohs)) } expr_loop_body(f) { expr_loop_body(fld.fold_expr(f)) } - expr_lit(_) { e } + expr_lit(_) { copy e } expr_cast(expr, ty) { expr_cast(fld.fold_expr(expr), ty) } expr_addr_of(m, ohs) { expr_addr_of(m, fld.fold_expr(ohs)) } expr_if(cond, tr, fl) { @@ -462,7 +466,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { } expr_path(pth) { expr_path(fld.fold_path(pth)) } expr_fail(e) { expr_fail(option::map(e, fld.fold_expr)) } - expr_break | expr_cont { e } + expr_break | expr_cont { copy e } expr_ret(e) { expr_ret(option::map(e, fld.fold_expr)) } expr_log(i, lv, e) { expr_log(i, fld.fold_expr(lv), fld.fold_expr(e)) } @@ -487,7 +491,7 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { span: fld.new_span(f.span)} } alt t { - ty_nil | ty_bot {t} + ty_nil | ty_bot | ty_infer {copy t} ty_box(mt) {ty_box(fold_mt(mt, fld))} ty_uniq(mt) {ty_uniq(fold_mt(mt, fld))} ty_vec(mt) {ty_vec(fold_mt(mt, fld))} @@ -501,17 +505,18 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { vec::map(constrs, fld.fold_ty_constr))} ty_vstore(t, vs) {ty_vstore(fld.fold_ty(t), vs)} ty_mac(mac) {ty_mac(fold_mac(mac))} - ty_infer {t} } } fn noop_fold_constr(c: constr_, fld: ast_fold) -> constr_ { - {path: fld.fold_path(c.path), args: c.args, id: fld.new_id(c.id)} + {path: fld.fold_path(c.path), args: /* FIXME: bad */ copy c.args, + id: fld.new_id(c.id)} } fn noop_fold_ty_constr(c: ty_constr_, fld: ast_fold) -> ty_constr_ { let rslt: ty_constr_ = - {path: fld.fold_path(c.path), args: c.args, id: fld.new_id(c.id)}; + {path: fld.fold_path(c.path), args: /* FIXME: bad */ copy c.args, + id: fld.new_id(c.id)}; rslt } // ...nor do modules @@ -539,14 +544,16 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { some(e) {some(fld.fold_expr(e))} none {none} }; - ret {name: v.name, + ret {name: /* FIXME: bad */ copy v.name, attrs: attrs, args: args, id: fld.new_id(v.id), disr_expr: de, vis: v.vis}; } -fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident { ret i; } +fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident { + ret /* FIXME: bad */ copy i; +} fn noop_fold_path(&&p: path, fld: ast_fold) -> path { ret {span: fld.new_span(p.span), global: p.global, @@ -639,8 +646,8 @@ impl of ast_fold for ast_fold_precursor { fn fold_class_item(&&ci: @class_member) -> @class_member { @{node: alt ci.node { instance_var(nm, t, mt, id, p) { - instance_var(nm, (self as ast_fold).fold_ty(t), - mt, id, p) + instance_var(/* FIXME: bad */ copy nm, + (self as ast_fold).fold_ty(t), mt, id, p) } class_method(m) { class_method(self.fold_method(m, self as ast_fold)) diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 35afb79ce63..c0a2f9b9e6e 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -209,6 +209,9 @@ impl parser_common for parser { ret v; } + // FIXME: A lot of callers go through here, only to copy out the T and + // discard the spanned<> wrapper. I feel as though there should be a + // version of this that does not return a spanned result. fn parse_seq(bra: token::token, ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> spanned<[T]> { let lo = self.span.lo; @@ -218,4 +221,4 @@ impl parser_common for parser { self.bump(); ret spanned(lo, hi, result); } -} \ No newline at end of file +} diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index 98d75499878..254d5cc5d5d 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -44,7 +44,7 @@ optional suffix then adding the .rs extension. fn parse_companion_mod(cx: ctx, prefix: str, suffix: option) -> ([@ast::view_item], [@ast::item], [ast::attribute]) { - fn companion_file(prefix: str, suffix: option) -> str { + fn companion_file(+prefix: str, suffix: option) -> str { ret alt suffix { option::some(s) { path::connect(prefix, s) } option::none { prefix } @@ -66,8 +66,7 @@ fn parse_companion_mod(cx: ctx, prefix: str, suffix: option) #debug("found companion mod"); let p0 = new_parser_from_file(cx.sess, cx.cfg, modpath, SOURCE_FILE); let inner_attrs = p0.parse_inner_attrs_and_next(); - let first_item_outer_attrs = inner_attrs.next; - let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs); + let m0 = p0.parse_mod_items(token::EOF, inner_attrs.next); cx.sess.chpos = p0.reader.chpos; cx.sess.byte_pos = cx.sess.byte_pos + p0.reader.pos; ret (m0.view_items, m0.items, inner_attrs.inner); @@ -102,7 +101,8 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str, let first_item_outer_attrs = inner_attrs.next; let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs); - let i = p0.mk_item(cdir.span.lo, cdir.span.hi, id, + let i = p0.mk_item(cdir.span.lo, cdir.span.hi, + /* FIXME: bad */ copy id, ast::item_mod(m0), ast::public, mod_attrs); // Thread defids, chpos and byte_pos through the parsers cx.sess.chpos = p0.reader.chpos; @@ -118,7 +118,7 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str, let (m0, a0) = eval_crate_directives_to_mod( cx, cdirs, full_path, none); let i = - @{ident: id, + @{ident: /* FIXME: bad */ copy id, attrs: attrs + a0, id: cx.sess.next_id, node: ast::item_mod(m0), diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index c5be778572b..fa0286ded81 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -28,7 +28,7 @@ enum fn_kind { fn name_of_fn(fk: fn_kind) -> ident { alt fk { fk_item_fn(name, _) | fk_method(name, _, _) | fk_res(name, _, _) - | fk_ctor(name, _, _, _) { name } + | fk_ctor(name, _, _, _) { /* FIXME: bad */ copy name } fk_anon(*) | fk_fn_block(*) { "anon" } fk_dtor(*) { "drop" } } @@ -37,7 +37,9 @@ fn name_of_fn(fk: fn_kind) -> ident { fn tps_of_fn(fk: fn_kind) -> [ty_param] { alt fk { fk_item_fn(_, tps) | fk_method(_, tps, _) | fk_res(_, tps, _) - | fk_ctor(_, tps, _, _) | fk_dtor(tps, _, _) { tps } + | fk_ctor(_, tps, _, _) | fk_dtor(tps, _, _) { + /* FIXME: bad */ copy tps + } fk_anon(*) | fk_fn_block(*) { [] } } } @@ -115,7 +117,9 @@ fn visit_item(i: @item, e: E, v: vt) { alt i.node { item_const(t, ex) { v.visit_ty(t, e, v); v.visit_expr(ex, e, v); } item_fn(decl, tp, body) { - v.visit_fn(fk_item_fn(i.ident, tp), decl, body, i.span, i.id, e, v); + v.visit_fn(fk_item_fn(/* FIXME: bad */ copy i.ident, + /* FIXME: bad */ copy tp), decl, body, + i.span, i.id, e, v); } item_mod(m) { v.visit_mod(m, i.span, i.id, e, v); } item_native_mod(nm) { @@ -127,8 +131,10 @@ fn visit_item(i: @item, e: E, v: vt) { v.visit_ty_params(tps, e, v); } item_res(decl, tps, body, dtor_id, _, rp) { - v.visit_fn(fk_res(i.ident, tps, rp), decl, body, i.span, - dtor_id, e, v); + v.visit_fn(fk_res(/* FIXME: bad */ copy i.ident, + /* FIXME: bad */ copy tps, + rp), + decl, body, i.span, dtor_id, e, v); } item_enum(variants, tps, _) { v.visit_ty_params(tps, e, v); @@ -281,22 +287,23 @@ fn visit_fn_decl(fd: fn_decl, e: E, v: vt) { // because it is not a default impl of any method, though I doubt that really // clarifies anything. - Niko fn visit_method_helper(m: @method, e: E, v: vt) { - v.visit_fn(fk_method(m.ident, m.tps, m), m.decl, m.body, m.span, - m.id, e, v); + v.visit_fn(fk_method(/* FIXME: bad */ copy m.ident, + /* FIXME: bad */ copy m.tps, m), + m.decl, m.body, m.span, m.id, e, v); } // Similar logic to the comment on visit_method_helper - Tim fn visit_class_ctor_helper(ctor: class_ctor, nm: ident, tps: [ty_param], parent_id: def_id, e: E, v: vt) { - v.visit_fn(fk_ctor(nm, tps, ctor.node.self_id, - parent_id), ctor.node.dec, + v.visit_fn(fk_ctor(/* FIXME: bad */ copy nm, /* FIXME: bad */ copy tps, + ctor.node.self_id, parent_id), ctor.node.dec, ctor.node.body, ctor.span, ctor.node.id, e, v) } fn visit_class_dtor_helper(dtor: class_dtor, tps: [ty_param], parent_id: def_id, e: E, v: vt) { - v.visit_fn(fk_dtor(tps, dtor.node.self_id, + v.visit_fn(fk_dtor(/* FIXME: bad */ copy tps, dtor.node.self_id, parent_id), ast_util::dtor_dec(), dtor.node.body, dtor.span, dtor.node.id, e, v)