From 7ccb0e63c5d1372f970f592b2d0b531ce591a63d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 7 Mar 2013 18:36:35 -0500 Subject: [PATCH 1/7] core: Remove uses of DVec in io/repr --- src/libcore/io.rs | 34 ++++++++++++----------------- src/libcore/repr.rs | 13 +++++------ src/libcore/task/local_data_priv.rs | 25 +++++++++++---------- 3 files changed, 34 insertions(+), 38 deletions(-) diff --git a/src/libcore/io.rs b/src/libcore/io.rs index cc40b90d61a34..34fa4c972ea77 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -16,7 +16,6 @@ Basic input/output use result::Result; -use dvec::DVec; use int; use libc; use libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t}; @@ -1109,30 +1108,25 @@ pub fn print(s: &str) { stdout().write_str(s); } pub fn println(s: &str) { stdout().write_line(s); } pub struct BytesWriter { - bytes: DVec, + mut bytes: ~[u8], mut pos: uint, } impl Writer for BytesWriter { fn write(&self, v: &[const u8]) { - do self.bytes.swap |bytes| { - let mut bytes = bytes; - let v_len = v.len(); - let bytes_len = bytes.len(); - - let count = uint::max(bytes_len, self.pos + v_len); - vec::reserve(&mut bytes, count); - unsafe { vec::raw::set_len(&mut bytes, count); } - - { - let view = vec::mut_slice(bytes, self.pos, count); - vec::bytes::copy_memory(view, v, v_len); - } + let v_len = v.len(); + let bytes_len = self.bytes.len(); - self.pos += v_len; + let count = uint::max(bytes_len, self.pos + v_len); + vec::reserve(&mut self.bytes, count); - bytes + unsafe { + vec::raw::set_len(&mut self.bytes, count); + let view = vec::mut_slice(self.bytes, self.pos, count); + vec::bytes::copy_memory(view, v, v_len); } + + self.pos += v_len; } fn seek(&self, offset: int, whence: SeekStyle) { let pos = self.pos; @@ -1145,14 +1139,14 @@ impl Writer for BytesWriter { } pub pure fn BytesWriter() -> BytesWriter { - BytesWriter { bytes: DVec(), mut pos: 0u } + BytesWriter { bytes: ~[], mut pos: 0u } } pub pure fn with_bytes_writer(f: fn(Writer)) -> ~[u8] { let wr = @BytesWriter(); f(wr as Writer); - // FIXME (#3758): This should not be needed. - unsafe { wr.bytes.check_out(|bytes| bytes) } + let @BytesWriter{bytes, _} = wr; + return bytes; } pub pure fn with_str_writer(f: fn(Writer)) -> ~str { diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index eaae9d03e8ea8..e9122754eb42a 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -16,7 +16,6 @@ More runtime type reflection use cast::transmute; use char; -use dvec::DVec; use intrinsic; use intrinsic::{TyDesc, TyVisitor, visit_tydesc}; use io::{Writer, WriterUtil}; @@ -147,14 +146,14 @@ enum VariantState { pub struct ReprVisitor { mut ptr: *c_void, - ptr_stk: DVec<*c_void>, - var_stk: DVec, + mut ptr_stk: ~[*c_void], + mut var_stk: ~[VariantState], writer: @Writer } pub fn ReprVisitor(ptr: *c_void, writer: @Writer) -> ReprVisitor { ReprVisitor { ptr: ptr, - ptr_stk: DVec(), - var_stk: DVec(), + ptr_stk: ~[], + var_stk: ~[], writer: writer } } @@ -500,7 +499,7 @@ impl TyVisitor for ReprVisitor { } fn visit_enum_variant_field(&self, i: uint, inner: *TyDesc) -> bool { - match self.var_stk.last() { + match self.var_stk[self.var_stk.len() - 1] { Degenerate | TagMatch => { if i != 0 { self.writer.write_str(", "); @@ -518,7 +517,7 @@ impl TyVisitor for ReprVisitor { _disr_val: int, n_fields: uint, _name: &str) -> bool { - match self.var_stk.last() { + match self.var_stk[self.var_stk.len() - 1] { Degenerate | TagMatch => { if n_fields > 0 { self.writer.write_char(')'); diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index cb1283019ebaa..f035916f59423 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -12,7 +12,6 @@ use cast; use cmp::Eq; -use dvec; use libc; use option; use prelude::*; @@ -35,11 +34,11 @@ impl Eq for LocalData { pure fn ne(&self, other: &@LocalData) -> bool { !(*self).eq(other) } } -// We use dvec because it's the best data structure in core. If TLS is used -// heavily in future, this could be made more efficient with a proper map. +// If TLS is used heavily in future, this could be made more efficient with a +// proper map. type TaskLocalElement = (*libc::c_void, *libc::c_void, LocalData); // Has to be a pointer at outermost layer; the foreign call returns void *. -type TaskLocalMap = @dvec::DVec>; +type TaskLocalMap = @mut ~[Option]; extern fn cleanup_task_local_map(map_ptr: *libc::c_void) { unsafe { @@ -60,17 +59,21 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap { // drop when they finish. No "re-storing after modifying" is needed. let map_ptr = rt::rust_get_task_local_data(task); if map_ptr.is_null() { - let map: TaskLocalMap = @dvec::DVec(); + let map: TaskLocalMap = @mut ~[]; // Use reinterpret_cast -- transmute would take map away from us also. rt::rust_set_task_local_data( task, cast::reinterpret_cast(&map)); rt::rust_task_local_data_atexit(task, cleanup_task_local_map); // Also need to reference it an extra time to keep it for now. - cast::bump_box_refcount(map); + let nonmut = cast::transmute::]>(map); + cast::bump_box_refcount(nonmut); map } else { let map = cast::transmute(map_ptr); - cast::bump_box_refcount(map); + let nonmut = cast::transmute::]>(map); + cast::bump_box_refcount(nonmut); map } } @@ -118,7 +121,7 @@ unsafe fn local_get_helper( let data: @T = cast::transmute(data_ptr); cast::bump_box_refcount(data); if do_pop { - (*map).set_elt(index, None); + map[index] = None; } data } @@ -159,13 +162,13 @@ pub unsafe fn local_set( Some((index, _old_data_ptr)) => { // Key already had a value set, _old_data_ptr, whose reference // will get dropped when the local_data box is overwritten. - (*map).set_elt(index, new_entry); + map[index] = new_entry; } None => { // Find an empty slot. If not, grow the vector. match (*map).position(|x| x.is_none()) { - Some(empty_index) => (*map).set_elt(empty_index, new_entry), - None => (*map).push(new_entry) + Some(empty_index) => { map[empty_index] = new_entry; } + None => { map.push(new_entry); } } } } From 87f864292def92dc8e2fe4782c4e8cce0db0fb0a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 7 Mar 2013 18:37:05 -0500 Subject: [PATCH 2/7] std: Remove uses of DVec --- src/libstd/flatpipes.rs | 9 +-- src/libstd/json.rs | 1 - src/libstd/sort.rs | 100 +++++++++++++++----------------- src/test/run-pass/issue-5275 | Bin 0 -> 16176 bytes src/test/run-pass/issue-5275.rs | 27 +++++++++ 5 files changed, 78 insertions(+), 59 deletions(-) create mode 100755 src/test/run-pass/issue-5275 create mode 100644 src/test/run-pass/issue-5275.rs diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 734e6e835815c..b117834238f4b 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -452,12 +452,13 @@ pub mod flatteners { pub fn serialize_value>(val: &T) -> ~[u8] { - let bytes_writer = @BytesWriter(); - let writer = bytes_writer as @Writer; + let mut bytes_writer = BytesWriter(); + let writer = @bytes_writer as @Writer; let ser = FromWriter::from_writer(writer); val.encode(&ser); - let bytes = bytes_writer.bytes.check_out(|bytes| bytes); - return bytes; + let mut ret = ~[]; + ret <-> bytes_writer.bytes; + return ret; } pub trait FromReader { diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 01e0b58f77e5c..6506d8e3c41a6 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -27,7 +27,6 @@ use core::prelude::*; use core::hashmap::linear::LinearMap; use core::str; use core::to_str; -use core::vec; /// Represents a json value pub enum Json { diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 37be1c86e917b..50de528762f26 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -11,7 +11,6 @@ //! Sorting methods use core::cmp::{Eq, Ord}; -use core::dvec::DVec; use core::prelude::*; use core::util; use core::vec::{len, push}; @@ -189,7 +188,7 @@ pub fn tim_sort(array: &mut [T]) { return; } - let ms = &MergeState(); + let mut ms = MergeState(); let min_run = min_run_length(size); let mut idx = 0; @@ -392,66 +391,63 @@ struct RunState { } struct MergeState { - mut min_gallop: uint, - runs: DVec, + min_gallop: uint, + runs: ~[RunState], } // Fixme (#3853) Move into MergeState fn MergeState() -> MergeState { MergeState { min_gallop: MIN_GALLOP, - runs: DVec(), + runs: ~[], } } -pub impl MergeState { - fn push_run(&self, run_base: uint, run_len: uint) { +impl MergeState { + fn push_run(&mut self, run_base: uint, run_len: uint) { let tmp = RunState{base: run_base, len: run_len}; self.runs.push(tmp); } - fn merge_at(&self, n: uint, array: &mut [T]) { + fn merge_at(&mut self, n: uint, array: &mut [T]) { let mut size = self.runs.len(); fail_unless!(size >= 2); fail_unless!(n == size-2 || n == size-3); - do self.runs.borrow_mut |arr| { + let mut b1 = self.runs[n].base; + let mut l1 = self.runs[n].len; + let b2 = self.runs[n+1].base; + let l2 = self.runs[n+1].len; - let mut b1 = arr[n].base; - let mut l1 = arr[n].len; - let b2 = arr[n+1].base; - let l2 = arr[n+1].len; + fail_unless!(l1 > 0 && l2 > 0); + fail_unless!(b1 + l1 == b2); - fail_unless!(l1 > 0 && l2 > 0); - fail_unless!(b1 + l1 == b2); - - arr[n].len = l1 + l2; - if n == size-3 { - arr[n+1].base = arr[n+2].base; - arr[n+1].len = arr[n+2].len; - } + self.runs[n].len = l1 + l2; + if n == size-3 { + self.runs[n+1].base = self.runs[n+2].base; + self.runs[n+1].len = self.runs[n+2].len; + } - let slice = vec::mut_slice(array, b1, b1+l1); - let k = gallop_right(&const array[b2], slice, 0); - b1 += k; - l1 -= k; - if l1 != 0 { - let slice = vec::mut_slice(array, b2, b2+l2); - let l2 = gallop_left( - &const array[b1+l1-1],slice,l2-1); - if l2 > 0 { - if l1 <= l2 { - self.merge_lo(array, b1, l1, b2, l2); - } else { - self.merge_hi(array, b1, l1, b2, l2); - } + let slice = vec::mut_slice(array, b1, b1+l1); + let k = gallop_right(&const array[b2], slice, 0); + b1 += k; + l1 -= k; + if l1 != 0 { + let slice = vec::mut_slice(array, b2, b2+l2); + let l2 = gallop_left( + &const array[b1+l1-1],slice,l2-1); + if l2 > 0 { + if l1 <= l2 { + self.merge_lo(array, b1, l1, b2, l2); + } else { + self.merge_hi(array, b1, l1, b2, l2); } } } self.runs.pop(); } - fn merge_lo(&self, array: &mut [T], base1: uint, len1: uint, + fn merge_lo(&mut self, array: &mut [T], base1: uint, len1: uint, base2: uint, len2: uint) { fail_unless!(len1 != 0 && len2 != 0 && base1+len1 == base2); @@ -554,7 +550,7 @@ pub impl MergeState { } } - fn merge_hi(&self, array: &mut [T], base1: uint, len1: uint, + fn merge_hi(&mut self, array: &mut [T], base1: uint, len1: uint, base2: uint, len2: uint) { fail_unless!(len1 != 1 && len2 != 0 && base1 + len1 == base2); @@ -672,32 +668,28 @@ pub impl MergeState { } } - fn merge_collapse(&self, array: &mut [T]) { + fn merge_collapse(&mut self, array: &mut [T]) { while self.runs.len() > 1 { let mut n = self.runs.len()-2; - let chk = do self.runs.borrow |arr| { - if n > 0 && arr[n-1].len <= arr[n].len + arr[n+1].len { - if arr[n-1].len < arr[n+1].len { n -= 1; } - true - } else if arr[n].len <= arr[n+1].len { - true - } else { - false - } - }; - if !chk { break; } + if n > 0 && + self.runs[n-1].len <= self.runs[n].len + self.runs[n+1].len + { + if self.runs[n-1].len < self.runs[n+1].len { n -= 1; } + } else if self.runs[n].len <= self.runs[n+1].len { + /* keep going */ + } else { + break; + } self.merge_at(n, array); } } - fn merge_force_collapse(&self, array: &mut [T]) { + fn merge_force_collapse(&mut self, array: &mut [T]) { while self.runs.len() > 1 { let mut n = self.runs.len()-2; if n > 0 { - do self.runs.borrow |arr| { - if arr[n-1].len < arr[n+1].len { - n -= 1; - } + if self.runs[n-1].len < self.runs[n+1].len { + n -= 1; } } self.merge_at(n, array); diff --git a/src/test/run-pass/issue-5275 b/src/test/run-pass/issue-5275 new file mode 100755 index 0000000000000000000000000000000000000000..ea8edf5156a63ae2378f0d57d4efde992f3fbcf1 GIT binary patch literal 16176 zcmeHOe{37qeLqTZqBM?8Cw1zy%SXxe1*=;THS;}2}i8HIegWk9dIB`)tI=OcQ9{Wi%nr?pH;pD|te8~a!MEvLO#F~Gl=%_c4wQv!px3~#8WMy>#5A||5H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A_Nsa(~>$8(RFSboDH#^8C@hEs)7 zsc>4;%UX7Z)>K6_jF_A6w%5%&vf438j^= z7)$8}DiD{w?2?ozlukiqNQ#PpN2E{$4++#U9n+0)n*~`l9c}GQ;jTndn_Sd-0Mg z@`Mr*w8|NJSVDRT+)W}3NRyChSg_~&Od(A#pU$xA@*J19eqyqb*-gY257e#rw|K0x z(bx4=gAmtxjoIoIq#N&6FDK~1O>bD-{2ksB+>W6aHgpYzo8H>IuYa!Ty1m=Gm@VGw z9oTih&lCK;?4JnlnMc>NbLzx)9UF!YY}d0@=)iWJn}p4rTWk+Dje~3N0^PTJcOTf= cOSn0$U4)yndH>KXq0MLeE^^bp5f8Bc1%|dVrvLx| literal 0 HcmV?d00001 diff --git a/src/test/run-pass/issue-5275.rs b/src/test/run-pass/issue-5275.rs new file mode 100644 index 0000000000000..a1b93d99f2814 --- /dev/null +++ b/src/test/run-pass/issue-5275.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(self: &A) -> int { + if true { + fail!() + } else { + *bar(self.bar) + } +} + +pub fn main() {} + +fn bar(_: &r/mut int) -> &r/int { + fail!() +} + +struct A { + bar: @mut int, +} From 2a72099063b21abc84145960a14224458b6dc37c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 7 Mar 2013 18:37:14 -0500 Subject: [PATCH 3/7] rustc: Remove uses of DVec --- src/librustc/metadata/csearch.rs | 3 +- src/librustc/metadata/decoder.rs | 16 +- src/librustc/metadata/encoder.rs | 15 +- src/librustc/middle/astencode.rs | 9 +- src/librustc/middle/borrowck/gather_loans.rs | 4 +- src/librustc/middle/borrowck/mod.rs | 3 +- src/librustc/middle/liveness.rs | 18 +- src/librustc/middle/privacy.rs | 3 +- src/librustc/middle/region.rs | 5 +- src/librustc/middle/resolve.rs | 201 +++++++++--------- src/librustc/middle/trans/_match.rs | 38 ++-- src/librustc/middle/ty.rs | 8 +- src/librustc/middle/typeck/check/method.rs | 37 ++-- src/librustc/middle/typeck/coherence.rs | 26 +-- src/librustc/middle/typeck/collect.rs | 6 +- .../middle/typeck/infer/region_inference.rs | 5 +- 16 files changed, 191 insertions(+), 206 deletions(-) diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index 427867845fe73..00cb977b50c83 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -19,7 +19,6 @@ use metadata::decoder; use metadata; use middle::{ty, resolve}; -use core::dvec::DVec; use core::vec; use reader = std::ebml::reader; use syntax::ast; @@ -136,7 +135,7 @@ pub fn get_supertraits(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::t] { pub fn get_method_names_if_trait(cstore: @mut cstore::CStore, def: ast::def_id) - -> Option<@DVec<(ast::ident, ast::self_ty_)>> { + -> Option<~[(ast::ident, ast::self_ty_)]> { let cdata = cstore::get_crate_data(cstore, def.crate); return decoder::get_method_names_if_trait(cstore.intr, cdata, def.node); } diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 6a2ba78bfe920..4fe708d1020cd 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -22,8 +22,6 @@ use metadata::decoder; use metadata::tydecode::{parse_ty_data, parse_def_id, parse_bounds_data}; use middle::{ty, resolve}; -use core::dvec; -use core::dvec::DVec; use core::hash::{Hash, HashUtil}; use core::int; use core::io::WriterUtil; @@ -766,12 +764,12 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd, /// Returns the supertraits of the given trait. pub fn get_supertraits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> ~[ty::t] { - let results = dvec::DVec(); + let mut results = ~[]; let item_doc = lookup_item(id, cdata.data); for reader::tagged_docs(item_doc, tag_impl_trait) |trait_doc| { results.push(doc_type(trait_doc, tcx, cdata)); } - return dvec::unwrap(results); + return results; } // If the item in question is a trait, returns its set of methods and @@ -779,14 +777,14 @@ pub fn get_supertraits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) // annoying way with get_trait_methods. pub fn get_method_names_if_trait(intr: @ident_interner, cdata: cmd, node_id: ast::node_id) - -> Option<@DVec<(ast::ident, ast::self_ty_)>> { + -> Option<~[(ast::ident, ast::self_ty_)]> { let item = lookup_item(node_id, cdata.data); if item_family(item) != Trait { return None; } - let resulting_methods = @DVec(); + let mut resulting_methods = ~[]; for reader::tagged_docs(item, tag_item_trait_method) |method| { resulting_methods.push( (item_name(intr, method), get_self_ty(method))); @@ -823,12 +821,12 @@ pub fn get_static_methods_if_impl(intr: @ident_interner, return None; } - let impl_method_ids = DVec(); + let mut impl_method_ids = ~[]; for reader::tagged_docs(item, tag_item_impl_method) |impl_method_doc| { impl_method_ids.push(parse_def_id(reader::doc_data(impl_method_doc))); } - let static_impl_methods = DVec(); + let mut static_impl_methods = ~[]; for impl_method_ids.each |impl_method_id| { let impl_method_doc = lookup_item(impl_method_id.node, cdata.data); let family = item_family(impl_method_doc); @@ -852,7 +850,7 @@ pub fn get_static_methods_if_impl(intr: @ident_interner, } } - return Some(dvec::unwrap(static_impl_methods)); + return Some(static_impl_methods); } pub fn get_item_attrs(cdata: cmd, diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 1b106cc121846..414aa035b5497 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -22,7 +22,6 @@ use middle::ty; use middle; use util::ppaux::ty_to_str; -use core::dvec; use core::flate; use core::hash::{Hash, HashUtil}; use core::int; @@ -857,7 +856,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder, } } item_trait(ref generics, ref traits, ref ms) => { - let provided_methods = dvec::DVec(); + let mut provided_methods = ~[]; add_to_index(); ebml_w.start_tag(tag_items_data_item); @@ -1366,13 +1365,11 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { if (parms.tcx.sess.meta_stats()) { - do wr.bytes.borrow |v| { - do v.each |e| { - if *e == 0 { - ecx.stats.zero_bytes += 1; - } - true + do wr.bytes.each |e| { + if *e == 0 { + ecx.stats.zero_bytes += 1; } + true } io::println("metadata stats:"); @@ -1401,7 +1398,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { (do str::as_bytes(&~"rust\x00\x00\x00\x01") |bytes| { vec::slice(*bytes, 0, 8).to_vec() - }) + flate::deflate_bytes(wr.bytes.check_out(|buf| buf)) + }) + flate::deflate_bytes(wr.bytes) } // Get the encoded string for a type diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 49a5be5468474..1be8112fc807e 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -25,7 +25,7 @@ use middle::{ty, typeck, moves}; use middle; use util::ppaux::ty_to_str; -use core::{dvec, io, option, vec}; +use core::{io, option, vec}; use std::ebml::reader; use std::ebml; use std::serialize; @@ -912,11 +912,11 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext, } } - for maps.last_use_map.find(&id).each |m| { + for maps.last_use_map.find(&id).each |&m| { do ebml_w.tag(c::tag_table_last_use) { ebml_w.id(id); do ebml_w.tag(c::tag_table_val) { - do ebml_w.emit_from_vec((*m).get()) |id| { + do ebml_w.emit_from_vec(/*bad*/ copy *m) |id| { id.encode(&ebml_w); } } @@ -1131,8 +1131,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext, let ids = val_dsr.read_to_vec(|| { xcx.tr_id(val_dsr.read_int()) }); - let dvec = @dvec::from_vec(ids); - dcx.maps.last_use_map.insert(id, dvec); + dcx.maps.last_use_map.insert(id, @mut ids); } else if tag == (c::tag_table_method_map as uint) { dcx.maps.method_map.insert( id, diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index 1404c4db464c6..94c266ab44fcb 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -32,7 +32,6 @@ use middle::ty; use util::common::indenter; use util::ppaux::{expr_repr, region_to_str}; -use core::dvec; use core::hashmap::linear::LinearSet; use core::vec; use std::oldmap::HashMap; @@ -575,9 +574,8 @@ pub impl GatherLoanCtxt { req_loans.push_all(loans); } None => { - let dvec = @dvec::from_vec(loans); let req_loan_map = self.req_maps.req_loan_map; - req_loan_map.insert(scope_id, dvec); + req_loan_map.insert(scope_id, @mut loans); } } } diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 412603016dcfe..5462ec87014e2 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -234,7 +234,6 @@ use middle::moves; use util::common::{indenter, stmt_set}; use util::ppaux::note_and_explain_region; -use core::dvec::DVec; use core::io; use core::result::{Result, Ok, Err}; use core::to_bytes; @@ -406,7 +405,7 @@ pub struct Loan { /// - `pure_map`: map from block/expr that must be pure to the error message /// that should be reported if they are not pure pub struct ReqMaps { - req_loan_map: HashMap>, + req_loan_map: HashMap, pure_map: HashMap } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 5d652571ab1b6..f0c06ceca989c 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -112,7 +112,6 @@ use middle::moves; use util::ppaux::ty_to_str; use core::cmp; -use core::dvec::DVec; use core::io::WriterUtil; use core::io; use core::ptr; @@ -136,7 +135,7 @@ use syntax::{visit, ast_util}; // // Very subtle (#2633): borrowck will remove entries from this table // if it detects an outstanding loan (that is, the addr is taken). -pub type last_use_map = HashMap>; +pub type last_use_map = HashMap; enum Variable = uint; enum LiveNode = uint; @@ -419,13 +418,13 @@ pub impl IrMaps { let v = match self.last_use_map.find(&expr_id) { Some(v) => v, None => { - let v = @DVec(); + let v = @mut ~[]; self.last_use_map.insert(expr_id, v); v } }; - (*v).push(id); + v.push(id); } Arg(_, _, by_ref) | Arg(_, _, by_val) | ImplicitRet => { @@ -667,7 +666,7 @@ struct Liveness { users: @mut ~[Users], // The list of node IDs for the nested loop scopes // we're in. - loop_scope: DVec, + loop_scope: @mut ~[node_id], // mappings from loop node ID to LiveNode // ("break" label should map to loop node ID, // it probably doesn't now) @@ -683,7 +682,7 @@ fn Liveness(ir: @mut IrMaps, specials: Specials) -> Liveness { successors: @mut vec::from_elem(ir.num_live_nodes, invalid_node()), users: @mut vec::from_elem(ir.num_live_nodes * ir.num_vars, invalid_users()), - loop_scope: DVec(), + loop_scope: @mut ~[], break_ln: HashMap(), cont_ln: HashMap() } @@ -856,11 +855,16 @@ pub impl Liveness { self.tcx.sess.span_bug(sp, ~"break outside loop"); } else { - self.loop_scope.last() + // FIXME(#5275): this shouldn't have to be a method... + self.last_loop_scope() } } } + fn last_loop_scope(&self) -> node_id { + *self.loop_scope.last() + } + fn ln_str(&self, ln: LiveNode) -> ~str { do io::with_str_writer |wr| { wr.write_str(~"[ln("); diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index e60069e05da81..3e3b1eb207109 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -21,7 +21,6 @@ use middle::typeck::{method_map, method_origin, method_param, method_self}; use middle::typeck::{method_super}; use middle::typeck::{method_static, method_trait}; -use core::dvec::DVec; use core::util::ignore; use syntax::ast::{def_variant, expr_field, expr_method_call, expr_struct}; use syntax::ast::{expr_unary, ident, item_struct, item_enum, item_impl}; @@ -38,7 +37,7 @@ use syntax::visit; pub fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) { - let privileged_items = @DVec(); + let privileged_items = @mut ~[]; // Adds structs that are privileged to this scope. let add_privileged_items: @fn(&[@ast::item]) -> uint = |items| { diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 866ec0ab515ef..12c08ffb43585 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -26,7 +26,6 @@ use middle::ty::{region_variance, rv_covariant, rv_invariant}; use middle::ty::{rv_contravariant}; use middle::ty; -use core::dvec::DVec; use core::vec; use std::oldmap::HashMap; use syntax::ast_map; @@ -395,7 +394,7 @@ pub struct region_dep { id: ast::node_id } -pub type dep_map = HashMap>; +pub type dep_map = HashMap; pub struct DetermineRpCtxt { sess: Session, @@ -498,7 +497,7 @@ pub impl DetermineRpCtxt { let vec = match self.dep_map.find(&from) { Some(vec) => vec, None => { - let vec = @DVec(); + let vec = @mut ~[]; let dep_map = self.dep_map; dep_map.insert(from, vec); vec diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 1ca3c045f57ec..391990eed95de 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -75,7 +75,6 @@ use syntax::visit::{visit_foreign_item, visit_item, visit_method_helper}; use syntax::visit::{visit_mod, visit_ty, vt}; use syntax::opt_vec::OptVec; -use core::dvec::DVec; use core::option::{Some, get, is_some, is_none}; use core::str::{connect, split_str}; use std::oldmap::HashMap; @@ -110,7 +109,7 @@ pub struct Impl { } // Trait method resolution -pub type TraitMap = @HashMap>; +pub type TraitMap = @HashMap; // This is the replacement export map. It maps a module to all of the exports // within. @@ -350,13 +349,13 @@ pub fn Rib(kind: RibKind) -> Rib { /// One import directive. pub struct ImportDirective { privacy: Privacy, - module_path: @DVec, + module_path: ~[ident], subclass: @ImportDirectiveSubclass, span: span, } pub fn ImportDirective(privacy: Privacy, - module_path: @DVec, + +module_path: ~[ident], subclass: @ImportDirectiveSubclass, span: span) -> ImportDirective { @@ -458,7 +457,7 @@ pub struct Module { kind: ModuleKind, children: @HashMap, - imports: @DVec<@ImportDirective>, + imports: ~[@ImportDirective], // The anonymous children of this node. Anonymous children are pseudo- // modules that are implicitly created around items contained within @@ -496,7 +495,7 @@ pub fn Module(parent_link: ParentLink, def_id: def_id, kind: kind, children: @HashMap(), - imports: @DVec(), + imports: ~[], anonymous_children: @HashMap(), import_resolutions: @HashMap(), glob_count: 0, @@ -781,9 +780,9 @@ pub fn Resolver(session: Session, unresolved_imports: 0, current_module: current_module, - value_ribs: @DVec(), - type_ribs: @DVec(), - label_ribs: @DVec(), + value_ribs: ~[], + type_ribs: ~[], + label_ribs: ~[], xray_context: NoXray, current_trait_refs: None, @@ -830,20 +829,20 @@ pub struct Resolver { // The current set of local scopes, for values. // FIXME #4948: Reuse ribs to avoid allocation. - value_ribs: @DVec<@Rib>, + value_ribs: ~[@Rib], // The current set of local scopes, for types. - type_ribs: @DVec<@Rib>, + type_ribs: ~[@Rib], // The current set of local scopes, for labels. - label_ribs: @DVec<@Rib>, + label_ribs: ~[@Rib], // Whether the current context is an X-ray context. An X-ray context is // allowed to access private names of any module. xray_context: XrayFlag, // The trait that the current context can refer to. - current_trait_refs: Option<@DVec>, + current_trait_refs: Option<~[def_id]>, // The ident for the keyword "self". self_ident: ident, @@ -1407,7 +1406,7 @@ pub impl Resolver { // globs and lists, the path is found directly in the AST; // for simple paths we have to munge the path a little. - let module_path = @DVec(); + let mut module_path = ~[]; match view_path.node { view_path_simple(_, full_path, _, _) => { let path_len = full_path.idents.len(); @@ -1415,7 +1414,7 @@ pub impl Resolver { for full_path.idents.eachi |i, ident| { if i != path_len - 1 { - (*module_path).push(*ident); + module_path.push(*ident); } } } @@ -1423,7 +1422,7 @@ pub impl Resolver { view_path_glob(module_ident_path, _) | view_path_list(module_ident_path, _, _) => { for module_ident_path.idents.each |ident| { - (*module_path).push(*ident); + module_path.push(*ident); } } } @@ -1457,7 +1456,7 @@ pub impl Resolver { AnyNS); self.build_import_directive(privacy, module_, - module_path, + copy module_path, subclass, view_path.span, state); @@ -1857,7 +1856,7 @@ pub impl Resolver { fn build_import_directive(@mut self, privacy: Privacy, module_: @mut Module, - module_path: @DVec, + +module_path: ~[ident], subclass: @ImportDirectiveSubclass, span: span, state: @mut ImportState) { @@ -1873,7 +1872,7 @@ pub impl Resolver { debug!("(building import directive) building import \ directive: privacy %? %s::%s", privacy, - self.idents_to_str(module_path.get()), + self.idents_to_str(directive.module_path), *self.session.str_of(target)); match module_.import_resolutions.find(&target) { @@ -1887,7 +1886,7 @@ pub impl Resolver { let resolution = @mut ImportResolution(privacy, span, state); - let name = self.idents_to_str(module_path.get()); + let name = self.idents_to_str(directive.module_path); // Don't warn about unused intrinsics because they're // automatically appended to all files if name == ~"intrinsic::rusti" { @@ -1982,13 +1981,13 @@ pub impl Resolver { let import_count = module.imports.len(); while module.resolved_import_count < import_count { let import_index = module.resolved_import_count; - let import_directive = module.imports.get_elt(import_index); + let import_directive = module.imports[import_index]; match self.resolve_import_for_module(module, import_directive) { Failed => { // We presumably emitted an error. Continue. - let idents = import_directive.module_path.get(); let msg = fmt!("failed to resolve import: %s", - *self.import_path_to_str(idents, + *self.import_path_to_str( + import_directive.module_path, *import_directive.subclass)); self.session.span_err(import_directive.span, msg); } @@ -2005,7 +2004,7 @@ pub impl Resolver { } } - fn idents_to_str(@mut self, idents: ~[ident]) -> ~str { + fn idents_to_str(@mut self, idents: &[ident]) -> ~str { let ident_strs = do idents.map |ident| { /*bad*/ copy *self.session.str_of(*ident) }; @@ -2043,11 +2042,11 @@ pub impl Resolver { import_directive: @ImportDirective) -> ResolveResult<()> { let mut resolution_result = Failed; - let module_path = import_directive.module_path; + let module_path = &import_directive.module_path; debug!("(resolving import for module) resolving import `%s::...` in \ `%s`", - self.idents_to_str(module_path.get()), + self.idents_to_str(*module_path), self.module_to_str(module_)); // First, resolve the module path for the directive, if necessary. @@ -2056,7 +2055,7 @@ pub impl Resolver { Some(self.graph_root.get_module()) } else { match self.resolve_module_path_for_import(module_, - module_path, + *module_path, DontUseLexicalScope, import_directive.span) { @@ -2574,21 +2573,21 @@ pub impl Resolver { /// Resolves the given module path from the given root `module_`. fn resolve_module_path_from_root(@mut self, module_: @mut Module, - module_path: @DVec, + module_path: ~[ident], index: uint, span: span, mut name_search_type: NameSearchType) -> ResolveResult<@mut Module> { let mut search_module = module_; let mut index = index; - let module_path_len = (*module_path).len(); + let module_path_len = module_path.len(); // Resolve the module part of the path. This does not involve looking // upward though scope chains; we simply resolve names directly in // modules as we go. while index < module_path_len { - let name = (*module_path).get_elt(index); + let name = module_path[index]; match self.resolve_name_in_module(search_module, name, TypeNS, @@ -2659,7 +2658,7 @@ pub impl Resolver { /// rooted at the given module. fn resolve_module_path_for_import(@mut self, module_: @mut Module, - module_path: @DVec, + module_path: ~[ident], use_lexical_scope: UseLexicalScopeFlag, span: span) -> ResolveResult<@mut Module> { @@ -2668,7 +2667,7 @@ pub impl Resolver { debug!("(resolving module path for import) processing `%s` rooted at \ `%s`", - self.idents_to_str((*module_path).get()), + self.idents_to_str(module_path), self.module_to_str(module_)); // Resolve the module prefix, if any. @@ -2704,7 +2703,7 @@ pub impl Resolver { // scope and then proceed to resolve below that. let result = self.resolve_module_in_lexical_scope( module_, - module_path.get_elt(0)); + module_path[0]); match result { Failed => { self.session.span_err(span, @@ -2945,7 +2944,7 @@ pub impl Resolver { */ fn resolve_module_prefix(@mut self, module_: @mut Module, - module_path: @DVec) + module_path: ~[ident]) -> ResolveResult { let interner = self.session.parse_sess.interner; @@ -2953,11 +2952,11 @@ pub impl Resolver { // top of the crate otherwise. let mut containing_module; let mut i; - if *interner.get(module_path.get_elt(0)) == ~"self" { + if *interner.get(module_path[0]) == ~"self" { containing_module = self.get_nearest_normal_module_parent_or_self(module_); i = 1; - } else if *interner.get(module_path.get_elt(0)) == ~"super" { + } else if *interner.get(module_path[0]) == ~"super" { containing_module = self.get_nearest_normal_module_parent_or_self(module_); i = 0; // We'll handle `super` below. @@ -2967,7 +2966,7 @@ pub impl Resolver { // Now loop through all the `super`s we find. while i < module_path.len() && - *interner.get(module_path.get_elt(i)) == ~"super" { + *interner.get(module_path[i]) == ~"super" { debug!("(resolving module prefix) resolving `super` at %s", self.module_to_str(containing_module)); match self.get_nearest_normal_module_parent(containing_module) { @@ -3064,7 +3063,7 @@ pub impl Resolver { let index = module_.resolved_import_count; let import_count = module_.imports.len(); if index != import_count { - self.session.span_err(module_.imports.get_elt(index).span, + self.session.span_err(module_.imports[index].span, ~"unresolved import"); } @@ -3283,7 +3282,7 @@ pub impl Resolver { // wrappers. fn upvarify(@mut self, - ribs: @DVec<@Rib>, + ribs: &mut ~[@Rib], rib_index: uint, def_like: def_like, span: span, @@ -3313,9 +3312,8 @@ pub impl Resolver { } let mut rib_index = rib_index + 1; - while rib_index < (*ribs).len() { - let rib = (*ribs).get_elt(rib_index); - match rib.kind { + while rib_index < ribs.len() { + match ribs[rib_index].kind { NormalRibKind => { // Nothing to do. Continue. } @@ -3393,7 +3391,7 @@ pub impl Resolver { } fn search_ribs(@mut self, - ribs: @DVec<@Rib>, + ribs: &mut ~[@Rib], name: ident, span: span, allow_capturing_self: AllowCapturingSelfFlag) @@ -3401,14 +3399,13 @@ pub impl Resolver { // FIXME #4950: This should not use a while loop. // FIXME #4950: Try caching? - let mut i = (*ribs).len(); + let mut i = ribs.len(); while i != 0 { i -= 1; - let rib = (*ribs).get_elt(i); - match rib.bindings.find(&name) { + match ribs[i].bindings.find(&name) { Some(def_like) => { return self.upvarify(ribs, i, def_like, span, - allow_capturing_self); + allow_capturing_self); } None => { // Continue. @@ -3502,7 +3499,7 @@ pub impl Resolver { item_trait(ref generics, ref traits, ref methods) => { // Create a new rib for the self type. let self_type_rib = @Rib(NormalRibKind); - (*self.type_ribs).push(self_type_rib); + self.type_ribs.push(self_type_rib); self_type_rib.bindings.insert(self.type_self_ident, dl_def(def_self_ty(item.id))); @@ -3573,7 +3570,7 @@ pub impl Resolver { } } - (*self.type_ribs).pop(); + self.type_ribs.pop(); } item_struct(struct_def, ref generics) => { @@ -3706,15 +3703,15 @@ pub impl Resolver { } fn with_label_rib(@mut self, f: fn()) { - (*self.label_ribs).push(@Rib(NormalRibKind)); + self.label_ribs.push(@Rib(NormalRibKind)); f(); - (*self.label_ribs).pop(); + self.label_ribs.pop(); } fn with_constant_rib(@mut self, f: fn()) { - (*self.value_ribs).push(@Rib(ConstantItemRibKind)); + self.value_ribs.push(@Rib(ConstantItemRibKind)); f(); - (*self.value_ribs).pop(); + self.value_ribs.pop(); } fn resolve_function(@mut self, @@ -3726,11 +3723,11 @@ pub impl Resolver { visitor: ResolveVisitor) { // Create a value rib for the function. let function_value_rib = @Rib(rib_kind); - (*self.value_ribs).push(function_value_rib); + self.value_ribs.push(function_value_rib); // Create a label rib for the function. let function_label_rib = @Rib(rib_kind); - (*self.label_ribs).push(function_label_rib); + self.label_ribs.push(function_label_rib); // If this function has type parameters, add them now. do self.with_type_parameter_rib(type_parameters) { @@ -3790,8 +3787,8 @@ pub impl Resolver { debug!("(resolving function) leaving function"); } - (*self.label_ribs).pop(); - (*self.value_ribs).pop(); + self.label_ribs.pop(); + self.value_ribs.pop(); } fn resolve_type_parameters(@mut self, @@ -3891,10 +3888,10 @@ pub impl Resolver { visitor); // Resolve the trait reference, if necessary. - let original_trait_refs = self.current_trait_refs; + let original_trait_refs; match opt_trait_reference { Some(trait_reference) => { - let new_trait_refs = @DVec(); + let mut new_trait_refs = ~[]; match self.resolve_path( trait_reference.path, TypeNS, true, visitor) { None => { @@ -3906,13 +3903,17 @@ pub impl Resolver { self.record_def(trait_reference.ref_id, def); // Record the current trait reference. - (*new_trait_refs).push(def_id_of_def(def)); + new_trait_refs.push(def_id_of_def(def)); } } // Record the current set of trait references. - self.current_trait_refs = Some(new_trait_refs); + let mut old = Some(new_trait_refs); + self.current_trait_refs <-> old; + original_trait_refs = Some(old); + } + None => { + original_trait_refs = None; } - None => () } // Resolve the self type. @@ -3945,7 +3946,10 @@ pub impl Resolver { } // Restore the original trait references. - self.current_trait_refs = original_trait_refs; + match original_trait_refs { + Some(r) => { self.current_trait_refs = r; } + None => () + } } } @@ -4032,7 +4036,7 @@ pub impl Resolver { } fn resolve_arm(@mut self, arm: &arm, visitor: ResolveVisitor) { - (*self.value_ribs).push(@Rib(NormalRibKind)); + self.value_ribs.push(@Rib(NormalRibKind)); let bindings_list = HashMap(); for arm.pats.each |pattern| { @@ -4047,12 +4051,12 @@ pub impl Resolver { visit_expr_opt(arm.guard, (), visitor); self.resolve_block(&arm.body, visitor); - (*self.value_ribs).pop(); + self.value_ribs.pop(); } fn resolve_block(@mut self, block: &blk, visitor: ResolveVisitor) { debug!("(resolving block) entering block"); - (*self.value_ribs).push(@Rib(NormalRibKind)); + self.value_ribs.push(@Rib(NormalRibKind)); // Move down in the graph, if there's an anonymous module rooted here. let orig_module = self.current_module; @@ -4071,7 +4075,7 @@ pub impl Resolver { // Move back up. self.current_module = orig_module; - (*self.value_ribs).pop(); + self.value_ribs.pop(); debug!("(resolving block) leaving block"); } @@ -4251,7 +4255,8 @@ pub impl Resolver { Some(bindings_list) if !bindings_list.contains_key(&ident) => { - let last_rib = (*self.value_ribs).last(); + let last_rib = self.value_ribs[ + self.value_ribs.len() - 1]; last_rib.bindings.insert(ident, dl_def(def)); bindings_list.insert(ident, pat_id); @@ -4270,7 +4275,8 @@ pub impl Resolver { // Not bound in the same pattern: do nothing } None => { - let last_rib = (*self.value_ribs).last(); + let last_rib = self.value_ribs[ + self.value_ribs.len() - 1]; last_rib.bindings.insert(ident, dl_def(def)); } @@ -4510,14 +4516,14 @@ pub impl Resolver { } } - fn intern_module_part_of_path(@mut self, path: @path) -> @DVec { - let module_path_idents = @DVec(); + fn intern_module_part_of_path(@mut self, path: @path) -> ~[ident] { + let mut module_path_idents = ~[]; for path.idents.eachi |index, ident| { if index == path.idents.len() - 1 { break; } - (*module_path_idents).push(*ident); + module_path_idents.push(*ident); } return module_path_idents; @@ -4539,7 +4545,7 @@ pub impl Resolver { self.session.span_err(path.span, fmt!("use of undeclared module `%s`", self.idents_to_str( - (*module_path_idents).get()))); + module_path_idents))); return None; } @@ -4587,8 +4593,8 @@ pub impl Resolver { Failed => { self.session.span_err(path.span, fmt!("use of undeclared module `::%s`", - self.idents_to_str - ((*module_path_idents).get()))); + self.idents_to_str( + module_path_idents))); return None; } @@ -4625,12 +4631,13 @@ pub impl Resolver { let mut search_result; match namespace { ValueNS => { - search_result = self.search_ribs(self.value_ribs, ident, span, + search_result = self.search_ribs(&mut self.value_ribs, ident, + span, DontAllowCapturingSelf); } TypeNS => { - search_result = self.search_ribs(self.type_ribs, ident, span, - AllowCapturingSelf); + search_result = self.search_ribs(&mut self.type_ribs, ident, + span, AllowCapturingSelf); } } @@ -4688,8 +4695,7 @@ pub impl Resolver { let mut j = self.value_ribs.len(); while j != 0 { j -= 1; - let rib = self.value_ribs.get_elt(j); - for rib.bindings.each_entry |e| { + for self.value_ribs[j].bindings.each_entry |e| { vec::push(&mut maybes, copy *self.session.str_of(e.key)); vec::push(&mut values, uint::max_value); } @@ -4721,8 +4727,7 @@ pub impl Resolver { let mut i = self.type_ribs.len(); while i != 0 { i -= 1; - let rib = self.type_ribs.get_elt(i); - match rib.kind { + match self.type_ribs[i].kind { MethodRibKind(node_id, _) => for self.crate.node.module.items.each |item| { if item.id == node_id { @@ -4839,14 +4844,15 @@ pub impl Resolver { expr_loop(_, Some(label)) => { do self.with_label_rib { let def_like = dl_def(def_label(expr.id)); - self.label_ribs.last().bindings.insert(label, def_like); + let rib = self.label_ribs[self.label_ribs.len() - 1]; + rib.bindings.insert(label, def_like); visit_expr(expr, (), visitor); } } expr_break(Some(label)) | expr_again(Some(label)) => { - match self.search_ribs(self.label_ribs, label, expr.span, + match self.search_ribs(&mut self.label_ribs, label, expr.span, DontAllowCapturingSelf) { None => self.session.span_err(expr.span, @@ -4873,11 +4879,11 @@ pub impl Resolver { match expr.node { expr_field(_, ident, _) => { let traits = self.search_for_traits_containing_method(ident); - self.trait_map.insert(expr.id, traits); + self.trait_map.insert(expr.id, @mut traits); } expr_method_call(_, ident, _, _, _) => { let traits = self.search_for_traits_containing_method(ident); - self.trait_map.insert(expr.id, traits); + self.trait_map.insert(expr.id, @mut traits); } expr_binary(add, _, _) | expr_assign_op(add, _, _) => { self.add_fixed_trait_for_expr(expr.id, @@ -4948,11 +4954,11 @@ pub impl Resolver { fn search_for_traits_containing_method(@mut self, name: ident) - -> @DVec { + -> ~[def_id] { debug!("(searching for traits containing method) looking for '%s'", *self.session.str_of(name)); - let found_traits = @DVec(); + let mut found_traits = ~[]; let mut search_module = self.current_module; loop { // Look for the current trait. @@ -4960,7 +4966,7 @@ pub impl Resolver { Some(trait_def_ids) => { for trait_def_ids.each |trait_def_id| { self.add_trait_info_if_containing_method( - found_traits, *trait_def_id, name); + &mut found_traits, *trait_def_id, name); } } None => { @@ -4975,7 +4981,7 @@ pub impl Resolver { match def { def_ty(trait_def_id) => { self.add_trait_info_if_containing_method( - found_traits, trait_def_id, name); + &mut found_traits, trait_def_id, name); } _ => { // Continue. @@ -5003,7 +5009,8 @@ pub impl Resolver { def_ty(trait_def_id) => { let added = self. add_trait_info_if_containing_method( - found_traits, trait_def_id, name); + &mut found_traits, + trait_def_id, name); if added { import_resolution.state.used = true; @@ -5039,7 +5046,7 @@ pub impl Resolver { } fn add_trait_info_if_containing_method(@mut self, - found_traits: @DVec, + found_traits: &mut ~[def_id], trait_def_id: def_id, name: ident) -> bool { @@ -5056,7 +5063,7 @@ pub impl Resolver { trait_def_id.crate, trait_def_id.node, *self.session.str_of(name)); - (*found_traits).push(trait_def_id); + found_traits.push(trait_def_id); true } Some(_) | None => { @@ -5068,9 +5075,7 @@ pub impl Resolver { fn add_fixed_trait_for_expr(@mut self, expr_id: node_id, +trait_id: def_id) { - let traits = @DVec(); - traits.push(trait_id); - self.trait_map.insert(expr_id, traits); + self.trait_map.insert(expr_id, @mut ~[trait_id]); } fn record_def(@mut self, node_id: node_id, def: def) { @@ -5225,7 +5230,7 @@ pub impl Resolver { /// A somewhat inefficient routine to obtain the name of a module. fn module_to_str(@mut self, module_: @mut Module) -> ~str { - let idents = DVec(); + let mut idents = ~[]; let mut current_module = module_; loop { match current_module.parent_link { @@ -5246,7 +5251,7 @@ pub impl Resolver { if idents.len() == 0 { return ~"???"; } - return self.idents_to_str(vec::reversed(idents.get())); + return self.idents_to_str(vec::reversed(idents)); } fn dump_module(@mut self, module_: @mut Module) { diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 072a52a96b809..8411064c57aef 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -167,8 +167,6 @@ use middle::trans::type_of; use middle::ty; use util::common::indenter; -use core::dvec::DVec; -use core::dvec; use std::oldmap::HashMap; use syntax::ast; use syntax::ast::ident; @@ -553,7 +551,7 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint, // Reorder the patterns into the same order they were // specified in the struct definition. Also fill in // unspecified fields with dummy. - let reordered_patterns = dvec::DVec(); + let mut reordered_patterns = ~[]; for ty::lookup_struct_fields(tcx, struct_id).each |field| { match field_pats.find(|p| @@ -562,7 +560,7 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint, Some(fp) => reordered_patterns.push(fp.pat) } } - Some(dvec::unwrap(reordered_patterns)) + Some(reordered_patterns) } else { None } @@ -764,32 +762,32 @@ pub fn enter_region(bcx: block, // on a set of enum variants or a literal. pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] { let ccx = bcx.ccx(); - fn add_to_set(tcx: ty::ctxt, set: &DVec, +val: Opt) { + fn add_to_set(tcx: ty::ctxt, set: &mut ~[Opt], +val: Opt) { if set.any(|l| opt_eq(tcx, l, &val)) {return;} set.push(val); } - let found = DVec(); - for vec::each(m) |br| { + let mut found = ~[]; + for m.each |br| { let cur = br.pats[col]; match /*bad*/copy cur.node { ast::pat_lit(l) => { - add_to_set(ccx.tcx, &found, lit(ExprLit(l))); + add_to_set(ccx.tcx, &mut found, lit(ExprLit(l))); } ast::pat_ident(*) => { // This is one of: an enum variant, a unit-like struct, or a // variable binding. match ccx.tcx.def_map.find(&cur.id) { Some(ast::def_variant(*)) => { - add_to_set(ccx.tcx, &found, + add_to_set(ccx.tcx, &mut found, variant_opt(bcx, cur.id)); } Some(ast::def_struct(*)) => { - add_to_set(ccx.tcx, &found, + add_to_set(ccx.tcx, &mut found, lit(UnitLikeStructLit(cur.id))); } Some(ast::def_const(const_did)) => { - add_to_set(ccx.tcx, &found, + add_to_set(ccx.tcx, &mut found, lit(ConstLit(const_did))); } _ => {} @@ -800,26 +798,26 @@ pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] { // struct-like enum variant, or a struct. match ccx.tcx.def_map.find(&cur.id) { Some(ast::def_variant(*)) => { - add_to_set(ccx.tcx, &found, + add_to_set(ccx.tcx, &mut found, variant_opt(bcx, cur.id)); } _ => {} } } ast::pat_range(l1, l2) => { - add_to_set(ccx.tcx, &found, range(l1, l2)); + add_to_set(ccx.tcx, &mut found, range(l1, l2)); } ast::pat_vec(elems, tail) => { let opt = match tail { None => vec_len_eq(elems.len()), Some(_) => vec_len_ge(elems.len()) }; - add_to_set(ccx.tcx, &found, opt); + add_to_set(ccx.tcx, &mut found, opt); } _ => {} } } - return dvec::unwrap(found); + return found; } pub struct ExtractedBlock { @@ -1074,7 +1072,7 @@ pub fn compare_values(cx: block, pub fn store_non_ref_bindings(bcx: block, data: &ArmData, - opt_temp_cleanups: Option<&DVec>) + opt_temp_cleanups: Option<&mut ~[ValueRef]>) -> block { /*! * @@ -1166,8 +1164,8 @@ pub fn compile_guard(bcx: block, let _indenter = indenter(); let mut bcx = bcx; - let temp_cleanups = DVec(); - bcx = store_non_ref_bindings(bcx, data, Some(&temp_cleanups)); + let mut temp_cleanups = ~[]; + bcx = store_non_ref_bindings(bcx, data, Some(&mut temp_cleanups)); bcx = insert_lllocals(bcx, data, false); let val = unpack_result!(bcx, { @@ -1627,7 +1625,7 @@ pub fn trans_match_inner(scope_cx: block, let lldiscr = discr_datum.to_ref_llval(bcx); compile_submatch(bcx, matches, ~[lldiscr], chk); - let arm_cxs = DVec(); + let mut arm_cxs = ~[]; for arm_datas.each |arm_data| { let mut bcx = arm_data.bodycx; @@ -1647,7 +1645,7 @@ pub fn trans_match_inner(scope_cx: block, arm_cxs.push(bcx); } - bcx = controlflow::join_blocks(scope_cx, dvec::unwrap(arm_cxs)); + bcx = controlflow::join_blocks(scope_cx, arm_cxs); return bcx; fn mk_fail(bcx: block, sp: span, msg: @~str, diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 082c64ced8ed7..978b1ed16d841 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -29,8 +29,6 @@ use util::common::{indenter}; use core::cast; use core::cmp; -use core::dvec::DVec; -use core::dvec; use core::ops; use core::option; use core::ptr::to_unsafe_ptr; @@ -213,7 +211,7 @@ pub enum AutoRefKind { // This is a map from ID of each implementation to the method info and trait // method ID of each of the default methods belonging to the trait that that // implementation implements. -pub type ProvidedMethodsMap = HashMap>; +pub type ProvidedMethodsMap = HashMap; // Stores the method info and definition ID of the associated trait method for // each instantiation of each provided method. @@ -3522,7 +3520,7 @@ pub fn trait_supertraits(cx: ctxt, // Get the supertraits out of the metadata and create the // InstantiatedTraitRef for each. - let result = dvec::DVec(); + let mut result = ~[]; for csearch::get_supertraits(cx, id).each |trait_type| { match get(*trait_type).sty { ty_trait(def_id, ref substs, _) => { @@ -3539,7 +3537,7 @@ pub fn trait_supertraits(cx: ctxt, } // Unwrap and return the result. - return @dvec::unwrap(result); + return @result; } pub fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] { diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index b7c4fff801faf..0bcbb3012cf10 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -95,7 +95,6 @@ use middle::typeck::{method_self, method_static, method_trait, method_super}; use util::common::indenter; use util::ppaux::expr_repr; -use core::dvec::DVec; use core::result; use core::uint; use core::vec; @@ -127,8 +126,8 @@ pub fn lookup( m_name: m_name, supplied_tps: supplied_tps, impl_dups: HashMap(), - inherent_candidates: DVec(), - extension_candidates: DVec(), + inherent_candidates: @mut ~[], + extension_candidates: @mut ~[], deref_args: deref_args, }; let mme = lcx.do_lookup(self_ty); @@ -145,8 +144,8 @@ pub struct LookupContext { m_name: ast::ident, supplied_tps: &self/[ty::t], impl_dups: HashMap, - inherent_candidates: DVec, - extension_candidates: DVec, + inherent_candidates: @mut ~[Candidate], + extension_candidates: @mut ~[Candidate], deref_args: check::DerefArgs, } @@ -188,7 +187,7 @@ pub impl LookupContext/&self { self.push_inherent_candidates(self_ty); self.push_extension_candidates(self_ty); - let enum_dids = DVec(); + let mut enum_dids = ~[]; let mut self_ty = self_ty; let mut autoderefs = 0; loop { @@ -224,7 +223,7 @@ pub impl LookupContext/&self { } } - match self.deref(self_ty, &enum_dids) { + match self.deref(self_ty, &mut enum_dids) { None => { break; } Some(ty) => { self_ty = ty; @@ -236,7 +235,7 @@ pub impl LookupContext/&self { self.search_for_autosliced_method(self_ty, autoderefs) } - fn deref(ty: ty::t, enum_dids: &DVec) -> Option { + fn deref(ty: ty::t, enum_dids: &mut ~[ast::def_id]) -> Option { match ty::get(ty).sty { ty_enum(did, _) => { // Watch out for newtype'd enums like "enum t = @T". @@ -272,7 +271,7 @@ pub impl LookupContext/&self { * example, if the receiver is @@C where `C` is a struct type, * we'll want to find the inherent impls for `C`. */ - let enum_dids = DVec(); + let mut enum_dids = ~[]; let mut self_ty = self_ty; loop { match get(self_ty).sty { @@ -307,7 +306,7 @@ pub impl LookupContext/&self { // n.b.: Generally speaking, we only loop if we hit the // fallthrough case in the match above. The exception // would be newtype enums. - self_ty = match self.deref(self_ty, &enum_dids) { + self_ty = match self.deref(self_ty, &mut enum_dids) { None => { return; } Some(ty) => { ty } } @@ -330,7 +329,7 @@ pub impl LookupContext/&self { for opt_impl_infos.each |impl_infos| { for impl_infos.each |impl_info| { self.push_candidates_from_impl( - &self.extension_candidates, *impl_info); + self.extension_candidates, *impl_info); } } @@ -338,7 +337,7 @@ pub impl LookupContext/&self { match self.tcx().provided_methods.find(trait_did) { Some(methods) => { self.push_candidates_from_provided_methods( - &self.extension_candidates, self_ty, *trait_did, + self.extension_candidates, self_ty, *trait_did, methods); } None => {} @@ -606,12 +605,12 @@ pub impl LookupContext/&self { for opt_impl_infos.each |impl_infos| { for impl_infos.each |impl_info| { self.push_candidates_from_impl( - &self.inherent_candidates, *impl_info); + self.inherent_candidates, *impl_info); } } } - fn push_candidates_from_impl(&self, candidates: &DVec, + fn push_candidates_from_impl(&self, candidates: &mut ~[Candidate], impl_info: &resolve::Impl) { if !self.impl_dups.insert(impl_info.did, ()) { return; // already visited @@ -657,10 +656,10 @@ pub impl LookupContext/&self { fn push_candidates_from_provided_methods( &self, - candidates: &DVec, + candidates: &mut ~[Candidate], self_ty: ty::t, trait_def_id: def_id, - methods: @DVec<@ProvidedMethodInfo>) { + methods: &mut ~[@ProvidedMethodInfo]) { debug!("(pushing candidates from provided methods) considering trait \ id %d:%d", trait_def_id.crate, @@ -970,7 +969,7 @@ pub impl LookupContext/&self { // existing code. debug!("searching inherent candidates"); - match self.consider_candidates(self_ty, &self.inherent_candidates) { + match self.consider_candidates(self_ty, self.inherent_candidates) { None => {} Some(mme) => { return Some(mme); @@ -978,7 +977,7 @@ pub impl LookupContext/&self { } debug!("searching extension candidates"); - match self.consider_candidates(self_ty, &self.extension_candidates) { + match self.consider_candidates(self_ty, self.extension_candidates) { None => { return None; } @@ -990,7 +989,7 @@ pub impl LookupContext/&self { fn consider_candidates(&self, self_ty: ty::t, - candidates: &DVec) + candidates: &mut ~[Candidate]) -> Option { let relevant_candidates = diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 8abbb7a9909ff..3e45323807212 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -55,7 +55,6 @@ use syntax::visit::{Visitor, SimpleVisitor}; use syntax::visit::{visit_mod}; use util::ppaux::ty_to_str; -use core::dvec::DVec; use core::result::Ok; use core::hashmap::linear::LinearSet; use core::uint; @@ -151,11 +150,11 @@ pub fn method_to_MethodInfo(ast_method: @method) -> @MethodInfo { pub struct CoherenceInfo { // Contains implementations of methods that are inherent to a type. // Methods in these implementations don't need to be exported. - inherent_methods: HashMap>, + inherent_methods: HashMap, // Contains implementations of methods associated with a trait. For these, // the associated trait must be imported at the call site. - extension_methods: HashMap>, + extension_methods: HashMap, } @@ -372,9 +371,8 @@ pub impl CoherenceChecker { for method `%s`", *self.crate_context.tcx.sess.str_of( provided_method_info.method_info.ident)); - let method_infos = @DVec(); - method_infos.push(provided_method_info); - pmm.insert(local_def(impl_id), method_infos); + pmm.insert(local_def(impl_id), + @mut ~[provided_method_info]); } } } @@ -386,7 +384,7 @@ pub impl CoherenceChecker { match self.crate_context.coherence_info.inherent_methods .find(&base_def_id) { None => { - implementation_list = @DVec(); + implementation_list = @mut ~[]; self.crate_context.coherence_info.inherent_methods .insert(base_def_id, implementation_list); } @@ -403,7 +401,7 @@ pub impl CoherenceChecker { match self.crate_context.coherence_info.extension_methods .find(&trait_id) { None => { - implementation_list = @DVec(); + implementation_list = @mut ~[]; self.crate_context.coherence_info.extension_methods .insert(trait_id, implementation_list); } @@ -741,13 +739,13 @@ pub impl CoherenceChecker { // Converts an implementation in the AST to an Impl structure. fn create_impl_from_item(&self, item: @item) -> @Impl { fn add_provided_methods(all_methods: &mut ~[@MethodInfo], - all_provided_methods: ~[@ProvidedMethodInfo], - sess: driver::session::Session) { + all_provided_methods: &mut ~[@ProvidedMethodInfo], + sess: driver::session::Session) { for all_provided_methods.each |provided_method| { debug!( "(creating impl) adding provided method `%s` to impl", *sess.str_of(provided_method.method_info.ident)); - vec::push(&mut *all_methods, provided_method.method_info); + vec::push(all_methods, provided_method.method_info); } } @@ -790,7 +788,7 @@ pub impl CoherenceChecker { // Add all provided methods. add_provided_methods( &mut methods, - all_provided.get(), + all_provided, self.crate_context.tcx.sess); } } @@ -943,9 +941,7 @@ pub impl CoherenceChecker { trait_method_def_id: trait_method_info.def_id }; - let method_infos = @DVec(); - method_infos.push(provided_method_info); - pmm.insert(trait_def_id, method_infos); + pmm.insert(trait_def_id, @mut ~[provided_method_info]); } } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 1535156d96c72..6c8bfdb041ddd 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -46,7 +46,6 @@ use middle::typeck::{CrateCtxt, lookup_def_tcx, no_params, write_ty_to_tcx}; use util::common::{indenter, pluralize}; use util::ppaux; -use core::dvec; use core::vec; use syntax::ast::{RegionTyParamBound, TraitTyParamBound}; use syntax::ast; @@ -321,7 +320,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt, let tcx = ccx.tcx; if tcx.supertraits.contains_key(&local_def(id)) { return; } - let instantiated = dvec::DVec(); + let mut instantiated = ~[]; for trait_refs.each |trait_ref| { let (did, tpt) = instantiate_trait_ref(ccx, *trait_ref, rp); if instantiated.any(|other_trait: &InstantiatedTraitRef| @@ -334,8 +333,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt, } instantiated.push(InstantiatedTraitRef { def_id: did, tpt: tpt }); } - tcx.supertraits.insert(local_def(id), - @dvec::unwrap(instantiated)); + tcx.supertraits.insert(local_def(id), @instantiated); } /** diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index e9843c8a075a0..35c901c7528de 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -549,7 +549,6 @@ use util::ppaux::note_and_explain_region; use core::cell::{Cell, empty_cell}; use core::cmp; -use core::dvec::DVec; use core::result::{Err, Ok, Result}; use core::to_bytes; use core::uint; @@ -627,7 +626,7 @@ type CombineMap = HashMap; pub struct RegionVarBindings { tcx: ty::ctxt, - var_spans: DVec, + var_spans: ~[span], constraints: HashMap, lubs: CombineMap, glbs: CombineMap, @@ -653,7 +652,7 @@ pub struct RegionVarBindings { pub fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings { RegionVarBindings { tcx: tcx, - var_spans: DVec(), + var_spans: ~[], values: empty_cell(), constraints: HashMap(), lubs: CombineMap(), From 7f99a02ddb3ff30388ae1dd5db06e332c215fea2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 7 Mar 2013 18:37:22 -0500 Subject: [PATCH 4/7] syntax: Remove uses of DVec --- src/libsyntax/codemap.rs | 9 ++++----- src/libsyntax/diagnostic.rs | 3 +-- src/libsyntax/ext/deriving.rs | 24 +++++++++--------------- src/libsyntax/ext/tt/macro_parser.rs | 18 +++++++++--------- src/libsyntax/print/pprust.rs | 7 +++---- src/libsyntax/util/interner.rs | 7 +++---- 6 files changed, 29 insertions(+), 39 deletions(-) diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index a525c0df5fa08..3397ca91c9624 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -24,7 +24,6 @@ source code snippets, etc. use core::prelude::*; use core::cmp; -use core::dvec::DVec; use core::str; use core::to_bytes; use core::uint; @@ -242,7 +241,7 @@ pub struct FileMap { /// Locations of lines beginnings in the source code lines: @mut ~[BytePos], /// Locations of multi-byte characters in the source code - multibyte_chars: DVec + multibyte_chars: @mut ~[MultiByteChar], } pub impl FileMap { @@ -282,13 +281,13 @@ pub impl FileMap { } pub struct CodeMap { - files: DVec<@FileMap> + files: @mut ~[@FileMap] } pub impl CodeMap { static pub fn new() -> CodeMap { CodeMap { - files: DVec() + files: @mut ~[], } } @@ -315,7 +314,7 @@ pub impl CodeMap { name: filename, substr: substr, src: src, start_pos: BytePos(start_pos), lines: @mut ~[], - multibyte_chars: DVec() + multibyte_chars: @mut ~[], }; self.files.push(filemap); diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index e9ea5deda3f84..33e734fbd64cc 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -18,7 +18,6 @@ use core::io; use core::option; use core::str; use core::vec; -use core::dvec::DVec; use std::term; @@ -203,7 +202,7 @@ fn print_diagnostic(topic: ~str, lvl: level, msg: &str) { io::stderr().write_str(fmt!(" %s\n", msg)); } -pub fn collect(messages: @DVec<~str>) +pub fn collect(messages: @mut ~[~str]) -> @fn(Option<(@codemap::CodeMap, span)>, &str, level) { let f: @fn(Option<(@codemap::CodeMap, span)>, &str, level) = |_o, msg: &str, _l| { messages.push(msg.to_str()); }; diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs index 8c12bbad3607b..a1514bc3eabdb 100644 --- a/src/libsyntax/ext/deriving.rs +++ b/src/libsyntax/ext/deriving.rs @@ -29,7 +29,6 @@ use parse::token::special_idents::clownshoes_extensions; use ast_util; use opt_vec; -use core::dvec; use core::uint; enum Junction { @@ -99,7 +98,7 @@ fn expand_deriving(cx: ext_ctxt, expand_deriving_struct_def: ExpandDerivingStructDefFn, expand_deriving_enum_def: ExpandDerivingEnumDefFn) -> ~[@item] { - let result = dvec::DVec(); + let mut result = ~[]; for in_items.each |item| { result.push(copy *item); match item.node { @@ -120,7 +119,7 @@ fn expand_deriving(cx: ext_ctxt, _ => () } } - dvec::unwrap(result) + result } fn create_impl_item(cx: ext_ctxt, span: span, +item: item_) -> @item { @@ -202,14 +201,13 @@ fn create_self_type_with_params(cx: ext_ctxt, generics: &Generics) -> @Ty { // Create the type parameters on the `self` path. - let self_ty_params = dvec::DVec(); + let mut self_ty_params = ~[]; for generics.ty_params.each |ty_param| { let self_ty_param = build::mk_simple_ty_path(cx, span, ty_param.ident); self_ty_params.push(self_ty_param); } - let self_ty_params = dvec::unwrap(self_ty_params); // Create the type of `self`. let self_type = build::mk_raw_path_(span, @@ -433,7 +431,7 @@ fn create_subpatterns(cx: ext_ctxt, prefix: ~str, n: uint) -> ~[@pat] { - let subpats = dvec::DVec(); + let mut subpats = ~[]; for uint::range(0, n) |_i| { // Create the subidentifier. let index = subpats.len().to_str(); @@ -445,7 +443,7 @@ fn create_subpatterns(cx: ext_ctxt, let subpat = build::mk_pat(cx, span, subpat); subpats.push(subpat); } - return dvec::unwrap(subpats); + return subpats; } fn is_struct_tuple(struct_def: &struct_def) -> bool { @@ -809,7 +807,7 @@ fn expand_deriving_iter_bytes_struct_method(cx: ext_ctxt, let self_ident = cx.ident_of(~"self"); // Create the body of the method. - let statements = dvec::DVec(); + let mut statements = ~[]; for struct_def.fields.each |struct_field| { match struct_field.node.kind { named_field(ident, _, _) => { @@ -833,7 +831,6 @@ fn expand_deriving_iter_bytes_struct_method(cx: ext_ctxt, } // Create the method itself. - let statements = dvec::unwrap(statements); return create_iter_bytes_method(cx, span, statements); } @@ -942,9 +939,9 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt, } // Create the arms of the self match in the method body. - let self_arms = dvec::DVec(); + let mut self_arms = ~[]; for enum_definition.variants.each |self_variant| { - let other_arms = dvec::DVec(); + let mut other_arms = ~[]; // Create the matching pattern. let matching_pat = create_enum_variant_pattern(cx, @@ -1026,7 +1023,6 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt, // Create the self pattern body. let other_expr = build::mk_path(cx, span, ~[ other_ident ]); let other_expr = build::mk_unary(cx, span, deref, other_expr); - let other_arms = dvec::unwrap(other_arms); let other_match_expr = expr_match(other_expr, other_arms); let other_match_expr = build::mk_expr(cx, span, @@ -1047,7 +1043,6 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt, // Create the method body. let self_expr = build::mk_path(cx, span, ~[ self_ident ]); let self_expr = build::mk_unary(cx, span, deref, self_expr); - let self_arms = dvec::unwrap(self_arms); let self_match_expr = expr_match(self_expr, self_arms); let self_match_expr = build::mk_expr(cx, span, self_match_expr); @@ -1148,7 +1143,7 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt, } // Feed the discriminant to the byte iteration function. - let stmts = dvec::DVec(); + let mut stmts = ~[]; let discrim_stmt = call_substructure_iter_bytes_method(cx, span, discriminant); @@ -1167,7 +1162,6 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt, } // Create the pattern body. - let stmts = dvec::unwrap(stmts); let match_body_block = build::mk_block_(cx, span, stmts); // Create the arm. diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index c66e726bbf772..88797a152066a 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -19,8 +19,6 @@ use parse::parser::Parser; use parse::token::{Token, EOF, to_str, nonterminal}; use parse::token; -use core::dvec::DVec; -use core::dvec; use core::option::{Option, Some, None}; use core::str; use core::uint; @@ -115,7 +113,7 @@ pub struct MatcherPos { sep: Option, idx: uint, up: matcher_pos_up, // mutable for swapping only - matches: ~[DVec<@named_match>], + matches: ~[~[@named_match]], match_lo: uint, match_hi: uint, sp_lo: BytePos, } @@ -151,7 +149,7 @@ pub fn initial_matcher_pos(+ms: ~[matcher], +sep: Option, lo: BytePos) } } } - let matches = vec::from_fn(count_names(ms), |_i| dvec::DVec()); + let matches = vec::from_fn(count_names(ms), |_i| ~[]); ~MatcherPos { elts: ms, sep: sep, @@ -283,7 +281,7 @@ pub fn parse( // Only touch the binders we have actually bound for uint::range(ei.match_lo, ei.match_hi) |idx| { - let sub = ei.matches[idx].get(); + let sub = ei.matches[idx]; new_pos.matches[idx] .push(@matched_seq(sub, mk_sp(ei.sp_lo, @@ -331,7 +329,7 @@ pub fn parse( } let matches = vec::map(ei.matches, // fresh, same size: - |_m| DVec::<@named_match>()); + |_m| ~[]); let ei_t = ei; cur_eis.push(~MatcherPos { elts: copy *matchers, @@ -358,9 +356,11 @@ pub fn parse( /* error messages here could be improved with links to orig. rules */ if tok == EOF { if eof_eis.len() == 1u { - return success( - nameize(sess, ms, - eof_eis[0u].matches.map(|dv| dv.pop()))); + let mut v = ~[]; + for vec::each_mut(eof_eis[0u].matches) |dv| { + v.push(dv.pop()); + } + return success(nameize(sess, ms, v)); } else if eof_eis.len() > 1u { return error(sp, ~"Ambiguity: multiple successful parses"); } else { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 4a8176abc6f1d..c68341c20fa4c 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -28,7 +28,6 @@ use print::pp; use print::pprust; use core::char; -use core::dvec::DVec; use core::io; use core::str; use core::u64; @@ -63,7 +62,7 @@ pub struct ps { comments: Option<~[comments::cmnt]>, literals: Option<~[comments::lit]>, cur_cmnt_and_lit: @mut CurrentCommentAndLiteral, - boxes: DVec, + boxes: @mut ~[pp::breaks], ann: pp_ann } @@ -88,7 +87,7 @@ pub fn rust_printer(writer: io::Writer, intr: @ident_interner) -> @ps { cur_cmnt: 0, cur_lit: 0 }, - boxes: DVec(), + boxes: @mut ~[], ann: no_ann() }; } @@ -123,7 +122,7 @@ pub fn print_crate(cm: @CodeMap, intr: @ident_interner, cur_cmnt: 0, cur_lit: 0 }, - boxes: DVec(), + boxes: @mut ~[], ann: ann }; print_crate_(s, crate); diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 2c852084aa7ed..7a5708049e9f4 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -13,12 +13,11 @@ // type, and vice versa. use core::prelude::*; -use core::dvec::DVec; use core::hashmap::linear::LinearMap; pub struct Interner { priv map: @mut LinearMap, - priv vect: DVec, + priv vect: @mut ~[T], } // when traits can extend traits, we should extend index to get [] @@ -26,7 +25,7 @@ pub impl Interner { static fn new() -> Interner { Interner { map: @mut LinearMap::new(), - vect: DVec(), + vect: @mut ~[], } } @@ -58,7 +57,7 @@ pub impl Interner { // this isn't "pure" in the traditional sense, because it can go from // failing to returning a value as items are interned. But for typestate, // where we first check a pred and then rely on it, ceasing to fail is ok. - pure fn get(&self, idx: uint) -> T { self.vect.get_elt(idx) } + pure fn get(&self, idx: uint) -> T { self.vect[idx] } fn len(&self) -> uint { self.vect.len() } } From 2c87920f5274ad2df2071ba295e533d606780cf6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 7 Mar 2013 21:49:43 -0500 Subject: [PATCH 5/7] test: Removing dvec uses --- src/librustc/middle/astencode.rs | 2 +- src/test/auxiliary/cci_nested_lib.rs | 8 +- src/test/auxiliary/issue-2631-a.rs | 3 +- src/test/bench/core-vec-append.rs | 76 ------------------- src/test/compile-fail/issue-2590.rs | 6 +- .../call-closure-from-overloaded-op.rs | 2 +- src/test/run-pass/dvec-index-op.rs | 16 ---- src/test/run-pass/dvec-test.rs | 36 --------- src/test/run-pass/issue-2631-b.rs | 2 +- 9 files changed, 9 insertions(+), 142 deletions(-) delete mode 100644 src/test/bench/core-vec-append.rs delete mode 100644 src/test/run-pass/dvec-index-op.rs delete mode 100644 src/test/run-pass/dvec-test.rs diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 1be8112fc807e..6f0bfbb197fac 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -25,7 +25,6 @@ use middle::{ty, typeck, moves}; use middle; use util::ppaux::ty_to_str; -use core::{io, option, vec}; use std::ebml::reader; use std::ebml; use std::serialize; @@ -1210,6 +1209,7 @@ fn mk_ctxt() -> fake_ext_ctxt { #[cfg(test)] fn roundtrip(in_item: Option<@ast::item>) { + use core::io; use std::prettyprint; let in_item = in_item.get(); diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index a818ff58f9440..ab9dc29441a96 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -10,11 +10,9 @@ #[legacy_modes]; -use core::dvec::DVec; - pub struct Entry {key: A, value: B} -pub struct alist { eq_fn: @fn(A,A) -> bool, data: DVec> } +pub struct alist { eq_fn: @fn(A,A) -> bool, data: @mut ~[Entry] } pub fn alist_add(lst: alist, k: A, v: B) { lst.data.push(Entry{key:k, value:v}); @@ -31,12 +29,12 @@ pub fn alist_get(lst: alist, k: A) -> B { #[inline] pub fn new_int_alist() -> alist { fn eq_int(&&a: int, &&b: int) -> bool { a == b } - return alist {eq_fn: eq_int, data: DVec()}; + return alist {eq_fn: eq_int, data: @mut ~[]}; } #[inline] pub fn new_int_alist_2() -> alist { #[inline] fn eq_int(&&a: int, &&b: int) -> bool { a == b } - return alist {eq_fn: eq_int, data: DVec()}; + return alist {eq_fn: eq_int, data: @mut ~[]}; } diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index b1fb7a82c5c8b..f7788c7d57aeb 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -13,10 +13,9 @@ extern mod std; -use core::dvec::*; use std::oldmap::HashMap; -pub type header_map = HashMap<~str, @DVec<@~str>>; +pub type header_map = HashMap<~str, @mut ~[@~str]>; // the unused ty param is necessary so this gets monomorphized pub fn request(req: header_map) { diff --git a/src/test/bench/core-vec-append.rs b/src/test/bench/core-vec-append.rs deleted file mode 100644 index 4117add8926a0..0000000000000 --- a/src/test/bench/core-vec-append.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// A raw test of vector appending performance. - -extern mod std; -use core::dvec::DVec; -use core::io::WriterUtil; - -fn collect_raw(num: uint) -> ~[uint] { - let mut result = ~[]; - for uint::range(0u, num) |i| { - result.push(i); - } - return result; -} - -fn collect_dvec(num: uint) -> ~[uint] { - let result = DVec(); - for uint::range(0u, num) |i| { - result.push(i); - } - return dvec::unwrap(result); -} - -fn main() { - let args = os::args(); - let args = if os::getenv(~"RUST_BENCH").is_some() { - ~[~"", ~"50000000"] - } else if args.len() <= 1u { - ~[~"", ~"100000"] - } else { - args - }; - let max = uint::from_str(args[1]).get(); - let start = std::time::precise_time_s(); - let raw_v = collect_raw(max); - let mid = std::time::precise_time_s(); - let dvec_v = collect_dvec(max); - let end = std::time::precise_time_s(); - - // check each vector - fail_unless!(raw_v.len() == max); - for raw_v.eachi |i, v| { fail_unless!(i == *v); } - fail_unless!(dvec_v.len() == max); - for dvec_v.eachi |i, v| { fail_unless!(i == *v); } - - let raw = mid - start; - let dvec = end - mid; - - let maxf = max as float; - let rawf = raw as float; - let dvecf = dvec as float; - - io::stdout().write_str(fmt!("Raw : %? seconds\n", raw)); - io::stdout().write_str(fmt!(" : %f op/sec\n", maxf/rawf)); - io::stdout().write_str(fmt!("\n")); - io::stdout().write_str(fmt!("Dvec : %? seconds\n", dvec)); - io::stdout().write_str(fmt!(" : %f op/sec\n", maxf/dvecf)); - io::stdout().write_str(fmt!("\n")); - - if dvec < raw { - io::stdout().write_str(fmt!("Dvec is %f%% faster than raw\n", - (rawf - dvecf) / rawf * 100.0)); - } else { - io::stdout().write_str(fmt!("Raw is %f%% faster than dvec\n", - (dvecf - rawf) / dvecf * 100.0)); - } -} diff --git a/src/test/compile-fail/issue-2590.rs b/src/test/compile-fail/issue-2590.rs index 1de311f4de548..5f26adfcdc770 100644 --- a/src/test/compile-fail/issue-2590.rs +++ b/src/test/compile-fail/issue-2590.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::dvec::DVec; - struct parser { - tokens: DVec, + tokens: ~[int], } trait parse { @@ -20,7 +18,7 @@ trait parse { impl parse for parser { fn parse() -> ~[int] { - ::core::dvec::unwrap(self.tokens) //~ ERROR moving out of immutable field + self.tokens //~ ERROR moving out of immutable field } } diff --git a/src/test/run-pass/call-closure-from-overloaded-op.rs b/src/test/run-pass/call-closure-from-overloaded-op.rs index 9d2c6f2319831..cbfae48302bff 100644 --- a/src/test/run-pass/call-closure-from-overloaded-op.rs +++ b/src/test/run-pass/call-closure-from-overloaded-op.rs @@ -11,7 +11,7 @@ fn foo() -> int { 22 } pub fn main() { - let x = dvec::DVec::<@fn() -> int>(); + let x: ~[@fn() -> int] = ~[]; x.push(foo); fail_unless!((x[0])() == 22); } diff --git a/src/test/run-pass/dvec-index-op.rs b/src/test/run-pass/dvec-index-op.rs deleted file mode 100644 index e061464c7b2b6..0000000000000 --- a/src/test/run-pass/dvec-index-op.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn main() { - let x = dvec::DVec(); - x.push(1); - io::println(fmt!("%d", x[0])); -} - diff --git a/src/test/run-pass/dvec-test.rs b/src/test/run-pass/dvec-test.rs deleted file mode 100644 index dff37af9a5936..0000000000000 --- a/src/test/run-pass/dvec-test.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn main() { - let d = dvec::DVec(); - d.push(3); - d.push(4); - fail_unless!(d.get() == ~[3, 4]); - d.set(~[5]); - d.push(6); - d.push(7); - d.push(8); - d.push(9); - d.push(10); - d.push_all(~[11, 12, 13]); - d.push_slice(~[11, 12, 13], 1u, 2u); - - let exp = ~[5, 6, 7, 8, 9, 10, 11, 12, 13, 12]; - fail_unless!(d.get() == exp); - fail_unless!(d.get() == exp); - fail_unless!(d.len() == exp.len()); - - for d.eachi |i, e| { - fail_unless!(*e == exp[i]); - } - - let v = dvec::unwrap(d); - fail_unless!(v == exp); -} diff --git a/src/test/run-pass/issue-2631-b.rs b/src/test/run-pass/issue-2631-b.rs index 79c884f869f3f..66383253f7cb4 100644 --- a/src/test/run-pass/issue-2631-b.rs +++ b/src/test/run-pass/issue-2631-b.rs @@ -21,6 +21,6 @@ use std::oldmap::HashMap; pub fn main() { let v = ~[@~"hi"]; let m: req::header_map = HashMap(); - m.insert(~"METHOD", @dvec::from_vec(v)); + m.insert(~"METHOD", @mut ~[v]); request::(m); } From 59de3853be3b7d9e5306522bdfdb76be69555703 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 7 Mar 2013 21:51:04 -0500 Subject: [PATCH 6/7] core: Remove the dvec module --- src/libcore/core.rc | 11 +- src/libcore/dvec.rs | 355 --------------------------------- src/libcore/iter-trait/dvec.rs | 37 ---- src/libcore/prelude.rs | 1 - 4 files changed, 4 insertions(+), 400 deletions(-) delete mode 100644 src/libcore/dvec.rs delete mode 100644 src/libcore/iter-trait/dvec.rs diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 21d8361868441..79a5d297178e3 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -21,10 +21,10 @@ used features. the floating point types, the `bool` type, tuples, characters, strings, vectors (`vec`), managed boxes (`managed`), owned boxes (`owned`), and unsafe and borrowed pointers (`ptr`). Additionally, `core` provides task management -and creation (`task`), communication primitives (`comm` and `pipes`), an -efficient vector builder (`dvec`), platform abstractions (`os` and `path`), -basic I/O abstractions (`io`), common traits (`cmp`, `num`, `to_str`), and -complete bindings to the C standard library (`libc`). +and creation (`task`), communication primitives (`comm` and `pipes`), platform +abstractions (`os` and `path`), basic I/O abstractions (`io`), common traits +(`cmp`, `num`, `to_str`), and complete bindings to the C standard library +(`libc`). `core` is linked to all crates by default and its contents imported. Implicitly, all crates behave as if they included the following prologue: @@ -141,9 +141,6 @@ pub mod container; pub mod option; pub mod result; pub mod either; -pub mod dvec; -#[path="iter-trait.rs"] #[merge = "iter-trait/dvec.rs"] -pub mod dvec_iter; pub mod dlist; #[path="iter-trait.rs"] #[merge = "iter-trait/dlist.rs"] pub mod dlist_iter; diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs deleted file mode 100644 index 43daf5fa6a5da..0000000000000 --- a/src/libcore/dvec.rs +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*! - -Dynamic vector - -A growable vector that makes use of unique pointers so that the -result can be sent between tasks and so forth. - -Note that recursive use is not permitted. - -*/ - -use cast; -use prelude::*; -use ptr::null; -use vec; - -/** - * A growable, modifiable vector type that accumulates elements into a - * unique vector. - * - * # Limitations on recursive use - * - * This class works by swapping the unique vector out of the data - * structure whenever it is to be used. Therefore, recursive use is not - * permitted. That is, while iterating through a vector, you cannot - * access the vector in any other way or else the program will fail. If - * you wish, you can use the `swap()` method to gain access to the raw - * vector and transform it or use it any way you like. Eventually, we - * may permit read-only access during iteration or other use. - * - * # WARNING - * - * For maximum performance, this type is implemented using some rather - * unsafe code. In particular, this innocent looking `~[mut A]` pointer - * *may be null!* Therefore, it is important you not reach into the - * data structure manually but instead use the provided extensions. - * - * The reason that I did not use an unsafe pointer in the structure - * itself is that I wanted to ensure that the vector would be freed when - * the dvec is dropped. The reason that I did not use an `Option` - * instead of a nullable pointer is that I found experimentally that it - * becomes approximately 50% slower. This can probably be improved - * through optimization. You can run your own experiments using - * `src/test/bench/vec-append.rs`. My own tests found that using null - * pointers achieved about 103 million pushes/second. Using an option - * type could only produce 47 million pushes/second. - */ -pub struct DVec { - mut data: ~[A] -} - -/// Creates a new, empty dvec -pub pure fn DVec() -> DVec { - DVec {data: ~[]} -} - -/// Creates a new dvec with a single element -pub pure fn from_elem(e: A) -> DVec { - DVec {data: ~[e]} -} - -/// Creates a new dvec with the contents of a vector -pub pure fn from_vec(v: ~[A]) -> DVec { - DVec {data: v} -} - -/// Consumes the vector and returns its contents -pub pure fn unwrap(d: DVec) -> ~[A] { - let DVec {data: v} = d; - v -} - -priv impl DVec { - #[inline(always)] - pure fn check_not_borrowed(&self) { - unsafe { - let data: *() = cast::reinterpret_cast(&self.data); - if data.is_null() { - fail!(~"Recursive use of dvec"); - } - } - } - - #[inline(always)] - fn give_back(&self, data: ~[A]) { - unsafe { - self.data = data; - } - } - - #[inline(always)] - fn unwrap(self) -> ~[A] { unwrap(self) } -} - -// In theory, most everything should work with any A, but in practice -// almost nothing works without the copy bound due to limitations -// around closures. -pub impl DVec { - // FIXME (#3758): This should not need to be public. - #[inline(always)] - fn check_out(&self, f: &fn(v: ~[A]) -> B) -> B { - unsafe { - let mut data = cast::reinterpret_cast(&null::<()>()); - data <-> self.data; - let data_ptr: *() = cast::reinterpret_cast(&data); - if data_ptr.is_null() { fail!(~"Recursive use of dvec"); } - return f(data); - } - } - - /// Reserves space for N elements - fn reserve(&self, count: uint) { - vec::reserve(&mut self.data, count) - } - - /** - * Swaps out the current vector and hands it off to a user-provided - * function `f`. The function should transform it however is desired - * and return a new vector to replace it with. - */ - #[inline(always)] - fn swap(&self, f: &fn(v: ~[A]) -> ~[A]) { - self.check_out(|v| self.give_back(f(v))) - } - - /// Returns the number of elements currently in the dvec - #[inline(always)] - pure fn len(&self) -> uint { - self.check_not_borrowed(); - return self.data.len(); - } - - /// Overwrite the current contents - #[inline(always)] - fn set(&self, w: ~[A]) { - self.check_not_borrowed(); - self.data = w; - } - - /// Remove and return the last element - fn pop(&self) -> A { - do self.check_out |v| { - let mut v = v; - let result = v.pop(); - self.give_back(v); - result - } - } - - /// Insert a single item at the front of the list - fn unshift(&self, t: A) { - unsafe { - let mut data = cast::reinterpret_cast(&null::<()>()); - data <-> self.data; - let data_ptr: *() = cast::reinterpret_cast(&data); - if data_ptr.is_null() { fail!(~"Recursive use of dvec"); } - self.data = ~[t]; - self.data.push_all_move(data); - } - } - - /// Append a single item to the end of the list - #[inline(always)] - fn push(&self, t: A) { - self.check_not_borrowed(); - self.data.push(t); - } - - /// Remove and return the first element - fn shift(&self) -> A { - do self.check_out |v| { - let mut v = v; - let result = v.shift(); - self.give_back(v); - result - } - } - - /// Reverse the elements in the list, in place - fn reverse(&self) { - do self.check_out |v| { - let mut v = v; - vec::reverse(v); - self.give_back(v); - } - } - - /// Gives access to the vector as a slice with immutable contents - fn borrow(&self, op: fn(x: &[A]) -> R) -> R { - do self.check_out |v| { - let result = op(v); - self.give_back(v); - result - } - } - - /// Gives access to the vector as a slice with mutable contents - fn borrow_mut(&self, op: &fn(x: &mut [A]) -> R) -> R { - do self.check_out |v| { - let mut v = v; - let result = op(v); - self.give_back(v); - result - } - } -} - -pub impl DVec { - /** - * Append all elements of a vector to the end of the list - * - * Equivalent to `append_iter()` but potentially more efficient. - */ - fn push_all(&self, ts: &[const A]) { - self.push_slice(ts, 0u, vec::len(ts)); - } - - /// Appends elements from `from_idx` to `to_idx` (exclusive) - fn push_slice(&self, ts: &[const A], from_idx: uint, to_idx: uint) { - do self.swap |v| { - let mut v = v; - let new_len = vec::len(v) + to_idx - from_idx; - vec::reserve(&mut v, new_len); - let mut i = from_idx; - while i < to_idx { - v.push(ts[i]); - i += 1u; - } - v - } - } - - /** - * Append all elements of an iterable. - * - * Failure will occur if the iterable's `each()` method - * attempts to access this vector. - */ - /* - fn append_iter>(ts: I) { - do self.swap |v| { - let mut v = match ts.size_hint() { - none { v } - Some(h) { - let len = v.len() + h; - let mut v = v; - vec::reserve(v, len); - v - } - }; - - for ts.each |t| { v.push(*t) }; - v - } - } - */ - - /** - * Gets a copy of the current contents. - * - * See `unwrap()` if you do not wish to copy the contents. - */ - pure fn get(&self) -> ~[A] { - unsafe { - do self.check_out |v| { - let w = copy v; - self.give_back(v); - w - } - } - } - - /// Copy out an individual element - #[inline(always)] - pure fn get_elt(&self, idx: uint) -> A { - self.check_not_borrowed(); - return self.data[idx]; - } - - /// Overwrites the contents of the element at `idx` with `a` - fn set_elt(&self, idx: uint, a: A) { - self.check_not_borrowed(); - self.data[idx] = a; - } - - /** - * Overwrites the contents of the element at `idx` with `a`, - * growing the vector if necessary. New elements will be initialized - * with `initval` - */ - fn grow_set_elt(&self, idx: uint, initval: &A, val: A) { - do self.swap |v| { - let mut v = v; - v.grow_set(idx, initval, val); - v - } - } - - /// Returns the last element, failing if the vector is empty - #[inline(always)] - pure fn last(&self) -> A { - self.check_not_borrowed(); - - let length = self.len(); - if length == 0 { - fail!(~"attempt to retrieve the last element of an empty vector"); - } - - return self.data[length - 1]; - } - - /// Iterates over the elements in reverse order - #[inline(always)] - fn rev_each(&self, f: fn(v: &A) -> bool) { - do self.swap |v| { - // FIXME(#2263)---we should be able to write - // `vec::rev_each(v, f);` but we cannot write now - for vec::rev_each(v) |e| { - if !f(e) { break; } - } - v - } - } - - /// Iterates over the elements and indices in reverse order - #[inline(always)] - fn rev_eachi(&self, f: fn(uint, v: &A) -> bool) { - do self.swap |v| { - // FIXME(#2263)---we should be able to write - // `vec::rev_eachi(v, f);` but we cannot write now - for vec::rev_eachi(v) |i, e| { - if !f(i, e) { break; } - } - v - } - } -} - -impl Index for DVec { - #[inline(always)] - pure fn index(&self, idx: uint) -> A { - self.get_elt(idx) - } -} - diff --git a/src/libcore/iter-trait/dvec.rs b/src/libcore/iter-trait/dvec.rs deleted file mode 100644 index 986aa18ad4ab1..0000000000000 --- a/src/libcore/iter-trait/dvec.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod inst { - use dvec; - use option::{Option, Some}; - - #[allow(non_camel_case_types)] - pub type IMPL_T = dvec::DVec; - - /** - * Iterates through the current contents. - * - * Attempts to access this dvec during iteration will fail. - */ - #[inline(always)] - pub pure fn EACH(self: &IMPL_T, f: fn(v: &A) -> bool) { - unsafe { - do self.swap |v| { - v.each(f); - v - } - } - } - - #[inline(always)] - pub pure fn SIZE_HINT(self: &IMPL_T) -> Option { - Some(self.len()) - } -} diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index e4be0cf98dd4e..2f575ce7d2811 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -50,7 +50,6 @@ pub use bool; pub use cast; pub use char; pub use cmp; -pub use dvec; pub use either; pub use f32; pub use f64; From 62651df2b482af4dc98b0aec6c5f1ad112fab8ec Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 7 Mar 2013 23:44:38 -0500 Subject: [PATCH 7/7] Fix dvec-related fallout in tests --- src/libcore/io.rs | 8 ++---- src/libstd/flatpipes.rs | 15 ++++------ src/libstd/json.rs | 9 ++---- src/libsyntax/parse/mod.rs | 6 ++-- .../call-closure-from-overloaded-op.rs | 2 +- src/test/run-pass/issue-2631-b.rs | 3 +- src/test/run-pass/issue-5275 | Bin 16176 -> 0 bytes src/test/run-pass/issue-5275.rs | 27 ------------------ 8 files changed, 17 insertions(+), 53 deletions(-) delete mode 100755 src/test/run-pass/issue-5275 delete mode 100644 src/test/run-pass/issue-5275.rs diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 34fa4c972ea77..4634eb8793d95 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -1442,17 +1442,15 @@ mod tests { fn bytes_buffer_overwrite() { let wr = BytesWriter(); wr.write(~[0u8, 1u8, 2u8, 3u8]); - fail_unless!(wr.bytes.borrow(|bytes| bytes == ~[0u8, 1u8, 2u8, 3u8])); + fail_unless!(wr.bytes == ~[0u8, 1u8, 2u8, 3u8]); wr.seek(-2, SeekCur); wr.write(~[4u8, 5u8, 6u8, 7u8]); - fail_unless!(wr.bytes.borrow(|bytes| bytes == - ~[0u8, 1u8, 4u8, 5u8, 6u8, 7u8])); + fail_unless!(wr.bytes == ~[0u8, 1u8, 4u8, 5u8, 6u8, 7u8]); wr.seek(-2, SeekEnd); wr.write(~[8u8]); wr.seek(1, SeekSet); wr.write(~[9u8]); - fail_unless!(wr.bytes.borrow(|bytes| bytes == - ~[0u8, 9u8, 4u8, 5u8, 8u8, 7u8])); + fail_unless!(wr.bytes == ~[0u8, 9u8, 4u8, 5u8, 8u8, 7u8]); } #[test] diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index b117834238f4b..897cb4c203403 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -452,13 +452,10 @@ pub mod flatteners { pub fn serialize_value>(val: &T) -> ~[u8] { - let mut bytes_writer = BytesWriter(); - let writer = @bytes_writer as @Writer; - let ser = FromWriter::from_writer(writer); - val.encode(&ser); - let mut ret = ~[]; - ret <-> bytes_writer.bytes; - return ret; + do io::with_bytes_writer |writer| { + let ser = FromWriter::from_writer(writer); + val.encode(&ser); + } } pub trait FromReader { @@ -652,7 +649,7 @@ mod test { chan.send(10); - let bytes = chan.byte_chan.writer.bytes.get(); + let bytes = copy chan.byte_chan.writer.bytes; let reader = BufReader::new(bytes); let port = serial::reader_port(reader); @@ -698,7 +695,7 @@ mod test { chan.send(10); - let bytes = chan.byte_chan.writer.bytes.get(); + let bytes = copy chan.byte_chan.writer.bytes; let reader = BufReader::new(bytes); let port = pod::reader_port(reader); diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 6506d8e3c41a6..9208d415971c6 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -1311,8 +1311,7 @@ mod tests { } } } - check_equal(str::from_bytes(bw.bytes.data), - ~"[\"frog\",[\"Henry\",349]]"); + check_equal(str::from_bytes(bw.bytes), ~"[\"frog\",[\"Henry\",349]]"); } #[test] @@ -1327,8 +1326,7 @@ mod tests { } } } - check_equal(str::from_bytes(bw.bytes.data), - ~"\"jodhpurs\""); + check_equal(str::from_bytes(bw.bytes), ~"\"jodhpurs\""); } #[test] @@ -1340,8 +1338,7 @@ mod tests { do encoder.emit_enum_variant (~"None",37,1242) { } } - check_equal(str::from_bytes(bw.bytes.data), - ~"null"); + check_equal(str::from_bytes(bw.bytes), ~"null"); } #[test] diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 48d3fbe8889e1..a1fc7230dd1f0 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -303,9 +303,9 @@ mod test { use util::testing::*; #[test] fn to_json_str (val: Encodable) -> ~str { - let bw = @io::BytesWriter(); - val.encode(~std::json::Encoder(bw as io::Writer)); - str::from_bytes(bw.bytes.data) + do io::with_str_writer |writer| { + val.encode(~std::json::Encoder(writer)); + } } #[test] fn alltts () { diff --git a/src/test/run-pass/call-closure-from-overloaded-op.rs b/src/test/run-pass/call-closure-from-overloaded-op.rs index cbfae48302bff..39864059fcd48 100644 --- a/src/test/run-pass/call-closure-from-overloaded-op.rs +++ b/src/test/run-pass/call-closure-from-overloaded-op.rs @@ -11,7 +11,7 @@ fn foo() -> int { 22 } pub fn main() { - let x: ~[@fn() -> int] = ~[]; + let mut x: ~[@fn() -> int] = ~[]; x.push(foo); fail_unless!((x[0])() == 22); } diff --git a/src/test/run-pass/issue-2631-b.rs b/src/test/run-pass/issue-2631-b.rs index 66383253f7cb4..5f5e2f9fc3084 100644 --- a/src/test/run-pass/issue-2631-b.rs +++ b/src/test/run-pass/issue-2631-b.rs @@ -15,12 +15,11 @@ extern mod req; extern mod std; use req::*; -use std::oldmap::*; use std::oldmap::HashMap; pub fn main() { let v = ~[@~"hi"]; let m: req::header_map = HashMap(); - m.insert(~"METHOD", @mut ~[v]); + m.insert(~"METHOD", @mut v); request::(m); } diff --git a/src/test/run-pass/issue-5275 b/src/test/run-pass/issue-5275 deleted file mode 100755 index ea8edf5156a63ae2378f0d57d4efde992f3fbcf1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16176 zcmeHOe{37qeLqTZqBM?8Cw1zy%SXxe1*=;THS;}2}i8HIegWk9dIB`)tI=OcQ9{Wi%nr?pH;pD|te8~a!MEvLO#F~Gl=%_c4wQv!px3~#8WMy>#5A||5H2bR$PyM}g3!QV zxdrJ7cyf1ePkH;`cfnuFiQvb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Z)>K6_jF_A6w%5%&vf438j^= z7)$8}DiD{w?2?ozlukiqNQ#PpN2E{$4++#U9n+0)n*~`l9c}GQ;jTndn_Sd-0Mg z@`Mr*w8|NJSVDRT+)W}3NRyChSg_~&Od(A#pU$xA@*J19eqyqb*-gY257e#rw|K0x z(bx4=gAmtxjoIoIq#N&6FDK~1O>bD-{2ksB+>W6aHgpYzo8H>IuYa!Ty1m=Gm@VGw z9oTih&lCK;?4JnlnMc>NbLzx)9UF!YY}d0@=)iWJn}p4rTWk+Dje~3N0^PTJcOTf= cOSn0$U4)yndH>KXq0MLeE^^bp5f8Bc1%|dVrvLx| diff --git a/src/test/run-pass/issue-5275.rs b/src/test/run-pass/issue-5275.rs deleted file mode 100644 index a1b93d99f2814..0000000000000 --- a/src/test/run-pass/issue-5275.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(self: &A) -> int { - if true { - fail!() - } else { - *bar(self.bar) - } -} - -pub fn main() {} - -fn bar(_: &r/mut int) -> &r/int { - fail!() -} - -struct A { - bar: @mut int, -}