From 366a233dbda597192b5ad027fe79f58331bc1bed Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 20 Jun 2013 15:15:03 -0400 Subject: syntax: Patch up code that was using irrefutable patterns incorrectly --- src/libsyntax/ext/deriving/generic.rs | 28 ++++++++++++++++++---------- src/libsyntax/ext/pipes/proto.rs | 4 ++-- 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 01769482d08..d3554d6b27c 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -589,7 +589,7 @@ impl<'self> MethodDef<'self> { // transpose raw_fields let fields = match raw_fields { - [self_arg, .. rest] => { + [ref self_arg, .. rest] => { do self_arg.iter().enumerate().transform |(i, &(opt_id, field))| { let other_fields = do rest.map |l| { match &l[i] { @@ -738,16 +738,20 @@ impl<'self> MethodDef<'self> { let mut enum_matching_fields = vec::from_elem(self_vec.len(), ~[]); - for matches_so_far.tail().iter().advance |&(_, _, other_fields)| { - for other_fields.iter().enumerate().advance |(i, &(_, other_field))| { - enum_matching_fields[i].push(other_field); + for matches_so_far.tail().iter().advance |triple| { + match triple { + &(_, _, ref other_fields) => { + for other_fields.iter().enumerate().advance |(i, pair)| { + enum_matching_fields[i].push(pair.second()); + } + } } } let field_tuples = do self_vec.iter() .zip(enum_matching_fields.iter()) - .transform |(&(id, self_f), &other)| { - (id, self_f, other) + .transform |(&(id, self_f), other)| { + (id, self_f, copy *other) }.collect(); substructure = EnumMatching(variant_index, variant, field_tuples); } @@ -1015,7 +1019,8 @@ left-to-right (`true`) or right-to-left (`false`). pub fn cs_fold(use_foldl: bool, f: &fn(@ExtCtxt, span, old: @expr, - self_f: @expr, other_fs: &[@expr]) -> @expr, + self_f: @expr, + other_fs: &[@expr]) -> @expr, base: @expr, enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: span, @@ -1023,11 +1028,13 @@ pub fn cs_fold(use_foldl: bool, match *substructure.fields { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { if use_foldl { - do all_fields.iter().fold(base) |old, &(_, self_f, other_fs)| { + do all_fields.iter().fold(base) |old, triple| { + let (_, self_f, other_fs) = copy *triple; f(cx, span, old, self_f, other_fs) } } else { - do all_fields.rev_iter().fold(base) |old, &(_, self_f, other_fs)| { + do all_fields.rev_iter().fold(base) |old, triple| { + let (_, self_f, other_fs) = copy *triple; f(cx, span, old, self_f, other_fs) } } @@ -1059,7 +1066,8 @@ pub fn cs_same_method(f: &fn(@ExtCtxt, span, ~[@expr]) -> @expr, match *substructure.fields { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { // call self_n.method(other_1_n, other_2_n, ...) - let called = do all_fields.map |&(_, self_field, other_fields)| { + let called = do all_fields.map |triple| { + let (_, self_field, other_fields) = copy *triple; cx.expr_method_call(span, self_field, substructure.method_ident, diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 2fe8456c274..75424b60390 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -215,8 +215,8 @@ pub fn visit>( // the copy keywords prevent recursive use of dvec let states: ~[Tstate] = do (copy proto.states).iter().transform |&s| { - let messages: ~[Tmessage] = do (copy s.messages).iter().transform |&m| { - let message(name, span, tys, this, next) = m; + let messages: ~[Tmessage] = do (copy s.messages).iter().transform |m| { + let message(name, span, tys, this, next) = copy *m; visitor.visit_message(name, span, tys, this, next) }.collect(); visitor.visit_state(s, messages) -- cgit 1.4.1-3-g733a5 From 50e95ea481af78516e3852687bc63d6d1a94dcd0 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 21 Jun 2013 12:19:22 -0400 Subject: Fix pretty printer, which was ignoring `ref` in irrefutable patterns --- src/libsyntax/print/pprust.rs | 61 ++++++++++----------------- src/test/bench/shootout-k-nucleotide-pipes.rs | 4 +- src/test/run-pass-fulldeps/qquote.rs | 2 +- 3 files changed, 26 insertions(+), 41 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index b545c56778e..73ee8768ca3 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -147,7 +147,7 @@ pub fn ty_to_str(ty: &ast::Ty, intr: @ident_interner) -> ~str { } pub fn pat_to_str(pat: &ast::pat, intr: @ident_interner) -> ~str { - to_str(pat, print_irrefutable_pat, intr) + to_str(pat, print_pat, intr) } pub fn expr_to_str(e: &ast::expr, intr: @ident_interner) -> ~str { @@ -1240,7 +1240,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { if first { first = false; } else { space(s.s); word_space(s, "|"); } - print_refutable_pat(s, *p); + print_pat(s, *p); } space(s.s); match arm.guard { @@ -1434,7 +1434,7 @@ pub fn print_expr(s: @ps, expr: &ast::expr) { } pub fn print_local_decl(s: @ps, loc: &ast::local) { - print_irrefutable_pat(s, loc.node.pat); + print_pat(s, loc.node.pat); match loc.node.ty.node { ast::ty_infer => (), _ => { word_space(s, ":"); print_type(s, &loc.node.ty); } @@ -1521,20 +1521,7 @@ pub fn print_path(s: @ps, path: &ast::Path, colons_before_params: bool) { print_path_(s, path, colons_before_params, &None) } -pub fn print_bounded_path(s: @ps, path: &ast::Path, - bounds: &Option>) { - print_path_(s, path, false, bounds) -} - -pub fn print_irrefutable_pat(s: @ps, pat: &ast::pat) { - print_pat(s, pat, false) -} - -pub fn print_refutable_pat(s: @ps, pat: &ast::pat) { - print_pat(s, pat, true) -} - -pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) { +pub fn print_pat(s: @ps, pat: &ast::pat) { maybe_print_comment(s, pat.span.lo); let ann_node = node_pat(s, pat); (s.ann.pre)(ann_node); @@ -1543,20 +1530,18 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) { match pat.node { ast::pat_wild => word(s.s, "_"), ast::pat_ident(binding_mode, ref path, sub) => { - if refutable { - match binding_mode { - ast::bind_by_ref(mutbl) => { - word_nbsp(s, "ref"); - print_mutability(s, mutbl); - } - ast::bind_infer => {} + match binding_mode { + ast::bind_by_ref(mutbl) => { + word_nbsp(s, "ref"); + print_mutability(s, mutbl); } + ast::bind_infer => {} } print_path(s, path, true); match sub { Some(p) => { word(s.s, "@"); - print_pat(s, p, refutable); + print_pat(s, p); } None => () } @@ -1569,7 +1554,7 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) { if !args.is_empty() { popen(s); commasep(s, inconsistent, *args, - |s, &p| print_pat(s, p, refutable)); + |s, &p| print_pat(s, p)); pclose(s); } else { } } @@ -1578,16 +1563,16 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) { ast::pat_struct(ref path, ref fields, etc) => { print_path(s, path, true); word(s.s, "{"); - fn print_field(s: @ps, f: &ast::field_pat, refutable: bool) { + fn print_field(s: @ps, f: &ast::field_pat) { cbox(s, indent_unit); print_ident(s, f.ident); word_space(s, ":"); - print_pat(s, f.pat, refutable); + print_pat(s, f.pat); end(s); } fn get_span(f: &ast::field_pat) -> codemap::span { return f.pat.span; } commasep_cmnt(s, consistent, *fields, - |s, f| print_field(s,f,refutable), + |s, f| print_field(s,f), get_span); if etc { if fields.len() != 0u { word_space(s, ","); } @@ -1597,7 +1582,7 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) { } ast::pat_tup(ref elts) => { popen(s); - commasep(s, inconsistent, *elts, |s, &p| print_pat(s, p, refutable)); + commasep(s, inconsistent, *elts, |s, &p| print_pat(s, p)); if elts.len() == 1 { word(s.s, ","); } @@ -1605,15 +1590,15 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) { } ast::pat_box(inner) => { word(s.s, "@"); - print_pat(s, inner, refutable); + print_pat(s, inner); } ast::pat_uniq(inner) => { word(s.s, "~"); - print_pat(s, inner, refutable); + print_pat(s, inner); } ast::pat_region(inner) => { word(s.s, "&"); - print_pat(s, inner, refutable); + print_pat(s, inner); } ast::pat_lit(e) => print_expr(s, e), ast::pat_range(begin, end) => { @@ -1625,16 +1610,16 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) { ast::pat_vec(ref before, slice, ref after) => { word(s.s, "["); do commasep(s, inconsistent, *before) |s, &p| { - print_pat(s, p, refutable); + print_pat(s, p); } for slice.iter().advance |&p| { if !before.is_empty() { word_space(s, ","); } word(s.s, ".."); - print_pat(s, p, refutable); + print_pat(s, p); if !after.is_empty() { word_space(s, ","); } } do commasep(s, inconsistent, *after) |s, &p| { - print_pat(s, p, refutable); + print_pat(s, p); } word(s.s, "]"); } @@ -1888,7 +1873,7 @@ pub fn print_arg(s: @ps, input: &ast::arg) { word_space(s, "mut"); } match input.ty.node { - ast::ty_infer => print_irrefutable_pat(s, input.pat), + ast::ty_infer => print_pat(s, input.pat), _ => { match input.pat.node { ast::pat_ident(_, ref path, _) if @@ -1897,7 +1882,7 @@ pub fn print_arg(s: @ps, input: &ast::arg) { // Do nothing. } _ => { - print_irrefutable_pat(s, input.pat); + print_pat(s, input.pat); word(s.s, ":"); space(s.s); } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 974cdb0a0ef..919c4daeb25 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -56,8 +56,8 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str { let mut pairs = ~[]; // map -> [(k,%)] - for mm.iter().advance |(&key, &val)| { - pairs.push((key, pct(val, total))); + for mm.iter().advance |(key, &val)| { + pairs.push((copy *key, pct(val, total))); } let pairs_sorted = sortKV(pairs); diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 9a3ba32390c..92344aae73e 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -68,7 +68,7 @@ fn main() { check_pp(ext_cx, *stmt, pprust::print_stmt, ~"let x = 20;"); let pat = quote_pat!(Some(_)); - check_pp(ext_cx, pat, pprust::print_refutable_pat, ~"Some(_)"); + check_pp(ext_cx, pat, pprust::print_pat, ~"Some(_)"); } -- cgit 1.4.1-3-g733a5 From 979d3a54f9e1eea483734059a2f594278787e16a Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 24 Jun 2013 13:30:35 -0400 Subject: Correct merge failures --- src/libextra/fileinput.rs | 2 +- src/libextra/num/bigint.rs | 2 +- src/libextra/term.rs | 4 +- src/librustc/middle/borrowck/gather_loans/mod.rs | 2 +- src/librustc/middle/moves.rs | 11 +--- src/librustc/middle/trans/_match.rs | 9 ++-- src/librustc/middle/trans/base.rs | 60 +++------------------- src/librustc/middle/trans/callee.rs | 5 +- src/librustc/middle/trans/meth.rs | 3 +- src/libstd/vec.rs | 6 +-- src/libsyntax/print/pprust.rs | 7 ++- .../borrowck-move-out-of-struct-with-dtor.rs | 2 +- .../borrowck-move-out-of-tuple-struct-with-dtor.rs | 2 +- src/test/run-pass/reflect-visit-type.rs | 4 +- 14 files changed, 34 insertions(+), 85 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libextra/fileinput.rs b/src/libextra/fileinput.rs index de6edd54094..27c8051afac 100644 --- a/src/libextra/fileinput.rs +++ b/src/libextra/fileinput.rs @@ -418,7 +418,7 @@ mod test { fn make_file(path : &Path, contents: &[~str]) { let file = io::file_writer(path, [io::Create, io::Truncate]).get(); - for contents.iter().advance |&str| { + for contents.iter().advance |str| { file.write_str(*str); file.write_char('\n'); } diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs index 91842474899..5867b13f556 100644 --- a/src/libextra/num/bigint.rs +++ b/src/libextra/num/bigint.rs @@ -1586,7 +1586,7 @@ mod biguint_tests { let &(ref n, ref rs) = num_pair; for rs.iter().advance |str_pair| { let &(ref radix, ref str) = str_pair; - assert_eq!(&n, &FromStrRadix::from_str_radix(*str, *radix).get()); + assert_eq!(n, &FromStrRadix::from_str_radix(*str, *radix).get()); } } diff --git a/src/libextra/term.rs b/src/libextra/term.rs index 55626622775..cd226e2ad32 100644 --- a/src/libextra/term.rs +++ b/src/libextra/term.rs @@ -119,8 +119,8 @@ impl Terminal { pub fn reset(&self) { let mut vars = Variables::new(); let s = do self.ti.strings.find_equiv(&("op")) - .map_consume_default(Err(~"can't find terminfo capability `op`")) |&op| { - expand(op, [], &mut vars) + .map_consume_default(Err(~"can't find terminfo capability `op`")) |op| { + expand(copy *op, [], &mut vars) }; if s.is_ok() { self.out.write(s.unwrap()); diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index 86baf535284..23451e0f36e 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -617,7 +617,7 @@ impl GatherLoanCtxt { */ let mc_ctxt = self.bccx.mc_ctxt(); - for decl.inputs.each |arg| { + for decl.inputs.iter().advance |arg| { let arg_ty = ty::node_id_to_type(self.tcx(), arg.pat.id); let arg_cmt = mc_ctxt.cat_rvalue( diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index e9a73a513c8..07bdee07c0f 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -190,15 +190,8 @@ enum UseMode { pub fn compute_moves(tcx: ty::ctxt, method_map: method_map, -<<<<<<< HEAD crate: &crate) -> MoveMaps { -||||||| merged common ancestors - crate: @crate) -> MoveMaps -{ -======= - crate: @crate) -> MoveMaps { ->>>>>>> Modify borrow checker to visit irrefutable patterns that appear in let visitor = visit::mk_vt(@visit::Visitor { visit_fn: compute_modes_for_fn, visit_expr: compute_modes_for_expr, @@ -248,7 +241,7 @@ fn compute_modes_for_fn(fk: &visit::fn_kind, id: node_id, (cx, v): (VisitContext, vt)) { - for decl.inputs.each |a| { + for decl.inputs.iter().advance |a| { cx.use_pat(a.pat); } visit::visit_fn(fk, decl, body, span, id, (cx, v)); @@ -554,7 +547,7 @@ impl VisitContext { } expr_fn_block(ref decl, ref body) => { - for decl.inputs.each |a| { + for decl.inputs.iter().advance |a| { self.use_pat(a.pat); } let cap_vars = self.compute_captures(expr.id); diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index f5bb075aafc..74f1e372c07 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1738,7 +1738,7 @@ pub fn store_local(bcx: block, * Generates code for a local variable declaration like * `let ;` or `let = `. */ - let _icx = bcx.insn_ctxt("match::store_local"); + let _icx = push_ctxt("match::store_local"); let mut bcx = bcx; return match opt_init_expr { @@ -1813,7 +1813,7 @@ pub fn store_arg(mut bcx: block, * if the argument type is `T`, then `llval` is a `T*`). In some * cases, this code may zero out the memory `llval` points at. */ - let _icx = bcx.insn_ctxt("match::store_arg"); + let _icx = push_ctxt("match::store_arg"); // We always need to cleanup the argument as we exit the fn scope. // Note that we cannot do it before for fear of a fn like @@ -1882,10 +1882,9 @@ fn bind_irrefutable_pat(bcx: block, * - binding_mode: is this for an argument or a local variable? */ - debug!("bind_irrefutable_pat(bcx=%s, pat=%s, val=%s, binding_mode=%?)", + debug!("bind_irrefutable_pat(bcx=%s, pat=%s, binding_mode=%?)", bcx.to_str(), pat_to_str(pat, bcx.sess().intr()), - val_str(bcx.ccx().tn, val), binding_mode); if bcx.sess().asm_comments() { @@ -1895,7 +1894,7 @@ fn bind_irrefutable_pat(bcx: block, let _indenter = indenter(); - let _icx = bcx.insn_ctxt("alt::bind_irrefutable_pat"); + let _icx = push_ctxt("alt::bind_irrefutable_pat"); let mut bcx = bcx; let tcx = bcx.tcx(); let ccx = bcx.ccx(); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 75d9f89a8d7..c8117ed64a7 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -112,8 +112,8 @@ impl Drop for _InsnCtxt { fn drop(&self) { unsafe { do local_data::local_data_modify(task_local_insn_key) |c| { - do c.map_consume |@ctx| { - let mut ctx = ctx; + do c.map_consume |ctx| { + let mut ctx = copy *ctx; ctx.pop(); @ctx } @@ -126,8 +126,8 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt { debug!("new InsnCtxt: %s", s); unsafe { do local_data::local_data_modify(task_local_insn_key) |c| { - do c.map_consume |@ctx| { - let mut ctx = ctx; + do c.map_consume |ctx| { + let mut ctx = copy *ctx; ctx.push(s); @ctx } @@ -1438,54 +1438,6 @@ pub fn block_locals(b: &ast::blk, it: &fn(@ast::local)) { } } -<<<<<<< variant A -pub fn alloc_local(cx: block, local: &ast::local) -> block { - let _icx = push_ctxt("alloc_local"); - let t = node_id_type(cx, local.node.id); - let simple_name = match local.node.pat.node { - ast::pat_ident(_, ref pth, None) => Some(path_to_ident(pth)), - _ => None - }; - let val = alloc_ty(cx, t); - if cx.sess().opts.debuginfo { - for simple_name.iter().advance |name| { - str::as_c_str(cx.ccx().sess.str_of(*name), |buf| { - unsafe { - llvm::LLVMSetValueName(val, buf) - } - }); - } - } - cx.fcx.lllocals.insert(local.node.id, val); - cx -} - - ->>>>>>> variant B -####### Ancestor -pub fn alloc_local(cx: block, local: @ast::local) -> block { - let _icx = push_ctxt("alloc_local"); - let t = node_id_type(cx, local.node.id); - let simple_name = match local.node.pat.node { - ast::pat_ident(_, pth, None) => Some(path_to_ident(pth)), - _ => None - }; - let val = alloc_ty(cx, t); - if cx.sess().opts.debuginfo { - for simple_name.iter().advance |name| { - str::as_c_str(cx.ccx().sess.str_of(*name), |buf| { - unsafe { - llvm::LLVMSetValueName(val, buf) - } - }); - } - } - cx.fcx.lllocals.insert(local.node.id, val); - cx -} - - -======= end pub fn with_cond(bcx: block, val: ValueRef, f: &fn(block) -> block) -> block { let _icx = push_ctxt("with_cond"); let next_cx = base::sub_block(bcx, "next"); @@ -1763,7 +1715,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt, let self_val = if slf.is_copy && datum::appropriate_mode(bcx.tcx(), slf.t).is_by_value() { let tmp = BitCast(bcx, slf.v, type_of(bcx.ccx(), slf.t)); - let alloc = alloc_ty(bcx, slf.t); + let alloc = alloc_ty(bcx, slf.t, "__self"); Store(bcx, tmp, alloc); alloc } else { @@ -3030,7 +2982,7 @@ pub fn trans_crate(sess: session::Session, } } if ccx.sess.count_llvm_insns() { - for ccx.stats.llvm_insns.each |k, v| { + for ccx.stats.llvm_insns.iter().advance |(k, v)| { io::println(fmt!("%-7u %s", *v, *k)); } } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 216338e1117..22adc4aa24b 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -873,10 +873,10 @@ pub fn trans_arg_expr(bcx: block, // &arg_expr.id); debug!("by ref arg with type %s, storing to scratch", bcx.ty_to_str(arg_datum.ty)); - let scratch = scratch_datum(bcx, arg_datum.ty, false); + let scratch = scratch_datum(bcx, arg_datum.ty, + "__self", false); arg_datum.store_to_datum(bcx, - arg_expr.id, INIT, scratch); @@ -897,7 +897,6 @@ pub fn trans_arg_expr(bcx: block, "__arg", false); arg_datum.store_to_datum(bcx, - arg_expr.id, INIT, scratch); diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 14cc822b5a5..0914e61d58f 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -614,7 +614,8 @@ pub fn trans_trait_callee_from_llval(bcx: block, } llself = PointerCast(bcx, llself, Type::opaque_box(ccx).ptr_to()); - let scratch = scratch_datum(bcx, ty::mk_opaque_box(bcx.tcx()), false); + let scratch = scratch_datum(bcx, ty::mk_opaque_box(bcx.tcx()), + "__trait_callee", false); Store(bcx, llself, scratch.val); scratch.add_clean(bcx); diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index b4e891414f6..c546be63138 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -1276,7 +1276,7 @@ impl OwnedVector for ~[T] { ln => { let valptr = ptr::to_mut_unsafe_ptr(&mut self[ln - 1u]); unsafe { - raw::set_len(v, ln - 1u); + raw::set_len(self, ln - 1u); ptr::read_ptr(valptr) } } @@ -1408,7 +1408,7 @@ impl OwnedVector for ~[T] { unsafe { // This loop is optimized out for non-drop types. for uint::range(newlen, oldlen) |i| { - ptr::read_and_zero_ptr(ptr::mut_offset(p, i)) + ptr::read_and_zero_ptr(ptr::mut_offset(p, i)); } } } @@ -1556,7 +1556,7 @@ impl OwnedEqVector for ~[T] { * Remove consecutive repeated elements from a vector; if the vector is * sorted, this removes all duplicates. */ - pub fn dedup(&mut self) { + pub fn dedup(&mut self) { unsafe { // Although we have a mutable reference to `self`, we cannot make // *arbitrary* changes. There exists the possibility that this diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 73ee8768ca3..f9504a696ce 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1521,7 +1521,12 @@ pub fn print_path(s: @ps, path: &ast::Path, colons_before_params: bool) { print_path_(s, path, colons_before_params, &None) } -pub fn print_pat(s: @ps, pat: &ast::pat) { +pub fn print_bounded_path(s: @ps, path: &ast::Path, + bounds: &Option>) { + print_path_(s, path, false, bounds) +} + +pub fn print_pat(s: @ps, pat: @ast::pat) { maybe_print_comment(s, pat.span.lo); let ann_node = node_pat(s, pat); (s.ann.pre)(ann_node); diff --git a/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs b/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs index 827e35e0c83..4407329f497 100644 --- a/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs +++ b/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs @@ -1,6 +1,6 @@ struct S {f:~str} impl Drop for S { - fn finalize(&self) { println(self.f); } + fn drop(&self) { println(self.f); } } fn move_in_match() { diff --git a/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs b/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs index 6013999d835..400a4f07951 100644 --- a/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs +++ b/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs @@ -1,6 +1,6 @@ struct S(~str); impl Drop for S { - fn finalize(&self) { println(**self); } + fn drop(&self) { println(**self); } } fn move_in_match() { diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index 4ce229526ff..f8c369c2e5f 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -163,8 +163,8 @@ pub fn main() { visit_ty::(vv); visit_ty::<~[int]>(vv); - for v.types.iter().advance |&s| { - println(fmt!("type: %s", s)); + for v.types.iter().advance |s| { + println(fmt!("type: %s", copy *s)); } assert_eq!((*v.types).clone(), ~[~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"]); } -- cgit 1.4.1-3-g733a5 From 0c6d02f391aa668b2ead91e8a4ed545475ac2c90 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 8 Jul 2013 11:05:52 -0400 Subject: Correct merge errors --- src/librustc/middle/trans/_match.rs | 8 ++++---- src/librustc/middle/trans/base.rs | 16 ++++++++++------ src/librustc/middle/typeck/coherence.rs | 4 ++-- src/libstd/vec.rs | 2 +- src/libsyntax/ext/deriving/generic.rs | 8 ++++---- src/libsyntax/ext/pipes/pipec.rs | 2 +- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax/print/pprust.rs | 2 +- 8 files changed, 24 insertions(+), 20 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 74f1e372c07..d5d0cde1ee0 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1842,7 +1842,7 @@ pub fn store_arg(mut bcx: block, fn mk_binding_alloca(mut bcx: block, p_id: ast::node_id, - path: @ast::Path, + path: &ast::Path, binding_mode: IrrefutablePatternBindingMode, populate: &fn(block, ty::t, ValueRef) -> block) -> block { let var_ty = node_id_type(bcx, p_id); @@ -1899,7 +1899,7 @@ fn bind_irrefutable_pat(bcx: block, let tcx = bcx.tcx(); let ccx = bcx.ccx(); match pat.node { - ast::pat_ident(pat_binding_mode, path, inner) => { + ast::pat_ident(pat_binding_mode, ref path, inner) => { if pat_is_binding(tcx.def_map, pat) { // Allocate the stack slot where the value of this // binding will live and place it into the appropriate @@ -2017,9 +2017,9 @@ fn bind_irrefutable_pat(bcx: block, return bcx; } -fn simple_identifier(pat: @ast::pat) -> Option<@ast::Path> { +fn simple_identifier<'a>(pat: &'a ast::pat) -> Option<&'a ast::Path> { match pat.node { - ast::pat_ident(ast::bind_infer, path, None) => { + ast::pat_ident(ast::bind_infer, ref path, None) => { Some(path) } _ => { diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index c8117ed64a7..80fc3803ae7 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1969,17 +1969,17 @@ pub fn trans_tuple_struct(ccx: @mut CrateContext, trait IdAndTy { fn id(&self) -> ast::node_id; - fn ty(&self) -> @ast::Ty; + fn ty<'a>(&'a self) -> &'a ast::Ty; } impl IdAndTy for ast::variant_arg { fn id(&self) -> ast::node_id { self.id } - fn ty(&self) -> @ast::Ty { self.ty } + fn ty<'a>(&'a self) -> &'a ast::Ty { &self.ty } } impl IdAndTy for @ast::struct_field { fn id(&self) -> ast::node_id { self.node.id } - fn ty(&self) -> @ast::Ty { self.node.ty } + fn ty<'a>(&'a self) -> &'a ast::Ty { &self.node.ty } } pub fn trans_enum_variant_or_tuple_like_struct( @@ -1994,7 +1994,7 @@ pub fn trans_enum_variant_or_tuple_like_struct( let fn_args = do args.map |varg| { ast::arg { is_mutbl: false, - ty: varg.ty(), + ty: copy *varg.ty(), pat: ast_util::ident_to_pat( ccx.tcx.sess.next_node_id(), codemap::dummy_sp(), @@ -2977,8 +2977,12 @@ pub fn trans_crate(sess: session::Session, do sort::quick_sort(ccx.stats.fn_stats) |&(_, _, insns_a), &(_, _, insns_b)| { insns_a > insns_b } - for ccx.stats.fn_stats.iter().advance |&(name, ms, insns)| { - io::println(fmt!("%u insns, %u ms, %s", insns, ms, name)); + for ccx.stats.fn_stats.iter().advance |tuple| { + match *tuple { + (ref name, ms, insns) => { + io::println(fmt!("%u insns, %u ms, %s", insns, ms, *name)); + } + } } } if ccx.sess.count_llvm_insns() { diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 473d5b8e6e8..7ee731d4f46 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -209,7 +209,7 @@ impl CoherenceChecker { match item.node { item_impl(_, ref opt_trait, _, _) => { let opt_trait : ~[trait_ref] = opt_trait.iter() - .transform(|&x| x) + .transform(|x| copy *x) .collect(); self.check_implementation(item, opt_trait); } @@ -270,7 +270,7 @@ impl CoherenceChecker { // We only want to generate one Impl structure. When we generate one, // we store it here so that we don't recreate it. let mut implementation_opt = None; - for associated_traits.iter().advance |&associated_trait| { + for associated_traits.iter().advance |associated_trait| { let trait_ref = ty::node_id_to_trait_ref( self.crate_context.tcx, diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index c546be63138..a69ffca026b 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -1277,7 +1277,7 @@ impl OwnedVector for ~[T] { let valptr = ptr::to_mut_unsafe_ptr(&mut self[ln - 1u]); unsafe { raw::set_len(self, ln - 1u); - ptr::read_ptr(valptr) + Some(ptr::read_ptr(valptr)) } } } diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index d3554d6b27c..3bc16477c80 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -519,8 +519,8 @@ impl<'self> MethodDef<'self> { // create the generics that aren't for Self let fn_generics = self.generics.to_generics(cx, span, type_ident, generics); - let args = do arg_types.map |&(id, ty)| { - cx.arg(span, id, ty) + let args = do arg_types.map |pair| { + cx.arg(span, pair.first(), pair.second()) }; let ret_type = self.get_ret_ty(cx, span, generics, type_ident); @@ -896,8 +896,8 @@ pub fn create_subpatterns(cx: @ExtCtxt, field_paths: ~[ast::Path], mutbl: ast::mutability) -> ~[@ast::pat] { - do field_paths.map |&path| { - cx.pat(span, ast::pat_ident(ast::bind_by_ref(mutbl), path, None)) + do field_paths.map |path| { + cx.pat(span, ast::pat_ident(ast::bind_by_ref(mutbl), copy *path, None)) } } diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 98fc9aa6178..478c0861990 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -137,7 +137,7 @@ impl gen_send for message { let arg_names = vec::from_fn(tys.len(), |i| "x_" + i.to_str()); let args_ast: ~[ast::arg] = arg_names.iter().zip(tys.iter()) - .transform(|(&n, t)| cx.arg(span, cx.ident_of(n), copy *t)).collect(); + .transform(|(n, t)| cx.arg(span, cx.ident_of(*n), copy *t)).collect(); let args_ast = vec::append( ~[cx.arg(span, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c43b350abdb..8666c84bbef 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3914,7 +3914,7 @@ impl Parser { }; let full_path = full_path.normalize(); - let maybe_i = do self.sess.included_mod_stack.iter().position |&p| { p == full_path }; + let maybe_i = do self.sess.included_mod_stack.iter().position |p| { *p == full_path }; match maybe_i { Some(i) => { let stack = &self.sess.included_mod_stack; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index f9504a696ce..c3710853615 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1526,7 +1526,7 @@ pub fn print_bounded_path(s: @ps, path: &ast::Path, print_path_(s, path, false, bounds) } -pub fn print_pat(s: @ps, pat: @ast::pat) { +pub fn print_pat(s: @ps, pat: &ast::pat) { maybe_print_comment(s, pat.span.lo); let ann_node = node_pat(s, pat); (s.ann.pre)(ann_node); -- cgit 1.4.1-3-g733a5