diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 84836568029..55a832b15cc 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -190,8 +190,7 @@ pub mod write { let opts = sess.opts; if sess.time_llvm_passes() { llvm::LLVMRustEnableTimePasses(); } let mut pm = mk_pass_manager(); - let td = mk_target_data( - /*bad*/copy sess.targ_cfg.target_strs.data_layout); + let td = mk_target_data(sess.targ_cfg.target_strs.data_layout); llvm::LLVMAddTargetData(td.lltd, pm.llpm); // FIXME (#2812): run the linter here also, once there are llvm-c // bindings for it. @@ -834,8 +833,9 @@ pub fn link_binary(sess: Session, // to be found at compile time so it is still entirely up to outside // forces to make sure that library can be found at runtime. - let addl_paths = /*bad*/copy sess.opts.addl_lib_search_paths; - for addl_paths.each |path| { cc_args.push(~"-L" + path.to_str()); } + for sess.opts.addl_lib_search_paths.each |path| { + cc_args.push(~"-L" + path.to_str()); + } // The names of the extern libraries let used_libs = cstore::get_used_libraries(cstore); diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 2d98a84aee9..1911764da3c 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -45,8 +45,8 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) // where rustrt is and we know every rust program needs it let libs = vec::append_one(libs, get_sysroot_absolute_rt_lib(sess)); - let target_triple = /*bad*/copy sess.opts.target_triple; - let rpaths = get_rpaths(os, &sysroot, output, libs, target_triple); + let rpaths = get_rpaths(os, &sysroot, output, libs, + sess.opts.target_triple); rpaths_to_flags(rpaths) } @@ -140,8 +140,8 @@ pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path { let abs2 = abs2.normalize(); debug!("finding relative path from %s to %s", abs1.to_str(), abs2.to_str()); - let split1 = /*bad*/copy abs1.components; - let split2 = /*bad*/copy abs2.components; + let split1: &[~str] = abs1.components; + let split2: &[~str] = abs2.components; let len1 = vec::len(split1); let len2 = vec::len(split2); fail_unless!(len1 > 0); diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index dff8ec866d6..d14ff17d837 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -132,15 +132,12 @@ pub fn build_configuration(sess: Session, +argv0: ~str, input: input) -> } // Convert strings provided as --cfg [cfgspec] into a crate_cfg -fn parse_cfgspecs(cfgspecs: ~[~str], +fn parse_cfgspecs(+cfgspecs: ~[~str], demitter: diagnostic::Emitter) -> ast::crate_cfg { - let mut meta = ~[]; - for cfgspecs.each |s| { + do vec::map_consume(cfgspecs) |s| { let sess = parse::new_parse_sess(Some(demitter)); - let m = parse::parse_meta_from_source_str(~"cfgspec", @/*bad*/ copy *s, ~[], sess); - meta.push(m) + parse::parse_meta_from_source_str(~"cfgspec", @s, ~[], sess) } - return meta; } pub enum input { @@ -566,9 +563,9 @@ pub fn build_session_options(+binary: ~str, let debug_map = session::debugging_opts_map(); for debug_flags.each |debug_flag| { let mut this_bit = 0u; - for debug_map.each |pair| { - let (name, _, bit) = /*bad*/copy *pair; - if name == *debug_flag { this_bit = bit; break; } + for debug_map.each |tuple| { + let (name, bit) = match *tuple { (ref a, _, b) => (a, b) }; + if name == debug_flag { this_bit = bit; break; } } if this_bit == 0u { early_error(demitter, fmt!("unknown debug flag: %s", *debug_flag)) @@ -633,7 +630,7 @@ pub fn build_session_options(+binary: ~str, let target = match target_opt { None => host_triple(), - Some(ref s) => (/*bad*/copy *s) + Some(s) => s }; let addl_lib_search_paths = diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 23eb6743b9f..e5234dff91d 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -1647,7 +1647,7 @@ pub struct TargetData { dtor: @target_data_res } -pub fn mk_target_data(string_rep: ~str) -> TargetData { +pub fn mk_target_data(string_rep: &str) -> TargetData { let lltd = str::as_c_str(string_rep, |buf| unsafe { llvm::LLVMCreateTargetData(buf) diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 92de7f3f5e6..21b035f2242 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -142,8 +142,8 @@ fn visit_crate(e: @mut Env, c: ast::crate) { } fn visit_view_item(e: @mut Env, i: @ast::view_item) { - match /*bad*/copy i.node { - ast::view_item_extern_mod(ident, meta_items, id) => { + match i.node { + ast::view_item_extern_mod(ident, /*bad*/copy meta_items, id) => { debug!("resolving extern mod stmt. ident: %?, meta: %?", ident, meta_items); let cnum = resolve_crate(e, ident, meta_items, @~"", i.span); @@ -154,8 +154,8 @@ fn visit_view_item(e: @mut Env, i: @ast::view_item) { } fn visit_item(e: @mut Env, i: @ast::item) { - match /*bad*/copy i.node { - ast::item_foreign_mod(fm) => { + match i.node { + ast::item_foreign_mod(ref fm) => { match attr::foreign_abi(i.attrs) { either::Right(abi) => { if abi != ast::foreign_abi_cdecl && diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index f507d0d8718..31b9dcea789 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -645,7 +645,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder, debug!("encoding info for item at %s", ecx.tcx.sess.codemap.span_to_str(item.span)); - match /*bad*/copy item.node { + match item.node { item_const(_, _) => { add_to_index(); ebml_w.start_tag(tag_items_data_item); @@ -1189,10 +1189,10 @@ fn synthesize_crate_attrs(ecx: @EncodeContext, if *attr::get_attr_name(attr) != ~"link" { /*bad*/copy *attr } else { - match /*bad*/copy attr.node.value.node { - meta_list(_, l) => { + match attr.node.value.node { + meta_list(_, ref l) => { found_link_attr = true;; - synthesize_link_attr(ecx, l) + synthesize_link_attr(ecx, /*bad*/copy *l) } _ => /*bad*/copy *attr } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 1dcaa76e9c7..853bb8df3a4 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -639,14 +639,14 @@ fn encode_vtable_origin(ecx: @e::EncodeContext, ebml_w: writer::Encoder, vtable_origin: typeck::vtable_origin) { do ebml_w.emit_enum(~"vtable_origin") { - match /*bad*/copy vtable_origin { - typeck::vtable_static(def_id, tys, vtable_res) => { + match vtable_origin { + typeck::vtable_static(def_id, ref tys, vtable_res) => { do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) { do ebml_w.emit_enum_variant_arg(0u) { ebml_w.emit_def_id(def_id) } do ebml_w.emit_enum_variant_arg(1u) { - ebml_w.emit_tys(ecx, /*bad*/copy tys); + ebml_w.emit_tys(ecx, /*bad*/copy *tys); } do ebml_w.emit_enum_variant_arg(2u) { encode_vtable_res(ecx, ebml_w, vtable_res); diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index e5f056619cc..83fe2db79ef 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -139,7 +139,7 @@ fn req_loans_in_expr(ex: @ast::expr, } // Special checks for various kinds of expressions: - match /*bad*/copy ex.node { + match ex.node { ast::expr_addr_of(mutbl, base) => { let base_cmt = self.bccx.cat_expr(base); @@ -150,10 +150,10 @@ fn req_loans_in_expr(ex: @ast::expr, visit::visit_expr(ex, self, vt); } - ast::expr_call(f, args, _) => { + ast::expr_call(f, ref args, _) => { let arg_tys = ty::ty_fn_args(ty::expr_ty(self.tcx(), f)); let scope_r = ty::re_scope(ex.id); - for vec::each2(args, arg_tys) |arg, arg_ty| { + for vec::each2(*args, arg_tys) |arg, arg_ty| { match ty::resolved_mode(self.tcx(), arg_ty.mode) { ast::by_ref => { let arg_cmt = self.bccx.cat_expr(*arg); @@ -165,11 +165,11 @@ fn req_loans_in_expr(ex: @ast::expr, visit::visit_expr(ex, self, vt); } - ast::expr_method_call(rcvr, _, _, args, _) => { + ast::expr_method_call(rcvr, _, _, ref args, _) => { let arg_tys = ty::ty_fn_args(ty::node_id_to_type(self.tcx(), ex.callee_id)); let scope_r = ty::re_scope(ex.id); - for vec::each2(args, arg_tys) |arg, arg_ty| { + for vec::each2(*args, arg_tys) |arg, arg_ty| { match ty::resolved_mode(self.tcx(), arg_ty.mode) { ast::by_ref => { let arg_cmt = self.bccx.cat_expr(*arg); diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index a7fb1506d18..245872c39c6 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -243,8 +243,8 @@ pub fn is_useful(cx: @MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful { } ty::ty_unboxed_vec(*) | ty::ty_evec(*) => { let max_len = do m.foldr(0) |r, max_len| { - match /*bad*/copy r[0].node { - pat_vec(before, _, after) => { + match r[0].node { + pat_vec(ref before, _, ref after) => { uint::max(before.len() + after.len(), max_len) } _ => max_len @@ -299,7 +299,7 @@ pub fn is_useful_specialized(cx: @MatchCheckCtxt, pub fn pat_ctor_id(cx: @MatchCheckCtxt, p: @pat) -> Option { let pat = raw_pat(p); - match /*bad*/copy pat.node { + match pat.node { pat_wild => { None } pat_ident(_, _, _) | pat_enum(_, _) => { match cx.tcx.def_map.find(&pat.id) { @@ -324,7 +324,7 @@ pub fn pat_ctor_id(cx: @MatchCheckCtxt, p: @pat) -> Option { pat_box(_) | pat_uniq(_) | pat_tup(_) | pat_region(*) => { Some(single) } - pat_vec(before, slice, after) => { + pat_vec(ref before, slice, ref after) => { match slice { Some(_) => None, None => Some(vec(before.len() + after.len())) @@ -448,8 +448,8 @@ pub fn missing_ctor(cx: @MatchCheckCtxt, } pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint { - match /*bad*/copy ty::get(ty).sty { - ty::ty_tup(fs) => fs.len(), + match ty::get(ty).sty { + ty::ty_tup(ref fs) => fs.len(), ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u, ty::ty_enum(eid, _) => { let id = match ctor { variant(id) => id, @@ -704,7 +704,7 @@ pub fn is_refutable(cx: @MatchCheckCtxt, pat: &pat) -> bool { _ => () } - match /*bad*/copy pat.node { + match pat.node { pat_box(sub) | pat_uniq(sub) | pat_region(sub) | pat_ident(_, _, Some(sub)) => { is_refutable(cx, sub) @@ -715,13 +715,13 @@ pub fn is_refutable(cx: @MatchCheckCtxt, pat: &pat) -> bool { false } pat_lit(_) | pat_range(_, _) => { true } - pat_struct(_, fields, _) => { + pat_struct(_, ref fields, _) => { fields.any(|f| is_refutable(cx, f.pat)) } - pat_tup(elts) => { + pat_tup(ref elts) => { elts.any(|elt| is_refutable(cx, *elt)) } - pat_enum(_, Some(args)) => { + pat_enum(_, Some(ref args)) => { args.any(|a| is_refutable(cx, *a)) } pat_enum(_,_) => { false } diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 441e01bbc34..4888a01c6b9 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -81,7 +81,7 @@ pub fn classify(e: @expr, Some(x) => x, None => { let cn = - match /*bad*/copy e.node { + match e.node { ast::expr_lit(lit) => { match lit.node { ast::lit_str(*) | @@ -101,9 +101,9 @@ pub fn classify(e: @expr, classify(b, def_map, tcx)) } - ast::expr_tup(es) | - ast::expr_vec(es, ast::m_imm) => { - join_all(vec::map(es, |e| classify(*e, def_map, tcx))) + ast::expr_tup(ref es) | + ast::expr_vec(ref es, ast::m_imm) => { + join_all(vec::map(*es, |e| classify(*e, def_map, tcx))) } ast::expr_vstore(e, vstore) => { diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index d6f0da6d7a3..e4ea2333d27 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -56,7 +56,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk) Some(df) => { let mut def = df; while i < depth { - match copy def { + match def { ast::def_upvar(_, inner, _, _) => { def = *inner; } _ => break } diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index ccd7e35f817..a8fe25b61c7 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -360,8 +360,8 @@ pub impl Context { let metas = attr::attr_metas(attr::find_attrs_by_name(attrs, level_name)); for metas.each |meta| { - match /*bad*/copy meta.node { - ast::meta_list(_, metas) => { + match meta.node { + ast::meta_list(_, ref metas) => { for metas.each |meta| { match meta.node { ast::meta_word(ref lintname) => { @@ -653,8 +653,8 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) { } fn check_item_default_methods(cx: ty::ctxt, item: @ast::item) { - match /*bad*/copy item.node { - ast::item_trait(_, _, methods) => { + match item.node { + ast::item_trait(_, _, ref methods) => { for methods.each |method| { match *method { ast::required(*) => {} diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index c2417f75a82..7f14b215858 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -383,7 +383,7 @@ pub impl IrMaps { } fn variable_name(&mut self, var: Variable) -> @~str { - match copy self.var_kinds[*var] { + match self.var_kinds[*var] { Local(LocalInfo {ident: nm, _}) | Arg(_, nm, _) => self.tcx.sess.str_of(nm), ImplicitRet => @~"" @@ -1065,8 +1065,8 @@ pub impl Liveness { fn propagate_through_decl(&self, decl: @decl, succ: LiveNode) -> LiveNode { - match /*bad*/copy decl.node { - decl_local(locals) => { + match decl.node { + decl_local(ref locals) => { do locals.foldr(succ) |local, succ| { self.propagate_through_local(*local, succ) } @@ -1097,7 +1097,7 @@ pub impl Liveness { self.define_bindings_in_pat(local.node.pat, succ) } - fn propagate_through_exprs(&self, exprs: ~[@expr], + fn propagate_through_exprs(&self, exprs: &[@expr], succ: LiveNode) -> LiveNode { do exprs.foldr(succ) |expr, succ| { self.propagate_through_expr(*expr, succ) @@ -1116,7 +1116,7 @@ pub impl Liveness { debug!("propagate_through_expr: %s", expr_to_str(expr, self.tcx.sess.intr())); - match /*bad*/copy expr.node { + match expr.node { // Interesting cases with control flow or which gen/kill expr_path(_) => { @@ -1283,8 +1283,8 @@ pub impl Liveness { self.propagate_through_expr(expr, succ) } - expr_vec(exprs, _) => { - self.propagate_through_exprs(exprs, succ) + expr_vec(ref exprs, _) => { + self.propagate_through_exprs(*exprs, succ) } expr_repeat(element, count, _) => { @@ -1299,29 +1299,29 @@ pub impl Liveness { } } - expr_call(f, args, _) => { + expr_call(f, ref args, _) => { // calling a fn with bot return type means that the fn // will fail, and hence the successors can be ignored let t_ret = ty::ty_fn_ret(ty::expr_ty(self.tcx, f)); let succ = if ty::type_is_bot(t_ret) {self.s.exit_ln} else {succ}; - let succ = self.propagate_through_exprs(args, succ); + let succ = self.propagate_through_exprs(*args, succ); self.propagate_through_expr(f, succ) } - expr_method_call(rcvr, _, _, args, _) => { + expr_method_call(rcvr, _, _, ref args, _) => { // calling a method with bot return type means that the method // will fail, and hence the successors can be ignored let t_ret = ty::ty_fn_ret(ty::node_id_to_type(self.tcx, expr.callee_id)); let succ = if ty::type_is_bot(t_ret) {self.s.exit_ln} else {succ}; - let succ = self.propagate_through_exprs(args, succ); + let succ = self.propagate_through_exprs(*args, succ); self.propagate_through_expr(rcvr, succ) } - expr_tup(exprs) => { - self.propagate_through_exprs(exprs, succ) + expr_tup(ref exprs) => { + self.propagate_through_exprs(*exprs, succ) } expr_binary(op, l, r) if ast_util::lazy_binop(op) => { @@ -1350,7 +1350,7 @@ pub impl Liveness { self.propagate_through_expr(e, succ) } - expr_inline_asm(_, ins, outs, _, _, _) =>{ + expr_inline_asm(_, ref ins, ref outs, _, _, _) =>{ let succ = do ins.foldr(succ) |&(_, expr), succ| { self.propagate_through_expr(expr, succ) }; @@ -1579,7 +1579,7 @@ fn check_arm(arm: &arm, &&self: @Liveness, vt: vt<@Liveness>) { } fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) { - match /*bad*/copy expr.node { + match expr.node { expr_path(_) => { for self.variable_from_def_map(expr.id, expr.span).each |var| { let ln = self.live_node(expr.id, expr.span); @@ -1624,7 +1624,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) { visit::visit_expr(expr, self, vt); } - expr_inline_asm(_, ins, outs, _, _, _) => { + expr_inline_asm(_, ref ins, ref outs, _, _, _) => { for ins.each |&(_, in)| { (vt.visit_expr)(in, self, vt); } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index c25266b4531..fee3695002d 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -1106,7 +1106,7 @@ pub fn field_mutbl(tcx: ty::ctxt, node_id: ast::node_id) -> Option { // Need to refactor so that struct/enum fields can be treated uniformly. - match /*bad*/copy ty::get(base_ty).sty { + match ty::get(base_ty).sty { ty::ty_struct(did, _) => { for ty::lookup_struct_fields(tcx, did).each |fld| { if fld.ident == f_name { diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 3e3b1eb2071..4ca8885c554 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -375,8 +375,8 @@ pub fn check_crate(tcx: ty::ctxt, visit::visit_expr(expr, method_map, visitor); }, visit_pat: |pattern, method_map, visitor| { - match /*bad*/copy pattern.node { - pat_struct(_, fields, _) => { + match pattern.node { + pat_struct(_, ref fields, _) => { match ty::get(ty::pat_ty(tcx, pattern)).sty { ty_struct(id, _) => { if id.crate != local_crate || diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 6561da0862a..6c2168548f1 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1080,7 +1080,7 @@ pub impl Resolver { let sp = item.span; let privacy = visibility_to_privacy(item.vis); - match /*bad*/copy item.node { + match item.node { item_mod(ref module_) => { let (name_bindings, new_parent) = self.add_child(ident, parent, ForbidDuplicateModules, sp); @@ -1099,7 +1099,7 @@ pub impl Resolver { visit_mod(module_, sp, item.id, new_parent, visitor); } - item_foreign_mod(fm) => { + item_foreign_mod(ref fm) => { let new_parent = match fm.sort { named => { let (name_bindings, new_parent) = @@ -1196,7 +1196,7 @@ pub impl Resolver { visit_item(item, new_parent, visitor); } - item_impl(_, trait_ref_opt, ty, methods) => { + item_impl(_, trait_ref_opt, ty, ref methods) => { // If this implements an anonymous trait and it has static // methods, then add all the static methods within to a new // module, if the type was defined within this module. @@ -1401,8 +1401,8 @@ pub impl Resolver { parent: ReducedGraphParent, &&_visitor: vt) { let privacy = visibility_to_privacy(view_item.vis); - match /*bad*/copy view_item.node { - view_item_use(view_paths) => { + match view_item.node { + view_item_use(ref view_paths) => { for view_paths.each |view_path| { // Extract and intern the module part of the path. For // globs and lists, the path is found directly in the AST; @@ -1571,7 +1571,7 @@ pub impl Resolver { new_parent: ReducedGraphParent) { match def { def_mod(def_id) | def_foreign_mod(def_id) => { - match copy child_name_bindings.type_def { + match child_name_bindings.type_def { Some(TypeNsDef { module_def: Some(copy module_def), _ }) => { debug!("(building reduced graph for external crate) \ already created module"); @@ -1790,7 +1790,7 @@ pub impl Resolver { // Process the static methods. First, // create the module. let type_module; - match copy child_name_bindings.type_def { + match child_name_bindings.type_def { Some(TypeNsDef { module_def: Some(copy module_def), _ @@ -2008,10 +2008,13 @@ pub impl Resolver { } fn idents_to_str(@mut self, idents: &[ident]) -> ~str { - let ident_strs = do idents.map |ident| { - /*bad*/ copy *self.session.str_of(*ident) + let mut first = true; + let mut result = ~""; + for idents.each |ident| { + if first { first = false; } else { result += "::" }; + result += *self.session.str_of(*ident); }; - str::connect(ident_strs, "::") + return result; } fn import_directive_subclass_to_str(@mut self, @@ -2511,22 +2514,22 @@ pub impl Resolver { // Merge the two import resolutions at a finer-grained // level. - match copy target_import_resolution.value_target { + match target_import_resolution.value_target { None => { // Continue. } - Some(value_target) => { + Some(copy value_target) => { dest_import_resolution.value_target = - Some(copy value_target); + Some(value_target); } } - match copy target_import_resolution.type_target { + match target_import_resolution.type_target { None => { // Continue. } - Some(type_target) => { + Some(copy type_target) => { dest_import_resolution.type_target = - Some(copy type_target); + Some(type_target); } } } @@ -3149,7 +3152,7 @@ pub impl Resolver { let mut exports2 = ~[]; self.add_exports_for_module(&mut exports2, module_); - match copy module_.def_id { + match /*bad*/copy module_.def_id { Some(def_id) => { self.export_map2.insert(def_id.node, exports2); debug!("(computing exports) writing exports for %d (some)", @@ -3448,12 +3451,12 @@ pub impl Resolver { // Items with the !resolve_unexported attribute are X-ray contexts. // This is used to allow the test runner to run unexported tests. let orig_xray_flag = self.xray_context; - if contains_name(attr_metas(/*bad*/copy item.attrs), + if contains_name(attr_metas(item.attrs), ~"!resolve_unexported") { self.xray_context = Xray; } - match /*bad*/copy item.node { + match item.node { // enum item: resolve all the variants' discrs, // then resolve the ty params @@ -3578,7 +3581,7 @@ pub impl Resolver { self.type_ribs.pop(); } - item_struct(struct_def, ref generics) => { + item_struct(ref struct_def, ref generics) => { self.resolve_struct(item.id, generics, struct_def.fields, @@ -3593,7 +3596,7 @@ pub impl Resolver { } } - item_foreign_mod(foreign_module) => { + item_foreign_mod(ref foreign_module) => { do self.with_scope(Some(item.ident)) { for foreign_module.items.each |foreign_item| { match foreign_item.node { @@ -3639,7 +3642,7 @@ pub impl Resolver { } self.resolve_function(OpaqueFunctionRibKind, - Some(@/*bad*/copy *fn_decl), + Some(fn_decl), HasTypeParameters (generics, item.id, @@ -3721,7 +3724,7 @@ pub impl Resolver { fn resolve_function(@mut self, rib_kind: RibKind, - optional_declaration: Option<@fn_decl>, + optional_declaration: Option<&fn_decl>, type_parameters: TypeParameters, block: &blk, self_binding: SelfBinding, @@ -3868,7 +3871,7 @@ pub impl Resolver { }; self.resolve_function(rib_kind, - Some(@/*bad*/copy method.decl), + Some(&method.decl), type_parameters, &method.body, self_binding, @@ -4133,7 +4136,7 @@ pub impl Resolver { } } - match copy result_def { + match result_def { Some(def) => { // Write the result into the def map. debug!("(resolving type) writing resolution for `%s` \ @@ -4681,7 +4684,7 @@ pub impl Resolver { } } - match copy search_result { + match search_result { Some(dl_def(def)) => { debug!("(resolving path in local ribs) resolved `%s` to \ local: %?", @@ -4823,7 +4826,7 @@ pub impl Resolver { } None => { let wrong_name = self.idents_to_str( - /*bad*/copy path.idents); + path.idents); if self.name_exists_in_scope_struct(wrong_name) { self.session.span_err(expr.span, fmt!("unresolved name: `%s`. \ @@ -4855,7 +4858,7 @@ pub impl Resolver { expr_fn_block(ref fn_decl, ref block) => { self.resolve_function(FunctionRibKind(expr.id, block.node.id), - Some(@/*bad*/copy *fn_decl), + Some(fn_decl), NoTypeParameters, block, NoSelfBinding, @@ -5007,7 +5010,7 @@ pub impl Resolver { let mut search_module = self.current_module; loop { // Look for the current trait. - match copy self.current_trait_refs { + match /*bad*/copy self.current_trait_refs { Some(trait_def_ids) => { for trait_def_ids.each |trait_def_id| { self.add_trait_info_if_containing_method( diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 8f0d9eb953f..45fe40ca1f7 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -501,12 +501,13 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint, let tcx = bcx.tcx(); let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, tcx.def_map, m, col, val) |p| { - match /*bad*/copy p.node { - ast::pat_enum(_, subpats) => { + match p.node { + ast::pat_enum(_, ref subpats) => { if opt_eq(tcx, &variant_opt(bcx, p.id), opt) { - Some(option::get_or_default(subpats, - vec::from_elem(variant_size, - dummy))) + match *subpats { + None => Some(vec::from_elem(variant_size, dummy)), + _ => copy *subpats + } } else { None } @@ -534,7 +535,7 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint, ast::pat_range(l1, l2) => { if opt_eq(tcx, &range(l1, l2), opt) {Some(~[])} else {None} } - ast::pat_struct(_, field_pats, _) => { + ast::pat_struct(_, ref field_pats, _) => { if opt_eq(tcx, &variant_opt(bcx, p.id), opt) { // Look up the struct variant ID. let struct_id; @@ -565,14 +566,14 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint, None } } - ast::pat_vec(before, slice, after) => { + ast::pat_vec(ref before, slice, ref after) => { match slice { - Some(_) => { + Some(slice) => { let n = before.len() + after.len(); let i = before.len(); if opt_eq(tcx, &vec_len_ge(n, i), opt) { - Some(vec::concat( - &[before, ~[slice.get()], after])) + Some(vec::append_one(copy *before, slice) + + *after) } else { None } @@ -580,7 +581,7 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint, None => { let n = before.len(); if opt_eq(tcx, &vec_len_eq(n), opt) { - Some(copy before) + Some(copy *before) } else { None } @@ -611,10 +612,10 @@ pub fn enter_rec_or_struct(bcx: block, let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - match /*bad*/copy p.node { - ast::pat_struct(_, fpats, _) => { + match p.node { + ast::pat_struct(_, ref fpats, _) => { let mut pats = ~[]; - for vec::each(fields) |fname| { + for fields.each |fname| { match fpats.find(|p| p.ident == *fname) { None => pats.push(dummy), Some(pat) => pats.push(pat.pat) @@ -642,8 +643,8 @@ pub fn enter_tup(bcx: block, dm: DefMap, m: &[@Match/&r], let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - match /*bad*/copy p.node { - ast::pat_tup(elts) => { + match p.node { + ast::pat_tup(/*bad*/copy elts) => { Some(elts) } _ => { @@ -670,8 +671,8 @@ pub fn enter_tuple_struct(bcx: block, let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - match /*bad*/copy p.node { - ast::pat_enum(_, Some(elts)) => Some(elts), + match p.node { + ast::pat_enum(_, Some(/*bad*/copy elts)) => Some(elts), _ => { assert_is_binding_or_wild(bcx, p); Some(vec::from_elem(n_elts, dummy)) @@ -774,7 +775,7 @@ pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] { let mut found = ~[]; for m.each |br| { let cur = br.pats[col]; - match /*bad*/copy cur.node { + match cur.node { ast::pat_lit(l) => { add_to_set(ccx.tcx, &mut found, lit(ExprLit(l))); } @@ -811,7 +812,7 @@ pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] { ast::pat_range(l1, l2) => { add_to_set(ccx.tcx, &mut found, range(l1, l2)); } - ast::pat_vec(before, slice, after) => { + ast::pat_vec(ref before, slice, ref after) => { let opt = match slice { None => vec_len_eq(before.len()), Some(_) => vec_len_ge(before.len() + after.len(), @@ -902,10 +903,10 @@ pub fn collect_record_or_struct_fields(bcx: block, -> ~[ast::ident] { let mut fields: ~[ast::ident] = ~[]; for vec::each(m) |br| { - match /*bad*/copy br.pats[col].node { - ast::pat_struct(_, fs, _) => { + match br.pats[col].node { + ast::pat_struct(_, ref fs, _) => { match ty::get(node_id_type(bcx, br.pats[col].id)).sty { - ty::ty_struct(*) => extend(&mut fields, fs), + ty::ty_struct(*) => extend(&mut fields, *fs), _ => () } } @@ -1300,8 +1301,8 @@ pub fn compile_submatch(bcx: block, if any_tup_pat(m, col) { let tup_ty = node_id_type(bcx, pat_id); let tup_repr = adt::represent_type(bcx.ccx(), tup_ty); - let n_tup_elts = match /*bad*/copy ty::get(tup_ty).sty { - ty::ty_tup(elts) => elts.len(), + let n_tup_elts = match ty::get(tup_ty).sty { + ty::ty_tup(ref elts) => elts.len(), _ => ccx.sess.bug(~"non-tuple type in tuple pattern") }; let tup_vals = do vec::from_fn(n_tup_elts) |i| { @@ -1701,8 +1702,8 @@ pub fn bind_irrefutable_pat(bcx: block, let mut bcx = bcx; // Necessary since bind_irrefutable_pat is called outside trans_match - match /*bad*/copy pat.node { - ast::pat_ident(_, _,inner) => { + match pat.node { + ast::pat_ident(_, _, ref inner) => { if pat_is_variant_or_struct(bcx.tcx().def_map, pat) { return bcx; } @@ -1740,7 +1741,7 @@ pub fn bind_irrefutable_pat(bcx: block, bcx, *inner_pat, val, true, binding_mode); } } - ast::pat_enum(_, sub_pats) => { + ast::pat_enum(_, ref sub_pats) => { match bcx.tcx().def_map.find(&pat.id) { Some(ast::def_variant(enum_id, var_id)) => { let repr = adt::represent_node(bcx, pat.id); @@ -1762,14 +1763,14 @@ pub fn bind_irrefutable_pat(bcx: block, } } Some(ast::def_struct(*)) => { - match sub_pats { + match *sub_pats { None => { // This is a unit-like struct. Nothing to do here. } - Some(elems) => { + Some(ref elems) => { // This is the tuple struct case. let repr = adt::represent_node(bcx, pat.id); - for vec::eachi(elems) |i, elem| { + for elems.eachi |i, elem| { let fldptr = adt::trans_field_ptr(bcx, repr, val, 0, i); bcx = bind_irrefutable_pat(bcx, @@ -1786,12 +1787,12 @@ pub fn bind_irrefutable_pat(bcx: block, } } } - ast::pat_struct(_, fields, _) => { + ast::pat_struct(_, ref fields, _) => { let tcx = bcx.tcx(); let pat_ty = node_id_type(bcx, pat.id); let pat_repr = adt::represent_type(bcx.ccx(), pat_ty); do expr::with_field_tys(tcx, pat_ty, None) |discr, field_tys| { - for vec::each(fields) |f| { + for fields.each |f| { let ix = ty::field_idx_strict(tcx, f.ident, field_tys); let fldptr = adt::trans_field_ptr(bcx, pat_repr, val, discr, ix); @@ -1803,9 +1804,9 @@ pub fn bind_irrefutable_pat(bcx: block, } } } - ast::pat_tup(elems) => { + ast::pat_tup(ref elems) => { let repr = adt::represent_node(bcx, pat.id); - for vec::eachi(elems) |i, elem| { + for elems.eachi |i, elem| { let fldptr = adt::trans_field_ptr(bcx, repr, val, 0, i); bcx = bind_irrefutable_pat(bcx, *elem, diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 4836ce062c9..8816c4a359b 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -638,7 +638,7 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, } let mut cx = cx; - match /*bad*/copy ty::get(t).sty { + match ty::get(t).sty { ty::ty_struct(*) => { let repr = adt::represent_type(cx.ccx(), t); do expr::with_field_tys(cx.tcx(), t, None) |discr, field_tys| { @@ -653,9 +653,9 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, let (base, len) = tvec::get_base_and_len(cx, av, t); cx = tvec::iter_vec_raw(cx, base, t, len, f); } - ty::ty_tup(args) => { + ty::ty_tup(ref args) => { let repr = adt::represent_type(cx.ccx(), t); - for vec::eachi(args) |i, arg| { + for args.eachi |i, arg| { let llfld_a = adt::trans_field_ptr(cx, repr, av, 0, i); cx = f(cx, llfld_a, *arg); } @@ -756,9 +756,9 @@ pub fn cast_shift_rhs(op: ast::binop, pub fn fail_if_zero(cx: block, span: span, divmod: ast::binop, rhs: ValueRef, rhs_t: ty::t) -> block { let text = if divmod == ast::div { - ~"divide by zero" + @~"divide by zero" } else { - ~"modulo zero" + @~"modulo zero" }; let is_zero = match ty::get(rhs_t).sty { ty::ty_int(t) => { @@ -775,7 +775,7 @@ pub fn fail_if_zero(cx: block, span: span, divmod: ast::binop, } }; do with_cond(cx, is_zero) |bcx| { - controlflow::trans_fail(bcx, Some(span), @/*bad*/copy text) + controlflow::trans_fail(bcx, Some(span), text) } } @@ -914,7 +914,7 @@ pub fn get_landing_pad(bcx: block) -> BasicBlockRef { let mut cached = None, pad_bcx = bcx; // Guaranteed to be set below do in_lpad_scope_cx(bcx) |inf| { // If there is a valid landing pad still around, use it - match copy inf.landing_pad { + match inf.landing_pad { Some(target) => cached = Some(target), None => { pad_bcx = lpad_block(bcx, ~"unwind"); @@ -944,7 +944,7 @@ pub fn get_landing_pad(bcx: block) -> BasicBlockRef { // We store the retval in a function-central alloca, so that calls to // Resume can find it. - match copy bcx.fcx.personality { + match bcx.fcx.personality { Some(addr) => Store(pad_bcx, llretval, addr), None => { let addr = alloca(pad_bcx, val_ty(llretval)); @@ -1143,9 +1143,9 @@ pub fn trans_stmt(cx: block, s: ast::stmt) -> block { bcx = expr::trans_into(cx, e, expr::Ignore); } ast::stmt_decl(d, _) => { - match /*bad*/copy d.node { - ast::decl_local(locals) => { - for vec::each(locals) |local| { + match d.node { + ast::decl_local(ref locals) => { + for locals.each |local| { bcx = init_local(bcx, *local); if cx.sess().opts.extra_debuginfo { debuginfo::create_local_var(bcx, *local); @@ -1390,9 +1390,9 @@ pub fn block_locals(b: &ast::blk, it: &fn(@ast::local)) { for vec::each(b.node.stmts) |s| { match s.node { ast::stmt_decl(d, _) => { - match /*bad*/copy d.node { - ast::decl_local(locals) => { - for vec::each(locals) |local| { + match d.node { + ast::decl_local(ref locals) => { + for locals.each |local| { it(*local); } } @@ -1771,7 +1771,7 @@ pub fn trans_closure(ccx: @CrateContext, let fcx = new_fn_ctxt_w_id(ccx, path, llfndecl, id, impl_id, param_substs, Some(body.span)); let raw_llargs = create_llargs_for_fn_args(fcx, ty_self, - /*bad*/copy decl.inputs); + decl.inputs); // Set GC for function. if ccx.sess.opts.gc { @@ -1871,8 +1871,8 @@ pub fn trans_enum_variant(ccx: @CrateContext, param_substs, None); let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args); let ty_param_substs = match param_substs { - Some(ref substs) => /*bad*/copy substs.tys, - None => ~[] + Some(ref substs) => { copy substs.tys } + None => ~[] }; let bcx = top_scope_block(fcx, None), lltop = bcx.llbb; let arg_tys = ty::ty_fn_args(node_id_type(bcx, variant.node.id)); @@ -1932,8 +1932,7 @@ pub fn trans_tuple_struct(ccx: @CrateContext, param_substs, None); - // XXX: Bad copy. - let raw_llargs = create_llargs_for_fn_args(fcx, no_self, copy fn_args); + let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args); let bcx = top_scope_block(fcx, None); let lltop = bcx.llbb; @@ -1942,7 +1941,7 @@ pub fn trans_tuple_struct(ccx: @CrateContext, // XXX is there a better way to reconstruct the ty::t? let ty_param_substs = match param_substs { - Some(ref substs) => /*bad*/copy substs.tys, + Some(ref substs) => { copy substs.tys } None => ~[] }; let ctor_ty = ty::subst_tps(ccx.tcx, ty_param_substs, None, @@ -2022,7 +2021,7 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: ast::enum_def, match variant.node.kind { ast::tuple_variant_kind(ref args) if args.len() > 0 => { let llfn = get_item_val(ccx, variant.node.id); - trans_enum_variant(ccx, id, *variant, /*bad*/copy *args, + trans_enum_variant(ccx, id, *variant, *args, disr_val, None, llfn); } ast::tuple_variant_kind(_) => { @@ -2051,7 +2050,7 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) { // tjc: ? _ => fail!(~"trans_item"), }; - match /*bad*/copy item.node { + match item.node { ast::item_fn(ref decl, purity, ref generics, ref body) => { if purity == ast::extern_fn { let llfndecl = get_item_val(ccx, item.id); @@ -2096,11 +2095,11 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) { ast::item_foreign_mod(ref foreign_mod) => { let abi = match attr::foreign_abi(item.attrs) { Right(abi_) => abi_, - Left(ref msg) => ccx.sess.span_fatal(item.span, /*bad*/copy *msg) + Left(msg) => ccx.sess.span_fatal(item.span, msg) }; foreign::trans_foreign_mod(ccx, foreign_mod, abi); } - ast::item_struct(struct_def, generics) => { + ast::item_struct(struct_def, ref generics) => { if !generics.is_type_parameterized() { trans_struct_def(ccx, struct_def, path, item.id); } @@ -2124,7 +2123,7 @@ pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def, // otherwise this is a unit-like struct. Some(ctor_id) if struct_def.fields.len() > 0 => { let llfndecl = get_item_val(ccx, ctor_id); - trans_tuple_struct(ccx, /*bad*/copy struct_def.fields, + trans_tuple_struct(ccx, struct_def.fields, ctor_id, None, llfndecl); } Some(_) | None => {} @@ -2405,7 +2404,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef { i.id, i.attrs) }; - set_inline_hint_if_appr(/*bad*/copy i.attrs, llfn); + set_inline_hint_if_appr(i.attrs, llfn); llfn } _ => fail!(~"get_item_val: weird result in table") @@ -2479,8 +2478,8 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef { ast_map::node_variant(ref v, enm, pth) => { let llfn; - match /*bad*/copy (*v).node.kind { - ast::tuple_variant_kind(args) => { + match v.node.kind { + ast::tuple_variant_kind(ref args) => { fail_unless!(args.len() != 0u); let pth = vec::append(/*bad*/copy *pth, ~[path_name(enm.ident), @@ -2543,7 +2542,7 @@ pub fn register_method(ccx: @CrateContext, let pth = vec::append(/*bad*/copy *pth, ~[path_name((ccx.names)(~"meth")), path_name(m.ident)]); let llfn = register_fn_full(ccx, m.span, pth, id, m.attrs, mty); - set_inline_hint_if_appr(/*bad*/copy m.attrs, llfn); + set_inline_hint_if_appr(m.attrs, llfn); llfn } @@ -3013,8 +3012,8 @@ pub fn trans_crate(sess: session::Session, llvm::LLVMModuleCreateWithNameInContext (buf, llvm::LLVMGetGlobalContext()) }); - let data_layout = /*bad*/copy sess.targ_cfg.target_strs.data_layout; - let targ_triple = /*bad*/copy sess.targ_cfg.target_strs.target_triple; + let data_layout: &str = sess.targ_cfg.target_strs.data_layout; + let targ_triple: &str = sess.targ_cfg.target_strs.target_triple; let _: () = str::as_c_str(data_layout, |buf| llvm::LLVMSetDataLayout(llmod, buf)); @@ -3022,8 +3021,7 @@ pub fn trans_crate(sess: session::Session, str::as_c_str(targ_triple, |buf| llvm::LLVMSetTarget(llmod, buf)); let targ_cfg = sess.targ_cfg; - let td = mk_target_data( - /*bad*/copy sess.targ_cfg.target_strs.data_layout); + let td = mk_target_data(sess.targ_cfg.target_strs.data_layout); let tn = mk_type_names(); let intrinsics = declare_intrinsics(llmod); if sess.opts.extra_debuginfo { diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 96c124d60de..0933cf6c8e5 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -70,10 +70,9 @@ pub fn count_insn(cx: block, category: &str) { let mut s = ~"."; i = 0u; while i < len { - let e = /*bad*/copy v[i]; - i = mm.get(&e); + i = mm.get(&v[i]); s += ~"/"; - s += e; + s += v[i]; i += 1u; } diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 04e25bdbf21..8c95ee4fd96 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -1291,14 +1291,14 @@ pub type mono_id = @mono_id_; impl to_bytes::IterBytes for mono_param_id { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { - match /*bad*/copy *self { - mono_precise(t, mids) => - to_bytes::iter_bytes_3(&0u8, &ty::type_id(t), &mids, lsb0, f), + match *self { + mono_precise(t, ref mids) => + to_bytes::iter_bytes_3(&0u8, &ty::type_id(t), mids, lsb0, f), - mono_any => 1u8.iter_bytes(lsb0, f), + mono_any => 1u8.iter_bytes(lsb0, f), - mono_repr(ref a, ref b, ref c, ref d) => - to_bytes::iter_bytes_5(&2u8, a, b, c, d, lsb0, f) + mono_repr(ref a, ref b, ref c, ref d) => + to_bytes::iter_bytes_5(&2u8, a, b, c, d, lsb0, f) } } } @@ -1340,7 +1340,7 @@ pub fn path_str(sess: session::Session, p: &[path_elt]) -> ~str { } pub fn monomorphize_type(bcx: block, t: ty::t) -> ty::t { - match /*bad*/copy bcx.fcx.param_substs { + match bcx.fcx.param_substs { Some(substs) => { ty::subst_tps(bcx.tcx(), substs.tys, substs.self_ty, t) } @@ -1367,7 +1367,7 @@ pub fn expr_ty_adjusted(bcx: block, ex: @ast::expr) -> ty::t { pub fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] { let tcx = bcx.tcx(); let params = ty::node_id_to_type_params(tcx, id); - match /*bad*/copy bcx.fcx.param_substs { + match bcx.fcx.param_substs { Some(substs) => { do vec::map(params) |t| { ty::subst_tps(tcx, substs.tys, substs.self_ty, *t) @@ -1396,7 +1396,7 @@ pub fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, +vt: typeck::vtable_origin) let tcx = fcx.ccx.tcx; match vt { typeck::vtable_static(trait_id, tys, sub) => { - let tys = match /*bad*/copy fcx.param_substs { + let tys = match fcx.param_substs { Some(substs) => { do vec::map(tys) |t| { ty::subst_tps(tcx, substs.tys, substs.self_ty, *t) diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 1d1fb13db0c..b630a9b44e8 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -242,7 +242,7 @@ pub fn const_expr(cx: @CrateContext, e: @ast::expr) -> ValueRef { fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { unsafe { let _icx = cx.insn_ctxt("const_expr"); - return match /*bad*/copy e.node { + return match e.node { ast::expr_lit(lit) => consts::const_lit(cx, e, *lit), ast::expr_binary(b, e1, e2) => { let te1 = const_expr(cx, e1); @@ -438,7 +438,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { ast::expr_addr_of(ast::m_imm, sub) => { const_addr_of(cx, const_expr(cx, sub)) } - ast::expr_tup(es) => { + ast::expr_tup(ref es) => { let ety = ty::expr_ty(cx.tcx, e); let repr = adt::represent_type(cx, ety); adt::trans_const(cx, repr, 0, es.map(|e| const_expr(cx, *e))) @@ -460,24 +460,24 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { adt::trans_const(cx, repr, discr, cs) } } - ast::expr_vec(es, ast::m_imm) => { - let (v, _, _) = const_vec(cx, e, es); + ast::expr_vec(ref es, ast::m_imm) => { + let (v, _, _) = const_vec(cx, e, *es); v } ast::expr_vstore(e, ast::expr_vstore_fixed(_)) => { const_expr(cx, e) } ast::expr_vstore(sub, ast::expr_vstore_slice) => { - match /*bad*/copy sub.node { - ast::expr_lit(lit) => { + match sub.node { + ast::expr_lit(ref lit) => { match lit.node { ast::lit_str(*) => { const_expr(cx, sub) } _ => { cx.sess.span_bug(e.span, ~"bad const-slice lit") } } } - ast::expr_vec(es, ast::m_imm) => { - let (cv, sz, llunitty) = const_vec(cx, e, es); + ast::expr_vec(ref es, ast::m_imm) => { + let (cv, sz, llunitty) = const_vec(cx, e, *es); let llty = val_ty(cv); let gv = do str::as_c_str("const") |name| { llvm::LLVMAddGlobal(cx.llmod, llty, name) @@ -525,7 +525,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { } } } - ast::expr_call(callee, args, _) => { + ast::expr_call(callee, ref args, _) => { match cx.tcx.def_map.find(&callee.id) { Some(ast::def_struct(_)) => { let ety = ty::expr_ty(cx.tcx, e); diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index e4b9d01c509..f74f83e4573 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -520,7 +520,7 @@ fn create_struct(cx: @CrateContext, t: ty::t, fields: ~[ty::field], return mdval; } -fn create_tuple(cx: @CrateContext, t: ty::t, elements: ~[ty::t], span: span) +fn create_tuple(cx: @CrateContext, t: ty::t, elements: &[ty::t], span: span) -> @Metadata { let fname = filename_from_span(cx, span); let file_node = create_file(cx, fname); @@ -648,46 +648,46 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span) }*/ let sty = copy ty::get(t).sty; - match copy sty { + match sty { ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) | ty::ty_uint(_) | ty::ty_float(_) => create_basic_type(cx, t, span), ty::ty_estr(_vstore) => { cx.sess.span_bug(span, ~"debuginfo for estr NYI") }, - ty::ty_enum(_did, _substs) => { + ty::ty_enum(_did, ref _substs) => { cx.sess.span_bug(span, ~"debuginfo for enum NYI") } - ty::ty_box(_mt) => { + ty::ty_box(ref _mt) => { cx.sess.span_bug(span, ~"debuginfo for box NYI") }, - ty::ty_uniq(_mt) => { + ty::ty_uniq(ref _mt) => { cx.sess.span_bug(span, ~"debuginfo for uniq NYI") }, - ty::ty_evec(_mt, _vstore) => { + ty::ty_evec(ref _mt, ref _vstore) => { cx.sess.span_bug(span, ~"debuginfo for evec NYI") }, - ty::ty_ptr(mt) => { + ty::ty_ptr(ref mt) => { let pointee = create_ty(cx, mt.ty, span); create_pointer_type(cx, t, span, pointee) }, - ty::ty_rptr(_region, _mt) => { + ty::ty_rptr(ref _region, ref _mt) => { cx.sess.span_bug(span, ~"debuginfo for rptr NYI") }, - ty::ty_bare_fn(_barefnty) => { + ty::ty_bare_fn(ref _barefnty) => { cx.sess.span_bug(span, ~"debuginfo for bare_fn NYI") }, - ty::ty_closure(_closurety) => { + ty::ty_closure(ref _closurety) => { cx.sess.span_bug(span, ~"debuginfo for closure NYI") }, - ty::ty_trait(_did, _substs, _vstore) => { + ty::ty_trait(_did, ref _substs, ref _vstore) => { cx.sess.span_bug(span, ~"debuginfo for trait NYI") }, - ty::ty_struct(did, substs) => { - let fields = ty::struct_fields(cx.tcx, did, &substs); + ty::ty_struct(did, ref substs) => { + let fields = ty::struct_fields(cx.tcx, did, substs); create_struct(cx, t, fields, span) }, - ty::ty_tup(elements) => { - create_tuple(cx, t, elements, span) + ty::ty_tup(ref elements) => { + create_tuple(cx, t, *elements, span) }, _ => cx.sess.bug(~"debuginfo: unexpected type in create_ty") } @@ -853,8 +853,8 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata { let (ident, ret_ty, id) = match cx.tcx.items.get(&fcx.id) { ast_map::node_item(item, _) => { - match /*bad*/copy item.node { - ast::item_fn(decl, _, _, _) => { + match item.node { + ast::item_fn(ref decl, _, _, _) => { (item.ident, decl.output, item.id) } _ => fcx.ccx.sess.span_bug(item.span, ~"create_function: item \ @@ -865,8 +865,8 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata { (method.ident, method.decl.output, method.id) } ast_map::node_expr(expr) => { - match /*bad*/copy expr.node { - ast::expr_fn_block(decl, _) => { + match expr.node { + ast::expr_fn_block(ref decl, _) => { ((dbg_cx.names)(~"fn"), decl.output, expr.id) } _ => fcx.ccx.sess.span_bug(expr.span, diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 284a5eac39d..2352ada8ced 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -792,7 +792,7 @@ pub fn emit_tydescs(ccx: @CrateContext) { // tydesc type. Then we'll recast each function to its real type when // calling it. let take_glue = - match copy ti.take_glue { + match ti.take_glue { None => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } Some(v) => { unsafe { @@ -802,7 +802,7 @@ pub fn emit_tydescs(ccx: @CrateContext) { } }; let drop_glue = - match copy ti.drop_glue { + match ti.drop_glue { None => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } Some(v) => { unsafe { @@ -812,7 +812,7 @@ pub fn emit_tydescs(ccx: @CrateContext) { } }; let free_glue = - match copy ti.free_glue { + match ti.free_glue { None => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } Some(v) => { unsafe { @@ -822,7 +822,7 @@ pub fn emit_tydescs(ccx: @CrateContext) { } }; let visit_glue = - match copy ti.visit_glue { + match ti.visit_glue { None => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } Some(v) => { unsafe { diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 51e26d3cfef..205acedb9e1 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -320,12 +320,12 @@ pub fn trans_static_method_callee(bcx: block, let vtbls = resolve_vtables_in_fn_ctxt( bcx.fcx, ccx.maps.vtable_map.get(&callee_id)); - match /*bad*/copy vtbls[bound_index] { - typeck::vtable_static(impl_did, rcvr_substs, rcvr_origins) => { + match vtbls[bound_index] { + typeck::vtable_static(impl_did, ref rcvr_substs, rcvr_origins) => { let mth_id = method_with_name(bcx.ccx(), impl_did, mname); let callee_substs = combine_impl_and_methods_tps( - bcx, mth_id, impl_did, callee_id, rcvr_substs); + bcx, mth_id, impl_did, callee_id, *rcvr_substs); let callee_origins = combine_impl_and_methods_origins( bcx, mth_id, impl_did, callee_id, rcvr_origins); @@ -347,7 +347,7 @@ pub fn trans_static_method_callee(bcx: block, } } -pub fn method_from_methods(ms: ~[@ast::method], name: ast::ident) +pub fn method_from_methods(ms: &[@ast::method], name: ast::ident) -> Option { ms.find(|m| m.ident == name).map(|m| ast_util::local_def(m.id)) } @@ -360,7 +360,7 @@ pub fn method_with_name(ccx: @CrateContext, impl_id: ast::def_id, node: ast::item_impl(_, _, _, ref ms), _ }, _) => { - method_from_methods(/*bad*/copy *ms, name).get() + method_from_methods(*ms, name).get() } _ => fail!(~"method_with_name") } @@ -376,7 +376,7 @@ pub fn method_with_name_or_default(ccx: @CrateContext, impl_id: ast::def_id, ast_map::node_item(@ast::item { node: ast::item_impl(_, _, _, ref ms), _ }, _) => { - let did = method_from_methods(/*bad*/copy *ms, name); + let did = method_from_methods(*ms, name); if did.is_some() { return did.get(); } else { @@ -440,7 +440,7 @@ pub fn trans_monomorphized_callee(bcx: block, -> Callee { let _icx = bcx.insn_ctxt("impl::trans_monomorphized_callee"); return match vtbl { - typeck::vtable_static(impl_did, rcvr_substs, rcvr_origins) => { + typeck::vtable_static(impl_did, ref rcvr_substs, rcvr_origins) => { let ccx = bcx.ccx(); let mname = ty::trait_methods(ccx.tcx, trait_id)[n_method].ident; let mth_id = method_with_name_or_default( @@ -453,7 +453,7 @@ pub fn trans_monomorphized_callee(bcx: block, // create a concatenated set of substitutions which includes // those from the impl and those from the method: let callee_substs = combine_impl_and_methods_tps( - bcx, mth_id, impl_did, callee_id, rcvr_substs); + bcx, mth_id, impl_did, callee_id, *rcvr_substs); let callee_origins = combine_impl_and_methods_origins( bcx, mth_id, impl_did, callee_id, rcvr_origins); @@ -490,7 +490,7 @@ pub fn combine_impl_and_methods_tps(bcx: block, mth_did: ast::def_id, impl_did: ast::def_id, callee_id: ast::node_id, - +rcvr_substs: ~[ty::t]) + rcvr_substs: &[ty::t]) -> ~[ty::t] { /*! * @@ -514,7 +514,7 @@ pub fn combine_impl_and_methods_tps(bcx: block, let node_substs = node_id_type_params(bcx, callee_id); debug!("rcvr_substs=%?", rcvr_substs.map(|t| bcx.ty_to_str(*t))); let ty_substs - = vec::append(rcvr_substs, + = vec::append(rcvr_substs.to_vec(), vec::tailn(node_substs, node_substs.len() - n_m_tps)); debug!("n_m_tps=%?", n_m_tps); diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index 44464810620..306eb0b0d44 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -98,7 +98,7 @@ fn traverse_public_mod(cx: ctx, mod_id: node_id, m: &_mod) { fn traverse_public_item(cx: ctx, item: @item) { if cx.rmap.contains_key(&item.id) { return; } cx.rmap.insert(item.id, ()); - match /*bad*/copy item.node { + match item.node { item_mod(ref m) => traverse_public_mod(cx, item.id, m), item_foreign_mod(ref nm) => { if !traverse_exports(cx, item.id) { diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 955bc563107..c6bf8ff3a3a 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -75,7 +75,7 @@ pub impl Reflector { PointerCast(bcx, static_ti.tydesc, T_ptr(self.tydesc_ty)) } - fn c_mt(&mut self, mt: ty::mt) -> ~[ValueRef] { + fn c_mt(&mut self, mt: &ty::mt) -> ~[ValueRef] { ~[self.c_uint(mt.mutbl as uint), self.c_tydesc(mt.ty)] } @@ -151,7 +151,7 @@ pub impl Reflector { debug!("reflect::visit_ty %s", ty_to_str(bcx.ccx().tcx, t)); - match /*bad*/copy ty::get(t).sty { + match ty::get(t).sty { ty::ty_bot => self.leaf(~"bot"), ty::ty_nil => self.leaf(~"nil"), ty::ty_bool => self.leaf(~"bool"), @@ -170,7 +170,7 @@ pub impl Reflector { ty::ty_float(ast::ty_f32) => self.leaf(~"f32"), ty::ty_float(ast::ty_f64) => self.leaf(~"f64"), - ty::ty_unboxed_vec(mt) => { + ty::ty_unboxed_vec(ref mt) => { let values = self.c_mt(mt); self.visit(~"vec", values) } @@ -179,30 +179,30 @@ pub impl Reflector { let (name, extra) = self.vstore_name_and_extra(t, vst); self.visit(~"estr_" + name, extra) } - ty::ty_evec(mt, vst) => { + ty::ty_evec(ref mt, vst) => { let (name, extra) = self.vstore_name_and_extra(t, vst); let extra = extra + self.c_mt(mt); self.visit(~"evec_" + name, extra) } - ty::ty_box(mt) => { + ty::ty_box(ref mt) => { let extra = self.c_mt(mt); self.visit(~"box", extra) } - ty::ty_uniq(mt) => { + ty::ty_uniq(ref mt) => { let extra = self.c_mt(mt); self.visit(~"uniq", extra) } - ty::ty_ptr(mt) => { + ty::ty_ptr(ref mt) => { let extra = self.c_mt(mt); self.visit(~"ptr", extra) } - ty::ty_rptr(_, mt) => { + ty::ty_rptr(_, ref mt) => { let extra = self.c_mt(mt); self.visit(~"rptr", extra) } - ty::ty_tup(tys) => { - let extra = ~[self.c_uint(vec::len(tys))] + ty::ty_tup(ref tys) => { + let extra = ~[self.c_uint(tys.len())] + self.c_size_and_align(t); do self.bracketed(~"tup", extra) |this| { for tys.eachi |i, t| { @@ -254,7 +254,7 @@ pub impl Reflector { let extra = ~[this.c_uint(i), this.c_slice( bcx.ccx().sess.str_of(field.ident))] - + this.c_mt(field.mt); + + this.c_mt(&field.mt); this.visit(~"class_field", extra); } } @@ -293,7 +293,7 @@ pub impl Reflector { ty::ty_trait(_, _, _) => self.leaf(~"trait"), ty::ty_infer(_) => self.leaf(~"infer"), ty::ty_err => self.leaf(~"err"), - ty::ty_param(p) => { + ty::ty_param(ref p) => { let extra = ~[self.c_uint(p.idx)]; self.visit(~"param", extra) } diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 9f66bb5b468..586b29c19c9 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -361,7 +361,7 @@ pub fn write_content(bcx: block, bcx.expr_to_str(vstore_expr)); let _indenter = indenter(); - match /*bad*/copy content_expr.node { + match content_expr.node { ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => { match dest { Ignore => { @@ -376,7 +376,7 @@ pub fn write_content(bcx: block, } } } - ast::expr_vec(elements, _) => { + ast::expr_vec(ref elements, _) => { match dest { Ignore => { for elements.each |element| { @@ -467,11 +467,11 @@ pub fn vec_types(bcx: block, vec_ty: ty::t) -> VecTypes { pub fn elements_required(bcx: block, content_expr: @ast::expr) -> uint { //! Figure out the number of elements we need to store this content - match /*bad*/copy content_expr.node { + match content_expr.node { ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => { s.len() + 1 }, - ast::expr_vec(es, _) => es.len(), + ast::expr_vec(ref es, _) => es.len(), ast::expr_repeat(_, count_expr, _) => { ty::eval_repeat_count(bcx.tcx(), count_expr) } diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 0c3e93885f9..785a3183676 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -176,7 +176,7 @@ pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef { } // XXX: This is a terrible terrible copy. - let llty = match /*bad*/copy ty::get(t).sty { + let llty = match ty::get(t).sty { ty::ty_nil | ty::ty_bot => T_nil(), ty::ty_bool => T_bool(), ty::ty_int(t) => T_int_ty(cx, t), @@ -199,22 +199,22 @@ pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef { ty::ty_estr(ty::vstore_box) => { T_box_ptr(T_box(cx, T_vec(cx, T_i8()))) } - ty::ty_evec(mt, ty::vstore_box) => { + ty::ty_evec(ref mt, ty::vstore_box) => { T_box_ptr(T_box(cx, T_vec(cx, type_of(cx, mt.ty)))) } - ty::ty_box(mt) => T_box_ptr(T_box(cx, type_of(cx, mt.ty))), + ty::ty_box(ref mt) => T_box_ptr(T_box(cx, type_of(cx, mt.ty))), ty::ty_opaque_box => T_box_ptr(T_box(cx, T_i8())), - ty::ty_uniq(mt) => T_unique_ptr(T_unique(cx, type_of(cx, mt.ty))), - ty::ty_evec(mt, ty::vstore_uniq) => { + ty::ty_uniq(ref mt) => T_unique_ptr(T_unique(cx, type_of(cx, mt.ty))), + ty::ty_evec(ref mt, ty::vstore_uniq) => { T_unique_ptr(T_unique(cx, T_vec(cx, type_of(cx, mt.ty)))) } - ty::ty_unboxed_vec(mt) => { + ty::ty_unboxed_vec(ref mt) => { T_vec(cx, type_of(cx, mt.ty)) } - ty::ty_ptr(mt) => T_ptr(type_of(cx, mt.ty)), - ty::ty_rptr(_, mt) => T_ptr(type_of(cx, mt.ty)), + ty::ty_ptr(ref mt) => T_ptr(type_of(cx, mt.ty)), + ty::ty_rptr(_, ref mt) => T_ptr(type_of(cx, mt.ty)), - ty::ty_evec(mt, ty::vstore_slice(_)) => { + ty::ty_evec(ref mt, ty::vstore_slice(_)) => { T_struct(~[T_ptr(type_of(cx, mt.ty)), T_uint_ty(cx, ast::ty_u)]) } @@ -228,7 +228,7 @@ pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef { T_array(T_i8(), n + 1u /* +1 for trailing null */) } - ty::ty_evec(mt, ty::vstore_fixed(n)) => { + ty::ty_evec(ref mt, ty::vstore_fixed(n)) => { T_array(type_of(cx, mt.ty), n) } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 599fa28e242..b0cf31fe8b7 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1161,20 +1161,20 @@ pub fn walk_ty(ty: t, f: &fn(t)) { pub fn maybe_walk_ty(ty: t, f: &fn(t) -> bool) { if !f(ty) { return; } - match /*bad*/copy get(ty).sty { + match get(ty).sty { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_estr(_) | ty_type | ty_opaque_box | ty_self | ty_opaque_closure_ptr(_) | ty_infer(_) | ty_param(_) | ty_err => { } - ty_box(tm) | ty_evec(tm, _) | ty_unboxed_vec(tm) | - ty_ptr(tm) | ty_rptr(_, tm) => { + ty_box(ref tm) | ty_evec(ref tm, _) | ty_unboxed_vec(ref tm) | + ty_ptr(ref tm) | ty_rptr(_, ref tm) | ty_uniq(ref tm) => { maybe_walk_ty(tm.ty, f); } ty_enum(_, ref substs) | ty_struct(_, ref substs) | ty_trait(_, ref substs, _) => { for (*substs).tps.each |subty| { maybe_walk_ty(*subty, f); } } - ty_tup(ts) => { for ts.each |tt| { maybe_walk_ty(*tt, f); } } + ty_tup(ref ts) => { for ts.each |tt| { maybe_walk_ty(*tt, f); } } ty_bare_fn(ref ft) => { for ft.sig.inputs.each |a| { maybe_walk_ty(a.ty, f); } maybe_walk_ty(ft.sig.output, f); @@ -1183,7 +1183,6 @@ pub fn maybe_walk_ty(ty: t, f: &fn(t) -> bool) { for ft.sig.inputs.each |a| { maybe_walk_ty(a.ty, f); } maybe_walk_ty(ft.sig.output, f); } - ty_uniq(tm) => { maybe_walk_ty(tm.ty, f); } } } @@ -1209,20 +1208,20 @@ fn fold_sty(sty: &sty, fldop: &fn(t) -> t) -> sty { tps: substs.tps.map(|t| fldop(*t))} } - match /*bad*/copy *sty { - ty_box(tm) => { + match *sty { + ty_box(ref tm) => { ty_box(mt {ty: fldop(tm.ty), mutbl: tm.mutbl}) } - ty_uniq(tm) => { + ty_uniq(ref tm) => { ty_uniq(mt {ty: fldop(tm.ty), mutbl: tm.mutbl}) } - ty_ptr(tm) => { + ty_ptr(ref tm) => { ty_ptr(mt {ty: fldop(tm.ty), mutbl: tm.mutbl}) } - ty_unboxed_vec(tm) => { + ty_unboxed_vec(ref tm) => { ty_unboxed_vec(mt {ty: fldop(tm.ty), mutbl: tm.mutbl}) } - ty_evec(tm, vst) => { + ty_evec(ref tm, vst) => { ty_evec(mt {ty: fldop(tm.ty), mutbl: tm.mutbl}, vst) } ty_enum(tid, ref substs) => { @@ -1231,8 +1230,8 @@ fn fold_sty(sty: &sty, fldop: &fn(t) -> t) -> sty { ty_trait(did, ref substs, st) => { ty_trait(did, fold_substs(substs, fldop), st) } - ty_tup(ts) => { - let new_ts = vec::map(ts, |tt| fldop(*tt)); + ty_tup(ref ts) => { + let new_ts = ts.map(|tt| fldop(*tt)); ty_tup(new_ts) } ty_bare_fn(ref f) => { @@ -1243,7 +1242,7 @@ fn fold_sty(sty: &sty, fldop: &fn(t) -> t) -> sty { let sig = fold_sig(&f.sig, fldop); ty_closure(ClosureTy {sig: sig, ..copy *f}) } - ty_rptr(r, tm) => { + ty_rptr(r, ref tm) => { ty_rptr(r, mt {ty: fldop(tm.ty), mutbl: tm.mutbl}) } ty_struct(did, ref substs) => { @@ -1510,8 +1509,8 @@ pub fn sequence_element_type(cx: ctxt, ty: t) -> t { } pub fn get_element_type(ty: t, i: uint) -> t { - match /*bad*/copy get(ty).sty { - ty_tup(ts) => return ts[i], + match get(ty).sty { + ty_tup(ref ts) => return ts[i], _ => fail!(~"get_element_type called on invalid type") } } @@ -2118,7 +2117,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { /// gives a rough estimate of how much space it takes to represent /// an instance of `ty`. Used for the mode transition. fn type_size(cx: ctxt, ty: t) -> uint { - match /*bad*/copy get(ty).sty { + match get(ty).sty { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_ptr(_) | ty_box(_) | ty_uniq(_) | ty_estr(vstore_uniq) | ty_trait(*) | ty_rptr(*) | ty_evec(_, vstore_uniq) | @@ -2146,7 +2145,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { flds.foldl(0, |s, f| *s + type_size(cx, f.mt.ty)) } - ty_tup(tys) => { + ty_tup(ref tys) => { tys.foldl(0, |s, t| *s + type_size(cx, *t)) } @@ -2208,7 +2207,7 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ::util::ppaux::ty_to_str(cx, r_ty), ::util::ppaux::ty_to_str(cx, ty)); - let r = match /*bad*/copy get(ty).sty { + let r = match get(ty).sty { ty_nil | ty_bot | ty_bool | @@ -2229,9 +2228,9 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ty_unboxed_vec(_) => { false } - ty_box(mt) | - ty_uniq(mt) | - ty_rptr(_, mt) => { + ty_box(ref mt) | + ty_uniq(ref mt) | + ty_rptr(_, ref mt) => { return type_requires(cx, seen, r_ty, mt.ty); } @@ -2255,8 +2254,8 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool { r } - ty_tup(ts) => { - vec::any(ts, |t| type_requires(cx, seen, r_ty, *t)) + ty_tup(ref ts) => { + ts.any(|t| type_requires(cx, seen, r_ty, *t)) } ty_enum(ref did, _) if vec::contains(*seen, did) => { @@ -2297,7 +2296,7 @@ pub fn type_structurally_contains(cx: ctxt, debug!("type_structurally_contains: %s", ::util::ppaux::ty_to_str(cx, ty)); if test(sty) { return true; } - match /*bad*/copy *sty { + match *sty { ty_enum(did, ref substs) => { for vec::each(*enum_variants(cx, did)) |variant| { for variant.args.each |aty| { @@ -2315,13 +2314,13 @@ pub fn type_structurally_contains(cx: ctxt, return false; } - ty_tup(ts) => { + ty_tup(ref ts) => { for ts.each |tt| { if type_structurally_contains(cx, *tt, test) { return true; } } return false; } - ty_evec(mt, vstore_fixed(_)) => { + ty_evec(ref mt, vstore_fixed(_)) => { return type_structurally_contains(cx, mt.ty, test); } _ => return false @@ -2375,7 +2374,7 @@ pub fn type_is_signed(ty: t) -> bool { // that the cycle collector might care about. pub fn type_is_pod(cx: ctxt, ty: t) -> bool { let mut result = true; - match /*bad*/copy get(ty).sty { + match get(ty).sty { // Scalar types ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) | ty_type | ty_ptr(_) | ty_bare_fn(_) => result = true, @@ -2395,11 +2394,11 @@ pub fn type_is_pod(cx: ctxt, ty: t) -> bool { if !type_is_pod(cx, tup_ty) { result = false; } } } - ty_tup(elts) => { + ty_tup(ref elts) => { for elts.each |elt| { if !type_is_pod(cx, *elt) { result = false; } } } ty_estr(vstore_fixed(_)) => result = true, - ty_evec(mt, vstore_fixed(_)) | ty_unboxed_vec(mt) => { + ty_evec(ref mt, vstore_fixed(_)) | ty_unboxed_vec(ref mt) => { result = type_is_pod(cx, mt.ty); } ty_param(_) => result = false, @@ -3007,8 +3006,8 @@ pub fn method_call_bounds(tcx: ctxt, method_map: typeck::method_map, // trait itself. This ought to be harmonized. let trt_bounds = ty::lookup_item_type(tcx, trt_id).bounds; - let mth = /*bad*/copy ty::trait_methods(tcx, trt_id)[n_mth]; - @(vec::append(/*bad*/copy *trt_bounds, *mth.tps)) + @(vec::append(/*bad*/copy *trt_bounds, + *ty::trait_methods(tcx, trt_id)[n_mth].tps)) } } } @@ -3528,7 +3527,7 @@ pub fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[ast::ident] { node: item_trait(_, _, ref ms), _ }, _)) => - match ast_util::split_trait_methods((/*bad*/copy *ms)) { + match ast_util::split_trait_methods(*ms) { (_, p) => p.map(|method| method.ident) }, _ => cx.sess.bug(fmt!("provided_trait_methods: %? is not a trait", @@ -3830,9 +3829,8 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[VariantInfo] { node: ast::item_enum(ref enum_definition, _), _ }, _) => { - let variants = /*bad*/copy (*enum_definition).variants; let mut disr_val = -1; - @vec::map(variants, |variant| { + @vec::map(enum_definition.variants, |variant| { match variant.node.kind { ast::tuple_variant_kind(ref args) => { let ctor_ty = node_id_to_type(cx, variant.node.id); @@ -3945,7 +3943,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { Some(ast_map::node_item(i,_)) => { match i.node { ast::item_struct(struct_def, _) => { - struct_field_tys(/*bad*/copy struct_def.fields) + struct_field_tys(struct_def.fields) } _ => cx.sess.bug(~"struct ID bound to non-struct") } @@ -3953,7 +3951,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { Some(ast_map::node_variant(ref variant, _, _)) => { match (*variant).node.kind { ast::struct_variant_kind(struct_def) => { - struct_field_tys(/*bad*/copy struct_def.fields) + struct_field_tys(struct_def.fields) } _ => { cx.sess.bug(~"struct ID bound to enum variant that isn't \ @@ -3993,7 +3991,7 @@ pure fn is_public(f: field_ty) -> bool { } } -fn struct_field_tys(fields: ~[@struct_field]) -> ~[field_ty] { +fn struct_field_tys(fields: &[@struct_field]) -> ~[field_ty] { do fields.map |field| { match field.node.kind { named_field(ident, mutability, visibility) => { diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 2a70ba7d4c1..b49c8c2bff8 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -212,7 +212,7 @@ pub fn ast_ty_to_ty( self: &AC, rscope: &RS, &&ast_ty: @ast::Ty) -> ty::t { fn ast_mt_to_mt( - self: &AC, rscope: &RS, mt: ast::mt) -> ty::mt { + self: &AC, rscope: &RS, mt: &ast::mt) -> ty::mt { ty::mt {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl} } @@ -223,14 +223,14 @@ pub fn ast_ty_to_ty( fn mk_pointer( self: &AC, rscope: &RS, - a_seq_ty: ast::mt, + a_seq_ty: &ast::mt, vst: ty::vstore, constr: &fn(ty::mt) -> ty::t) -> ty::t { let tcx = self.tcx(); match a_seq_ty.ty.node { - ast::ty_vec(mt) => { + ast::ty_vec(ref mt) => { let mut mt = ast_mt_to_mt(self, rscope, mt); if a_seq_ty.mutbl == ast::m_mutbl || a_seq_ty.mutbl == ast::m_const { @@ -318,34 +318,34 @@ pub fn ast_ty_to_ty( } tcx.ast_ty_to_ty_cache.insert(ast_ty.id, ty::atttce_unresolved); - let typ = match /*bad*/copy ast_ty.node { + let typ = match ast_ty.node { ast::ty_nil => ty::mk_nil(tcx), ast::ty_bot => ty::mk_bot(tcx), - ast::ty_box(mt) => { + ast::ty_box(ref mt) => { mk_pointer(self, rscope, mt, ty::vstore_box, |tmt| ty::mk_box(tcx, tmt)) } - ast::ty_uniq(mt) => { + ast::ty_uniq(ref mt) => { mk_pointer(self, rscope, mt, ty::vstore_uniq, |tmt| ty::mk_uniq(tcx, tmt)) } - ast::ty_vec(mt) => { + ast::ty_vec(ref mt) => { tcx.sess.span_err(ast_ty.span, ~"bare `[]` is not a type"); // return /something/ so they can at least get more errors ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), ty::vstore_uniq) } - ast::ty_ptr(mt) => { + ast::ty_ptr(ref mt) => { ty::mk_ptr(tcx, ast_mt_to_mt(self, rscope, mt)) } - ast::ty_rptr(region, mt) => { + ast::ty_rptr(region, ref mt) => { let r = ast_region_to_region(self, rscope, ast_ty.span, region); mk_pointer(self, rscope, mt, ty::vstore_slice(r), |tmt| ty::mk_rptr(tcx, r, tmt)) } - ast::ty_tup(fields) => { - let flds = vec::map(fields, |t| ast_ty_to_ty(self, rscope, *t)); + ast::ty_tup(ref fields) => { + let flds = fields.map(|t| ast_ty_to_ty(self, rscope, *t)); ty::mk_tup(tcx, flds) } ast::ty_bare_fn(ref bf) => { @@ -413,7 +413,7 @@ pub fn ast_ty_to_ty( } } } - ast::ty_fixed_length_vec(a_mt, e) => { + ast::ty_fixed_length_vec(ref a_mt, e) => { match const_eval::eval_const_expr_partial(tcx, e) { Ok(ref r) => { match *r { diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 4b7def26fd5..5e106668fc9 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -28,7 +28,7 @@ use syntax::print::pprust; pub fn check_match(fcx: @mut FnCtxt, expr: @ast::expr, discrim: @ast::expr, - arms: ~[ast::arm]) -> bool { + arms: &[ast::arm]) -> bool { let tcx = fcx.ccx.tcx; let mut bot; @@ -74,7 +74,7 @@ pub struct pat_ctxt { } pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, - +subpats: Option<~[@ast::pat]>, expected: ty::t) { + subpats: &Option<~[@ast::pat]>, expected: ty::t) { // Typecheck the path. let fcx = pcx.fcx; @@ -162,7 +162,7 @@ pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, // Count the number of subpatterns. let subpats_len; - match subpats { + match *subpats { None => subpats_len = arg_len, Some(ref subpats) => subpats_len = subpats.len() } @@ -207,7 +207,7 @@ pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, pub fn check_struct_pat_fields(pcx: pat_ctxt, span: span, path: @ast::path, - fields: ~[ast::field_pat], + fields: &[ast::field_pat], class_fields: ~[ty::field_ty], class_id: ast::def_id, substitutions: &ty::substs, @@ -258,7 +258,7 @@ pub fn check_struct_pat_fields(pcx: pat_ctxt, pub fn check_struct_pat(pcx: pat_ctxt, pat_id: ast::node_id, span: span, expected: ty::t, path: @ast::path, - +fields: ~[ast::field_pat], etc: bool, + fields: &[ast::field_pat], etc: bool, class_id: ast::def_id, substitutions: &ty::substs) { let fcx = pcx.fcx; let tcx = pcx.fcx.ccx.tcx; @@ -299,7 +299,7 @@ pub fn check_struct_like_enum_variant_pat(pcx: pat_ctxt, span: span, expected: ty::t, path: @ast::path, - +fields: ~[ast::field_pat], + fields: &[ast::field_pat], etc: bool, enum_id: ast::def_id, substitutions: &ty::substs) { @@ -336,7 +336,7 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { let fcx = pcx.fcx; let tcx = pcx.fcx.ccx.tcx; - match /*bad*/copy pat.node { + match pat.node { ast::pat_wild => { fcx.write_ty(pat.id, expected); } @@ -409,22 +409,22 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { } } ast::pat_ident(_, path, _) => { - check_pat_variant(pcx, pat, path, Some(~[]), expected); + check_pat_variant(pcx, pat, path, &Some(~[]), expected); } - ast::pat_enum(path, subpats) => { + ast::pat_enum(path, ref subpats) => { check_pat_variant(pcx, pat, path, subpats, expected); } - ast::pat_struct(path, fields, etc) => { + ast::pat_struct(path, ref fields, etc) => { // Grab the class data that we care about. let structure = structure_of(fcx, pat.span, expected); match structure { ty::ty_struct(cid, ref substs) => { check_struct_pat(pcx, pat.id, pat.span, expected, path, - fields, etc, cid, substs); + *fields, etc, cid, substs); } ty::ty_enum(eid, ref substs) => { check_struct_like_enum_variant_pat( - pcx, pat.id, pat.span, expected, path, fields, etc, eid, + pcx, pat.id, pat.span, expected, path, *fields, etc, eid, substs); } _ => { @@ -439,9 +439,10 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { // Finally, write in the type. fcx.write_ty(pat.id, expected); } - ast::pat_tup(elts) => { - let ex_elts = match structure_of(fcx, pat.span, expected) { - ty::ty_tup(elts) => elts, + ast::pat_tup(ref elts) => { + let s = structure_of(fcx, pat.span, expected); + let ex_elts = match s { + ty::ty_tup(ref elts) => elts, _ => { tcx.sess.span_fatal (pat.span, @@ -449,12 +450,12 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { fcx.infcx().ty_to_str(expected))); } }; - let e_count = vec::len(elts); - if e_count != vec::len(ex_elts) { + let e_count = elts.len(); + if e_count != ex_elts.len() { tcx.sess.span_fatal (pat.span, fmt!("mismatched types: expected a tuple \ with %u fields, found one with %u \ - fields", vec::len(ex_elts), e_count)); + fields", ex_elts.len(), e_count)); } let mut i = 0u; for elts.each |elt| { @@ -509,7 +510,7 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { } } } - ast::pat_vec(before, slice, after) => { + ast::pat_vec(ref before, slice, ref after) => { let default_region_var = fcx.infcx().next_region_var_with_lb( pat.span, pcx.block_region diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 604a753c448..63a210f84eb 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -1051,7 +1051,7 @@ pub impl LookupContext/&self { let mut j = i + 1; while j < candidates.len() { - let candidate_b = /*bad*/copy candidates[j]; + let candidate_b = &candidates[j]; debug!("attempting to merge %? and %?", candidate_a, candidate_b); let candidates_same = match (&candidate_a.origin, diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 7a1beeca513..2d35fc17ede 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -577,18 +577,18 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) { ty::item_path_str(ccx.tcx, local_def(it.id))); let _indenter = indenter(); - match /*bad*/copy it.node { + match it.node { ast::item_const(_, e) => check_const(ccx, it.span, e, it.id), ast::item_enum(ref enum_definition, _) => { check_enum_variants(ccx, it.span, - /*bad*/copy (*enum_definition).variants, + enum_definition.variants, it.id); } ast::item_fn(ref decl, _, _, ref body) => { check_bare_fn(ccx, decl, body, it.id, None); } - ast::item_impl(_, _, ty, ms) => { + ast::item_impl(_, _, ty, ref ms) => { let rp = ccx.tcx.region_paramd_items.find(&it.id); debug!("item_impl %s with id %d rp %?", *ccx.tcx.sess.str_of(it.ident), it.id, rp); @@ -617,7 +617,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) { let tpt_ty = ty::node_id_to_type(ccx.tcx, it.id); check_bounds_are_used(ccx, t.span, &generics.ty_params, tpt_ty); } - ast::item_foreign_mod(m) => { + ast::item_foreign_mod(ref m) => { if syntax::attr::foreign_abi(it.attrs) == either::Right(ast::foreign_abi_rust_intrinsic) { for m.items.each |item| { @@ -1157,7 +1157,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, call_expr_id: ast::node_id, in_fty: ty::t, callee_expr: @ast::expr, - args: ~[@ast::expr], + args: &[@ast::expr], sugar: ast::CallSugar, deref_args: DerefArgs) -> (ty::t, bool) { @@ -1309,7 +1309,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, call_expr_id: ast::node_id, fn_ty: ty::t, expr: @ast::expr, - +args: ~[@ast::expr], + args: &[@ast::expr], bot: bool, sugar: ast::CallSugar) -> bool { @@ -1331,14 +1331,14 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, sp: span, call_expr_id: ast::node_id, f: @ast::expr, - +args: ~[@ast::expr], + args: &[@ast::expr], sugar: ast::CallSugar) -> bool { // Index expressions need to be handled separately, to inform them // that they appear in call position. - let mut bot = match /*bad*/copy f.node { - ast::expr_field(base, field, tys) => { - check_field(fcx, f, true, base, field, tys) + let mut bot = match f.node { + ast::expr_field(base, field, ref tys) => { + check_field(fcx, f, true, base, field, *tys) } _ => check_expr(fcx, f) }; @@ -1358,8 +1358,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, expr: @ast::expr, rcvr: @ast::expr, method_name: ast::ident, - +args: ~[@ast::expr], - tps: ~[@ast::Ty], + args: &[@ast::expr], + tps: &[@ast::Ty], sugar: ast::CallSugar) -> bool { let bot = check_expr(fcx, rcvr); @@ -1594,7 +1594,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fn check_user_unop(fcx: @mut FnCtxt, op_str: ~str, - mname: ~str, + +mname: ~str, ex: @ast::expr, rhs_expr: @ast::expr, rhs_t: ty::t) @@ -1603,7 +1603,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, ex, rhs_expr, rhs_t, - fcx.tcx().sess.ident_of(/*bad*/ copy mname), + fcx.tcx().sess.ident_of(mname), ~[], DontDerefArgs, DontAutoderefReceiver) { @@ -1713,7 +1713,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, is_callee: bool, base: @ast::expr, field: ast::ident, - tys: ~[@ast::Ty]) + tys: &[@ast::Ty]) -> bool { let tcx = fcx.ccx.tcx; let bot = check_expr(fcx, base); @@ -1791,8 +1791,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, span: span, class_id: ast::def_id, substitutions: &ty::substs, - field_types: ~[ty::field_ty], - ast_fields: ~[ast::field], + field_types: &[ty::field_ty], + ast_fields: &[ast::field], check_completeness: bool) -> bool { let tcx = fcx.ccx.tcx; @@ -1870,7 +1870,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, id: ast::node_id, span: codemap::span, class_id: ast::def_id, - fields: ~[ast::field], + fields: &[ast::field], base_expr: Option<@ast::expr>) -> bool { let mut bot = false; @@ -1955,7 +1955,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, span: codemap::span, enum_id: ast::def_id, variant_id: ast::def_id, - fields: ~[ast::field]) + fields: &[ast::field]) -> bool { let mut bot = false; let tcx = fcx.ccx.tcx; @@ -2147,14 +2147,14 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, let tcx = fcx.ccx.tcx; let id = expr.id; let mut bot = false; - match /*bad*/copy expr.node { + match expr.node { ast::expr_vstore(ev, vst) => { - let typ = match /*bad*/copy ev.node { + let typ = match ev.node { ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => { let tt = ast_expr_vstore_to_vstore(fcx, ev, str::len(*s), vst); ty::mk_estr(tcx, tt) } - ast::expr_vec(args, mutbl) => { + ast::expr_vec(ref args, mutbl) => { let tt = ast_expr_vstore_to_vstore(fcx, ev, args.len(), vst); let mutability; match vst { @@ -2317,7 +2317,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, let region_lb = ty::re_scope(expr.id); instantiate_path(fcx, pth, tpt, expr.span, expr.id, region_lb); } - ast::expr_inline_asm(_, ins, outs, _, _, _) => { + ast::expr_inline_asm(_, ref ins, ref outs, _, _, _) => { fcx.require_unsafe(expr.span, ~"use of inline assembly"); for ins.each |&(_, in)| { @@ -2389,7 +2389,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, bot = !may_break(tcx, expr.id, body); } ast::expr_match(discrim, ref arms) => { - bot = _match::check_match(fcx, expr, discrim, (/*bad*/copy *arms)); + bot = _match::check_match(fcx, expr, discrim, *arms); } ast::expr_fn_block(ref decl, ref body) => { check_expr_fn(fcx, expr, None, @@ -2441,11 +2441,11 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, }; fcx.write_ty(id, typ); } - ast::expr_call(f, args, sugar) => { - bot = check_call(fcx, expr.span, expr.id, f, args, sugar); + ast::expr_call(f, ref args, sugar) => { + bot = check_call(fcx, expr.span, expr.id, f, *args, sugar); } - ast::expr_method_call(rcvr, ident, tps, args, sugar) => { - bot = check_method_call(fcx, expr, rcvr, ident, args, tps, sugar); + ast::expr_method_call(rcvr, ident, ref tps, ref args, sugar) => { + bot = check_method_call(fcx, expr, rcvr, ident, *args, *tps, sugar); } ast::expr_cast(e, t) => { bot = check_expr(fcx, e); @@ -2528,7 +2528,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } fcx.write_ty(id, t_1); } - ast::expr_vec(args, mutbl) => { + ast::expr_vec(ref args, mutbl) => { let t: ty::t = fcx.infcx().next_ty_var(); for args.each |e| { bot |= check_expr_has_type(fcx, *e, t); } let typ = ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutbl}, @@ -2544,7 +2544,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, ty::vstore_fixed(count)); fcx.write_ty(id, t); } - ast::expr_tup(elts) => { + ast::expr_tup(ref elts) => { let flds = unpack_expected(fcx, expected, |sty| { match *sty { ty::ty_tup(ref flds) => Some(copy *flds), _ => None } }); @@ -2560,11 +2560,11 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, match tcx.def_map.find(&id) { Some(ast::def_struct(type_def_id)) => { check_struct_constructor(fcx, id, expr.span, type_def_id, - (/*bad*/copy *fields), base_expr); + *fields, base_expr); } Some(ast::def_variant(enum_id, variant_id)) => { check_struct_enum_variant(fcx, id, expr.span, enum_id, - variant_id, (/*bad*/copy *fields)); + variant_id, *fields); } _ => { tcx.sess.span_bug(path.span, ~"structure constructor does \ @@ -2572,8 +2572,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } } } - ast::expr_field(base, field, tys) => { - bot = check_field(fcx, expr, false, base, field, tys); + ast::expr_field(base, field, ref tys) => { + bot = check_field(fcx, expr, false, base, field, *tys); } ast::expr_index(base, idx) => { bot |= check_expr(fcx, base); @@ -2678,8 +2678,8 @@ pub fn check_stmt(fcx: @mut FnCtxt, stmt: @ast::stmt) -> bool { match stmt.node { ast::stmt_decl(decl, id) => { node_id = id; - match /*bad*/copy decl.node { - ast::decl_local(ls) => for ls.each |l| { + match decl.node { + ast::decl_local(ref ls) => for ls.each |l| { bot |= check_decl_local(fcx, *l); }, ast::decl_item(_) => {/* ignore for now */ } @@ -2803,11 +2803,11 @@ pub fn check_instantiable(tcx: ty::ctxt, pub fn check_enum_variants(ccx: @mut CrateCtxt, sp: span, - +vs: ~[ast::variant], + vs: &[ast::variant], id: ast::node_id) { fn do_check(ccx: @mut CrateCtxt, sp: span, - vs: ~[ast::variant], + vs: &[ast::variant], id: ast::node_id, disr_vals: &mut ~[int], disr_val: &mut int, @@ -2867,7 +2867,7 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt, arg_tys = None; do_check(ccx, sp, - /*bad*/copy vs, + vs, id, &mut *disr_vals, &mut *disr_val, diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 6871496a805..e0441d2e544 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -192,7 +192,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) { } } - match /*bad*/copy expr.node { + match expr.node { ast::expr_path(*) => { // Avoid checking the use of local variables, as we // already check their definitions. The def'n always @@ -207,7 +207,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) { } } - ast::expr_call(callee, args, _) => { + ast::expr_call(callee, ref args, _) => { // Check for a.b() where b is a method. Ensure that // any types in the callee are valid for the entire // method call. @@ -236,7 +236,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) { } } - ast::expr_method_call(rcvr, _, _, args, _) => { + ast::expr_method_call(rcvr, _, _, ref args, _) => { // Check for a.b() where b is a method. Ensure that // any types in the callee are valid for the entire // method call. diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 699b8ad74e4..620d64fd58e 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -610,7 +610,7 @@ pub impl CoherenceChecker { fn check_privileged_scopes(self, crate: @crate) { visit_crate(*crate, (), mk_vt(@Visitor { visit_item: |item, _context, visitor| { - match /*bad*/copy item.node { + match item.node { item_mod(ref module_) => { // Then visit the module items. visit_mod(module_, item.span, item.id, (), visitor); @@ -738,8 +738,8 @@ pub impl CoherenceChecker { } } - match /*bad*/copy item.node { - item_impl(_, trait_refs, _, ast_methods) => { + match item.node { + item_impl(_, ref trait_refs, _, ref ast_methods) => { let mut methods = ~[]; for ast_methods.each |ast_method| { methods.push(method_to_MethodInfo(*ast_method)); diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index b9aac4b19ed..a6626d5c4ed 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -228,9 +228,9 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, trait_ty: ty::t) { fn store_methods(ccx: &CrateCtxt, id: ast::node_id, - stuff: ~[T], + stuff: &[T], f: &fn(v: &T) -> ty::method) { - ty::store_trait_methods(ccx.tcx, id, @vec::map(stuff, f)); + ty::store_trait_methods(ccx.tcx, id, @stuff.map(f)); } fn make_static_method_ty(ccx: &CrateCtxt, @@ -285,7 +285,7 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, node: ast::item_trait(ref generics, _, ref ms), _ }, _) => { - store_methods::(ccx, id, (/*bad*/copy *ms), |m| { + store_methods::(ccx, id, *ms, |m| { let def_id; match *m { ast::required(ref ty_method) => { @@ -502,7 +502,7 @@ pub fn check_methods_against_trait(ccx: &CrateCtxt, rp: Option, selfty: ty::t, a_trait_ty: @ast::trait_ref, - impl_ms: ~[ConvertedMethod]) { + impl_ms: &[ConvertedMethod]) { let tcx = ccx.tcx; let (did, tpt) = instantiate_trait_ref(ccx, a_trait_ty, rp); @@ -643,8 +643,7 @@ pub fn convert(ccx: &CrateCtxt, it: @ast::item) { // XXX: Bad copy of `ms` below. let cms = convert_methods(ccx, *ms, rp, i_bounds); for trait_ref.each |t| { - check_methods_against_trait(ccx, generics, rp, selfty, - *t, /*bad*/copy cms); + check_methods_against_trait(ccx, generics, rp, selfty, *t, cms); } } ast::item_trait(ref generics, ref supertraits, ref trait_methods) => { @@ -656,7 +655,7 @@ pub fn convert(ccx: &CrateCtxt, it: @ast::item) { ensure_supertraits(ccx, it.id, it.span, rp, *supertraits); let (_, provided_methods) = - split_trait_methods(/*bad*/copy *trait_methods); + split_trait_methods(*trait_methods); let (bounds, _) = mk_substs(ccx, generics, rp); let _ = convert_methods(ccx, provided_methods, rp, bounds); } diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index 3ec4fcb6d2e..8b128dbc5c5 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -82,7 +82,7 @@ pub trait Combine { fn lub(&self) -> Lub; fn glb(&self) -> Glb; - fn mts(&self, a: ty::mt, b: ty::mt) -> cres; + fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres; fn contratys(&self, a: ty::t, b: ty::t) -> cres; fn tys(&self, a: ty::t, b: ty::t) -> cres; fn tps(&self, as_: &[ty::t], bs: &[ty::t]) -> cres<~[ty::t]>; @@ -305,7 +305,7 @@ pub fn super_flds( self: &C, a: ty::field, b: ty::field) -> cres { if a.ident == b.ident { - self.mts(a.mt, b.mt) + self.mts(&a.mt, &b.mt) .chain(|mt| Ok(ty::field {ident: a.ident, mt: mt}) ) .chain_err(|e| Err(ty::terr_in_field(@e, a.ident)) ) } else { @@ -419,8 +419,8 @@ pub fn super_fn_sigs( self: &C, a_f: &ty::FnSig, b_f: &ty::FnSig) -> cres { fn argvecs(self: &C, - +a_args: ~[ty::arg], - +b_args: ~[ty::arg]) -> cres<~[ty::arg]> + a_args: &[ty::arg], + b_args: &[ty::arg]) -> cres<~[ty::arg]> { if vec::same_length(a_args, b_args) { map_vec2(a_args, b_args, |a, b| self.args(*a, *b)) @@ -429,7 +429,7 @@ pub fn super_fn_sigs( } } - do argvecs(self, /*bad*/copy a_f.inputs, /*bad*/copy b_f.inputs) + do argvecs(self, a_f.inputs, b_f.inputs) .chain |inputs| { do self.tys(a_f.output, b_f.output).chain |output| { Ok(FnSig {inputs: /*bad*/copy inputs, output: output}) @@ -509,7 +509,7 @@ pub fn super_tys( } } - (ty::ty_param(a_p), ty::ty_param(b_p)) if a_p.idx == b_p.idx => { + (ty::ty_param(ref a_p), ty::ty_param(ref b_p)) if a_p.idx == b_p.idx => { Ok(a) } @@ -538,31 +538,31 @@ pub fn super_tys( } } - (ty::ty_box(a_mt), ty::ty_box(b_mt)) => { + (ty::ty_box(ref a_mt), ty::ty_box(ref b_mt)) => { do self.mts(a_mt, b_mt).chain |mt| { Ok(ty::mk_box(tcx, mt)) } } - (ty::ty_uniq(a_mt), ty::ty_uniq(b_mt)) => { + (ty::ty_uniq(ref a_mt), ty::ty_uniq(ref b_mt)) => { do self.mts(a_mt, b_mt).chain |mt| { Ok(ty::mk_uniq(tcx, mt)) } } - (ty::ty_ptr(a_mt), ty::ty_ptr(b_mt)) => { + (ty::ty_ptr(ref a_mt), ty::ty_ptr(ref b_mt)) => { do self.mts(a_mt, b_mt).chain |mt| { Ok(ty::mk_ptr(tcx, mt)) } } - (ty::ty_rptr(a_r, a_mt), ty::ty_rptr(b_r, b_mt)) => { + (ty::ty_rptr(a_r, ref a_mt), ty::ty_rptr(b_r, ref b_mt)) => { let r = if_ok!(self.contraregions(a_r, b_r)); let mt = if_ok!(self.mts(a_mt, b_mt)); Ok(ty::mk_rptr(tcx, r, mt)) } - (ty::ty_evec(a_mt, vs_a), ty::ty_evec(b_mt, vs_b)) => { + (ty::ty_evec(ref a_mt, vs_a), ty::ty_evec(ref b_mt, vs_b)) => { do self.mts(a_mt, b_mt).chain |mt| { do self.vstores(ty::terr_vec, vs_a, vs_b).chain |vs| { Ok(ty::mk_evec(tcx, mt, vs)) @@ -576,9 +576,9 @@ pub fn super_tys( } } - (ty::ty_tup(as_), ty::ty_tup(bs)) => { - if vec::same_length(as_, bs) { - map_vec2(as_, bs, |a, b| self.tys(*a, *b) ) + (ty::ty_tup(ref as_), ty::ty_tup(ref bs)) => { + if as_.len() == bs.len() { + map_vec2(*as_, *bs, |a, b| self.tys(*a, *b) ) .chain(|ts| Ok(ty::mk_tup(tcx, ts)) ) } else { Err(ty::terr_tuple_size( diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index ff13f7ee576..55bfa9888c0 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -41,7 +41,7 @@ impl Combine for Glb { fn lub(&self) -> Lub { Lub(**self) } fn glb(&self) -> Glb { Glb(**self) } - fn mts(&self, a: ty::mt, b: ty::mt) -> cres { + fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres { let tcx = self.infcx.tcx; debug!("%s.mts(%s, %s)", diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 933ad44a79e..59cc15dfc02 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -47,7 +47,7 @@ impl Combine for Lub { fn lub(&self) -> Lub { Lub(**self) } fn glb(&self) -> Glb { Glb(**self) } - fn mts(&self, a: ty::mt, b: ty::mt) -> cres { + fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres { let tcx = self.infcx.tcx; debug!("%s.mts(%s, %s)", diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index bcbe08c2881..1d9594d930c 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -150,7 +150,7 @@ pub impl ResolveState { return typ; } - match /*bad*/ copy ty::get(typ).sty { + match ty::get(typ).sty { ty::ty_infer(TyVar(vid)) => { self.resolve_ty_var(vid) } diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 580aefe5b1a..561fabd9d70 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -69,7 +69,7 @@ impl Combine for Sub { } } - fn mts(&self, a: ty::mt, b: ty::mt) -> cres { + fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres { debug!("mts(%s <: %s)", a.inf_str(self.infcx), b.inf_str(self.infcx)); if a.mutbl != b.mutbl && b.mutbl != m_const { @@ -80,11 +80,11 @@ impl Combine for Sub { m_mutbl => { // If supertype is mut, subtype must match exactly // (i.e., invariant if mut): - eq_tys(self, a.ty, b.ty).then(|| Ok(a) ) + eq_tys(self, a.ty, b.ty).then(|| Ok(copy *a) ) } m_imm | m_const => { // Otherwise we can be covariant: - self.tys(a.ty, b.ty).chain(|_t| Ok(a) ) + self.tys(a.ty, b.ty).chain(|_t| Ok(copy *a) ) } } } diff --git a/src/librustc/middle/typeck/infer/to_str.rs b/src/librustc/middle/typeck/infer/to_str.rs index a9ad54aea8b..7a28e7d1607 100644 --- a/src/librustc/middle/typeck/infer/to_str.rs +++ b/src/librustc/middle/typeck/infer/to_str.rs @@ -43,7 +43,7 @@ impl InferStr for FnSig { impl InferStr for ty::mt { fn inf_str(&self, cx: &InferCtxt) -> ~str { - mt_to_str(cx.tcx, *self) + mt_to_str(cx.tcx, self) } } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 77258d0b329..d8636470555 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -218,7 +218,7 @@ pub fn region_to_str_space(cx: ctxt, prefix: &str, region: Region) -> ~str { } } -pub fn mt_to_str(cx: ctxt, m: mt) -> ~str { +pub fn mt_to_str(cx: ctxt, m: &mt) -> ~str { let mstr = match m.mutbl { ast::m_mutbl => "mut ", ast::m_imm => "", @@ -391,7 +391,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { &m.fty.sig) + ~";" } fn field_to_str(cx: ctxt, f: field) -> ~str { - return *cx.sess.str_of(f.ident) + ~": " + mt_to_str(cx, f.mt); + return *cx.sess.str_of(f.ident) + ~": " + mt_to_str(cx, &f.mt); } // if there is an id, print that instead of the structural type: @@ -402,7 +402,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { }*/ // pretty print the structural type representation: - return match /*bad*/copy ty::get(typ).sty { + return match ty::get(typ).sty { ty_nil => ~"()", ty_bot => ~"!", ty_bool => ~"bool", @@ -413,15 +413,15 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { ty_uint(t) => ast_util::uint_ty_to_str(t), ty_float(ast::ty_f) => ~"float", ty_float(t) => ast_util::float_ty_to_str(t), - ty_box(tm) => ~"@" + mt_to_str(cx, tm), - ty_uniq(tm) => ~"~" + mt_to_str(cx, tm), - ty_ptr(tm) => ~"*" + mt_to_str(cx, tm), - ty_rptr(r, tm) => { + ty_box(ref tm) => ~"@" + mt_to_str(cx, tm), + ty_uniq(ref tm) => ~"~" + mt_to_str(cx, tm), + ty_ptr(ref tm) => ~"*" + mt_to_str(cx, tm), + ty_rptr(r, ref tm) => { region_to_str_space(cx, ~"&", r) + mt_to_str(cx, tm) } - ty_unboxed_vec(tm) => { ~"unboxed_vec<" + mt_to_str(cx, tm) + ~">" } + ty_unboxed_vec(ref tm) => { ~"unboxed_vec<" + mt_to_str(cx, tm) + ~">" } ty_type => ~"type", - ty_tup(elems) => { + ty_tup(ref elems) => { let strs = elems.map(|elem| ty_to_str(cx, *elem)); ~"(" + str::connect(strs, ~",") + ~")" } @@ -455,7 +455,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { let ty = parameterized(cx, base, substs.self_r, substs.tps); fmt!("%s%s", trait_store_to_str(cx, s), ty) } - ty_evec(mt, vs) => { + ty_evec(ref mt, vs) => { vstore_ty_to_str(cx, fmt!("%s", mt_to_str(cx, mt)), vs) } ty_estr(vs) => fmt!("%s%s", vstore_to_str(cx, vs), ~"str"),