From 90843b6f58a042cd1548555064a80034a608c02b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 20 Jun 2013 15:15:16 -0400 Subject: extra: Patch up code that was using irrefutable patterns incorrectly. --- src/libextra/fileinput.rs | 15 ++++++++------- src/libextra/num/bigint.rs | 12 ++++++------ src/libextra/rc.rs | 2 +- src/libextra/terminfo/parm.rs | 4 ++-- src/libextra/treemap.rs | 10 +++++----- src/libextra/workcache.rs | 4 ++-- 6 files changed, 24 insertions(+), 23 deletions(-) (limited to 'src/libextra') diff --git a/src/libextra/fileinput.rs b/src/libextra/fileinput.rs index f91260f4752..de6edd54094 100644 --- a/src/libextra/fileinput.rs +++ b/src/libextra/fileinput.rs @@ -419,7 +419,7 @@ mod test { let file = io::file_writer(path, [io::Create, io::Truncate]).get(); for contents.iter().advance |&str| { - file.write_str(str); + file.write_str(*str); file.write_char('\n'); } } @@ -445,7 +445,7 @@ mod test { |i| fmt!("tmp/lib-fileinput-test-fileinput-read-byte-%u.tmp", i)), true); // 3 files containing 0\n, 1\n, and 2\n respectively - for filenames.iter().enumerate().advance |(i, &filename)| { + for filenames.iter().enumerate().advance |(i, filename)| { make_file(filename.get_ref(), [fmt!("%u", i)]); } @@ -475,7 +475,7 @@ mod test { |i| fmt!("tmp/lib-fileinput-test-fileinput-read-%u.tmp", i)), true); // 3 files containing 1\n, 2\n, and 3\n respectively - for filenames.iter().enumerate().advance |(i, &filename)| { + for filenames.iter().enumerate().advance |(i, filename)| { make_file(filename.get_ref(), [fmt!("%u", i)]); } @@ -495,10 +495,11 @@ mod test { 3, |i| fmt!("tmp/lib-fileinput-test-input-vec-%u.tmp", i)), true); - for filenames.iter().enumerate().advance |(i, &filename)| { + for filenames.iter().enumerate().advance |(i, filename)| { let contents = vec::from_fn(3, |j| fmt!("%u %u", i, j)); make_file(filename.get_ref(), contents); + debug!("contents=%?", contents); all_lines.push_all(contents); } @@ -515,7 +516,7 @@ mod test { 3, |i| fmt!("tmp/lib-fileinput-test-input-vec-state-%u.tmp", i)),true); - for filenames.iter().enumerate().advance |(i, &filename)| { + for filenames.iter().enumerate().advance |(i, filename)| { let contents = vec::from_fn(3, |j| fmt!("%u %u", i, j + 1)); make_file(filename.get_ref(), contents); @@ -579,10 +580,10 @@ mod test { 3, |i| fmt!("tmp/lib-fileinput-test-next-file-%u.tmp", i)),true); - for filenames.iter().enumerate().advance |(i, &filename)| { + for filenames.iter().enumerate().advance |(i, filename)| { let contents = vec::from_fn(3, |j| fmt!("%u %u", i, j + 1)); - make_file(&filename.get(), contents); + make_file(filename.get_ref(), contents); } let in = FileInput::from_vec(filenames); diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs index a0b95924e09..91842474899 100644 --- a/src/libextra/num/bigint.rs +++ b/src/libextra/num/bigint.rs @@ -1571,10 +1571,10 @@ mod biguint_tests { fn test_to_str_radix() { let r = to_str_pairs(); for r.iter().advance |num_pair| { - let &(n, rs) = num_pair; + let &(ref n, ref rs) = num_pair; for rs.iter().advance |str_pair| { - let &(radix, str) = str_pair; - assert_eq!(n.to_str_radix(radix), str); + let &(ref radix, ref str) = str_pair; + assert_eq!(&n.to_str_radix(*radix), str); } } } @@ -1583,10 +1583,10 @@ mod biguint_tests { fn test_from_str_radix() { let r = to_str_pairs(); for r.iter().advance |num_pair| { - let &(n, rs) = num_pair; + let &(ref n, ref rs) = num_pair; for rs.iter().advance |str_pair| { - let &(radix, str) = str_pair; - assert_eq!(&n, &FromStrRadix::from_str_radix(str, radix).get()); + let &(ref radix, ref str) = str_pair; + assert_eq!(&n, &FromStrRadix::from_str_radix(*str, *radix).get()); } } diff --git a/src/libextra/rc.rs b/src/libextra/rc.rs index 86080b343c7..7cc8bca8910 100644 --- a/src/libextra/rc.rs +++ b/src/libextra/rc.rs @@ -73,7 +73,7 @@ impl Drop for Rc { if self.ptr.is_not_null() { (*self.ptr).count -= 1; if (*self.ptr).count == 0 { - ptr::replace_ptr(self.ptr, intrinsics::uninit()); + ptr::read_ptr(self.ptr); free(self.ptr as *c_void) } } diff --git a/src/libextra/terminfo/parm.rs b/src/libextra/terminfo/parm.rs index b7d21ea0ee3..f25d192cc0a 100644 --- a/src/libextra/terminfo/parm.rs +++ b/src/libextra/terminfo/parm.rs @@ -81,8 +81,8 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) // Copy parameters into a local vector for mutability let mut mparams = [Number(0), ..9]; - for mparams.mut_iter().zip(params.iter()).advance |(dst, &src)| { - *dst = src; + for mparams.mut_iter().zip(params.iter()).advance |(dst, src)| { + *dst = copy *src; } for cap.iter().transform(|&x| x).advance |c| { diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs index a5f7479d41a..f2dea8b9bba 100644 --- a/src/libextra/treemap.rs +++ b/src/libextra/treemap.rs @@ -773,15 +773,15 @@ mod test_treemap { map: &TreeMap) { assert_eq!(ctrl.is_empty(), map.is_empty()); for ctrl.iter().advance |x| { - let &(k, v) = x; - assert!(map.find(&k).unwrap() == &v) + let &(ref k, ref v) = x; + assert!(map.find(k).unwrap() == v) } for map.iter().advance |(map_k, map_v)| { let mut found = false; for ctrl.iter().advance |x| { - let &(ctrl_k, ctrl_v) = x; - if *map_k == ctrl_k { - assert!(*map_v == ctrl_v); + let &(ref ctrl_k, ref ctrl_v) = x; + if *map_k == *ctrl_k { + assert!(*map_v == *ctrl_v); found = true; break; } diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs index 503bd05b733..e7bec2fbd8d 100644 --- a/src/libextra/workcache.rs +++ b/src/libextra/workcache.rs @@ -157,8 +157,8 @@ impl Decodable for WorkMap { fn decode(d: &mut D) -> WorkMap { let v : ~[(WorkKey,~str)] = Decodable::decode(d); let mut w = WorkMap::new(); - for v.iter().advance |&(k, v)| { - w.insert(copy k, copy v); + for v.iter().advance |pair| { + w.insert(pair.first(), pair.second()); } w } -- 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/libextra') 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