diff options
| author | bors <bors@rust-lang.org> | 2014-04-10 15:31:55 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-04-10 15:31:55 -0700 |
| commit | 0156af156d70efd5a3c96d0c5b8fc9bec39a7ae5 (patch) | |
| tree | 7cae8ac126922eee38607c2a0032c85cdad7ba0d /src/libstd | |
| parent | 5bcb76181a3b0df2df5ade348af3a1d29fca795e (diff) | |
| parent | 1f2c18a0afd55bf3a5319d9e3810ec1ac6b3e1bb (diff) | |
auto merge of #13443 : alexcrichton/rust/rollup, r=alexcrichton
Closes #13441 (debuginfo: Fixes and improvements for #12840, #12886, and #13213) Closes #13433 (Remove references to @Trait from a compiler error message) Closes #13430 (Fix outdated lint warning about inner attribute) Closes #13425 (Remove a pile of (mainly) internal `~[]` uses) Closes #13419 (Stop using transmute_mut in RefCell) Closes #13417 (Remove an unnecessary file `src/libnative/io/p`.) Closes #13409 (Closing assorted resolve bugs) Closes #13406 (Generalized the pretty-print entry points to support `-o <file>`.) Closes #13403 (test: Add a test for #7663) Closes #13402 (rustdoc: Prune the paths that do not appear in the index.) Closes #13396 (rustc: Remove absolute rpaths) Closes #13371 (Rename ast::Purity and ast::Impure Function. Closes #7287) Closes #13350 (collections: replace all ~[T] with Vec<T>.)
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/cell.rs | 38 | ||||
| -rw-r--r-- | src/libstd/fmt/parse.rs | 116 | ||||
| -rw-r--r-- | src/libstd/io/extensions.rs | 10 | ||||
| -rw-r--r-- | src/libstd/io/fs.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/signal.rs | 5 | ||||
| -rw-r--r-- | src/libstd/io/test.rs | 1 | ||||
| -rw-r--r-- | src/libstd/local_data.rs | 11 | ||||
| -rw-r--r-- | src/libstd/repr.rs | 17 | ||||
| -rw-r--r-- | src/libstd/rt/at_exit_imp.rs | 7 | ||||
| -rw-r--r-- | src/libstd/rt/rtio.rs | 3 | ||||
| -rw-r--r-- | src/libstd/sync/deque.rs | 16 | ||||
| -rw-r--r-- | src/libstd/sync/mpmc_bounded_queue.rs | 12 |
12 files changed, 120 insertions, 120 deletions
diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 40c6c3ebccf..ec064f4f5ec 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -10,7 +10,6 @@ //! Types dealing with dynamic mutability -use cast; use clone::Clone; use cmp::Eq; use fmt; @@ -70,7 +69,7 @@ impl<T: Copy + fmt::Show> fmt::Show for Cell<T> { /// A mutable memory location with dynamically checked borrow rules pub struct RefCell<T> { value: Unsafe<T>, - borrow: BorrowFlag, + borrow: Cell<BorrowFlag>, nocopy: marker::NoCopy, noshare: marker::NoShare, } @@ -86,22 +85,18 @@ impl<T> RefCell<T> { pub fn new(value: T) -> RefCell<T> { RefCell { value: Unsafe::new(value), + borrow: Cell::new(UNUSED), nocopy: marker::NoCopy, noshare: marker::NoShare, - borrow: UNUSED, } } /// Consumes the `RefCell`, returning the wrapped value. pub fn unwrap(self) -> T { - assert!(self.borrow == UNUSED); + assert!(self.borrow.get() == UNUSED); unsafe{self.value.unwrap()} } - unsafe fn as_mut<'a>(&'a self) -> &'a mut RefCell<T> { - cast::transmute_mut(self) - } - /// Attempts to immutably borrow the wrapped value. /// /// The borrow lasts until the returned `Ref` exits scope. Multiple @@ -109,10 +104,10 @@ impl<T> RefCell<T> { /// /// Returns `None` if the value is currently mutably borrowed. pub fn try_borrow<'a>(&'a self) -> Option<Ref<'a, T>> { - match self.borrow { + match self.borrow.get() { WRITING => None, - _ => { - unsafe { self.as_mut().borrow += 1; } + borrow => { + self.borrow.set(borrow + 1); Some(Ref { parent: self }) } } @@ -140,11 +135,10 @@ impl<T> RefCell<T> { /// /// Returns `None` if the value is currently borrowed. pub fn try_borrow_mut<'a>(&'a self) -> Option<RefMut<'a, T>> { - match self.borrow { - UNUSED => unsafe { - let mut_self = self.as_mut(); - mut_self.borrow = WRITING; - Some(RefMut { parent: mut_self }) + match self.borrow.get() { + UNUSED => { + self.borrow.set(WRITING); + Some(RefMut { parent: self }) }, _ => None } @@ -186,8 +180,9 @@ pub struct Ref<'b, T> { #[unsafe_destructor] impl<'b, T> Drop for Ref<'b, T> { fn drop(&mut self) { - assert!(self.parent.borrow != WRITING && self.parent.borrow != UNUSED); - unsafe { self.parent.as_mut().borrow -= 1; } + let borrow = self.parent.borrow.get(); + assert!(borrow != WRITING && borrow != UNUSED); + self.parent.borrow.set(borrow - 1); } } @@ -200,14 +195,15 @@ impl<'b, T> Deref<T> for Ref<'b, T> { /// Wraps a mutable borrowed reference to a value in a `RefCell` box. pub struct RefMut<'b, T> { - parent: &'b mut RefCell<T> + parent: &'b RefCell<T> } #[unsafe_destructor] impl<'b, T> Drop for RefMut<'b, T> { fn drop(&mut self) { - assert!(self.parent.borrow == WRITING); - self.parent.borrow = UNUSED; + let borrow = self.parent.borrow.get(); + assert!(borrow == WRITING); + self.parent.borrow.set(UNUSED); } } diff --git a/src/libstd/fmt/parse.rs b/src/libstd/fmt/parse.rs index 4752f3a75f4..36ffb857237 100644 --- a/src/libstd/fmt/parse.rs +++ b/src/libstd/fmt/parse.rs @@ -131,13 +131,13 @@ pub enum Method<'a> { /// /// The final element of this enum is the default "other" case which is /// always required to be specified. - Plural(Option<uint>, ~[PluralArm<'a>], ~[Piece<'a>]), + Plural(Option<uint>, Vec<PluralArm<'a>>, Vec<Piece<'a>>), /// A select method selects over a string. Each arm is a different string /// which can be selected for. /// /// As with `Plural`, a default "other" case is required as well. - Select(~[SelectArm<'a>], ~[Piece<'a>]), + Select(Vec<SelectArm<'a>>, Vec<Piece<'a>>), } /// A selector for what pluralization a plural method should take @@ -156,7 +156,7 @@ pub struct PluralArm<'a> { /// literal. pub selector: PluralSelector, /// Array of pieces which are the format of this arm - pub result: ~[Piece<'a>], + pub result: Vec<Piece<'a>>, } /// Enum of the 5 CLDR plural keywords. There is one more, "other", but that @@ -184,7 +184,7 @@ pub struct SelectArm<'a> { /// String selector which guards this arm pub selector: &'a str, /// Array of pieces which are the format of this arm - pub result: ~[Piece<'a>], + pub result: Vec<Piece<'a>>, } /// The parser structure for interpreting the input format string. This is @@ -198,7 +198,7 @@ pub struct Parser<'a> { cur: str::CharOffsets<'a>, depth: uint, /// Error messages accumulated during parsing - pub errors: ~[~str], + pub errors: Vec<~str>, } impl<'a> Iterator<Piece<'a>> for Parser<'a> { @@ -236,7 +236,7 @@ impl<'a> Parser<'a> { input: s, cur: s.char_indices(), depth: 0, - errors: ~[], + errors: vec!(), } } @@ -463,7 +463,7 @@ impl<'a> Parser<'a> { /// Parses a 'select' statement (after the initial 'select' word) fn select(&mut self) -> ~Method<'a> { let mut other = None; - let mut arms = ~[]; + let mut arms = vec!(); // Consume arms one at a time loop { self.ws(); @@ -496,7 +496,7 @@ impl<'a> Parser<'a> { Some(arm) => { arm } None => { self.err("`select` statement must provide an `other` case"); - ~[] + vec!() } }; ~Select(arms, other) @@ -506,7 +506,7 @@ impl<'a> Parser<'a> { fn plural(&mut self) -> ~Method<'a> { let mut offset = None; let mut other = None; - let mut arms = ~[]; + let mut arms = vec!(); // First, attempt to parse the 'offset:' field. We know the set of // selector words which can appear in plural arms, and the only ones @@ -594,7 +594,7 @@ impl<'a> Parser<'a> { Some(arm) => { arm } None => { self.err("`plural` statement must provide an `other` case"); - ~[] + vec!() } }; ~Plural(offset, arms, other) @@ -684,9 +684,9 @@ mod tests { use super::*; use prelude::*; - fn same(fmt: &'static str, p: ~[Piece<'static>]) { + fn same(fmt: &'static str, p: &[Piece<'static>]) { let mut parser = Parser::new(fmt); - assert!(p == parser.collect()); + assert!(p == parser.collect::<Vec<Piece<'static>>>().as_slice()); } fn fmtdflt() -> FormatSpec<'static> { @@ -708,12 +708,12 @@ mod tests { #[test] fn simple() { - same("asdf", ~[String("asdf")]); - same("a\\{b", ~[String("a"), String("{b")]); - same("a\\#b", ~[String("a"), String("#b")]); - same("a\\}b", ~[String("a"), String("}b")]); - same("a\\}", ~[String("a"), String("}")]); - same("\\}", ~[String("}")]); + same("asdf", [String("asdf")]); + same("a\\{b", [String("a"), String("{b")]); + same("a\\#b", [String("a"), String("#b")]); + same("a\\}b", [String("a"), String("}b")]); + same("a\\}", [String("a"), String("}")]); + same("\\}", [String("}")]); } #[test] fn invalid01() { musterr("{") } @@ -725,7 +725,7 @@ mod tests { #[test] fn format_nothing() { - same("{}", ~[Argument(Argument { + same("{}", [Argument(Argument { position: ArgumentNext, format: fmtdflt(), method: None, @@ -733,7 +733,7 @@ mod tests { } #[test] fn format_position() { - same("{3}", ~[Argument(Argument { + same("{3}", [Argument(Argument { position: ArgumentIs(3), format: fmtdflt(), method: None, @@ -741,7 +741,7 @@ mod tests { } #[test] fn format_position_nothing_else() { - same("{3:}", ~[Argument(Argument { + same("{3:}", [Argument(Argument { position: ArgumentIs(3), format: fmtdflt(), method: None, @@ -749,7 +749,7 @@ mod tests { } #[test] fn format_type() { - same("{3:a}", ~[Argument(Argument { + same("{3:a}", [Argument(Argument { position: ArgumentIs(3), format: FormatSpec { fill: None, @@ -764,7 +764,7 @@ mod tests { } #[test] fn format_align_fill() { - same("{3:>}", ~[Argument(Argument { + same("{3:>}", [Argument(Argument { position: ArgumentIs(3), format: FormatSpec { fill: None, @@ -776,7 +776,7 @@ mod tests { }, method: None, })]); - same("{3:0<}", ~[Argument(Argument { + same("{3:0<}", [Argument(Argument { position: ArgumentIs(3), format: FormatSpec { fill: Some('0'), @@ -788,7 +788,7 @@ mod tests { }, method: None, })]); - same("{3:*<abcd}", ~[Argument(Argument { + same("{3:*<abcd}", [Argument(Argument { position: ArgumentIs(3), format: FormatSpec { fill: Some('*'), @@ -803,7 +803,7 @@ mod tests { } #[test] fn format_counts() { - same("{:10s}", ~[Argument(Argument { + same("{:10s}", [Argument(Argument { position: ArgumentNext, format: FormatSpec { fill: None, @@ -815,7 +815,7 @@ mod tests { }, method: None, })]); - same("{:10$.10s}", ~[Argument(Argument { + same("{:10$.10s}", [Argument(Argument { position: ArgumentNext, format: FormatSpec { fill: None, @@ -827,7 +827,7 @@ mod tests { }, method: None, })]); - same("{:.*s}", ~[Argument(Argument { + same("{:.*s}", [Argument(Argument { position: ArgumentNext, format: FormatSpec { fill: None, @@ -839,7 +839,7 @@ mod tests { }, method: None, })]); - same("{:.10$s}", ~[Argument(Argument { + same("{:.10$s}", [Argument(Argument { position: ArgumentNext, format: FormatSpec { fill: None, @@ -851,7 +851,7 @@ mod tests { }, method: None, })]); - same("{:a$.b$s}", ~[Argument(Argument { + same("{:a$.b$s}", [Argument(Argument { position: ArgumentNext, format: FormatSpec { fill: None, @@ -866,7 +866,7 @@ mod tests { } #[test] fn format_flags() { - same("{:-}", ~[Argument(Argument { + same("{:-}", [Argument(Argument { position: ArgumentNext, format: FormatSpec { fill: None, @@ -878,7 +878,7 @@ mod tests { }, method: None, })]); - same("{:+#}", ~[Argument(Argument { + same("{:+#}", [Argument(Argument { position: ArgumentNext, format: FormatSpec { fill: None, @@ -893,7 +893,7 @@ mod tests { } #[test] fn format_mixture() { - same("abcd {3:a} efg", ~[String("abcd "), Argument(Argument { + same("abcd {3:a} efg", [String("abcd "), Argument(Argument { position: ArgumentIs(3), format: FormatSpec { fill: None, @@ -909,42 +909,42 @@ mod tests { #[test] fn select_simple() { - same("{, select, other { haha } }", ~[Argument(Argument{ + same("{, select, other { haha } }", [Argument(Argument{ position: ArgumentNext, format: fmtdflt(), - method: Some(~Select(~[], ~[String(" haha ")])) + method: Some(~Select(vec![], vec![String(" haha ")])) })]); - same("{1, select, other { haha } }", ~[Argument(Argument{ + same("{1, select, other { haha } }", [Argument(Argument{ position: ArgumentIs(1), format: fmtdflt(), - method: Some(~Select(~[], ~[String(" haha ")])) + method: Some(~Select(vec![], vec![String(" haha ")])) })]); - same("{1, select, other {#} }", ~[Argument(Argument{ + same("{1, select, other {#} }", [Argument(Argument{ position: ArgumentIs(1), format: fmtdflt(), - method: Some(~Select(~[], ~[CurrentArgument])) + method: Some(~Select(vec![], vec![CurrentArgument])) })]); - same("{1, select, other {{2, select, other {lol}}} }", ~[Argument(Argument{ + same("{1, select, other {{2, select, other {lol}}} }", [Argument(Argument{ position: ArgumentIs(1), format: fmtdflt(), - method: Some(~Select(~[], ~[Argument(Argument{ + method: Some(~Select(vec![], vec![Argument(Argument{ position: ArgumentIs(2), format: fmtdflt(), - method: Some(~Select(~[], ~[String("lol")])) + method: Some(~Select(vec![], vec![String("lol")])) })])) // wat })]); } #[test] fn select_cases() { - same("{1, select, a{1} b{2} c{3} other{4} }", ~[Argument(Argument{ + same("{1, select, a{1} b{2} c{3} other{4} }", [Argument(Argument{ position: ArgumentIs(1), format: fmtdflt(), - method: Some(~Select(~[ - SelectArm{ selector: "a", result: ~[String("1")] }, - SelectArm{ selector: "b", result: ~[String("2")] }, - SelectArm{ selector: "c", result: ~[String("3")] }, - ], ~[String("4")])) + method: Some(~Select(vec![ + SelectArm{ selector: "a", result: vec![String("1")] }, + SelectArm{ selector: "b", result: vec![String("2")] }, + SelectArm{ selector: "c", result: vec![String("3")] }, + ], vec![String("4")])) })]); } @@ -961,25 +961,25 @@ mod tests { #[test] fn plural_simple() { - same("{, plural, other { haha } }", ~[Argument(Argument{ + same("{, plural, other { haha } }", [Argument(Argument{ position: ArgumentNext, format: fmtdflt(), - method: Some(~Plural(None, ~[], ~[String(" haha ")])) + method: Some(~Plural(None, vec![], vec![String(" haha ")])) })]); - same("{:, plural, other { haha } }", ~[Argument(Argument{ + same("{:, plural, other { haha } }", [Argument(Argument{ position: ArgumentNext, format: fmtdflt(), - method: Some(~Plural(None, ~[], ~[String(" haha ")])) + method: Some(~Plural(None, vec![], vec![String(" haha ")])) })]); same("{, plural, offset:1 =2{2} =3{3} many{yes} other{haha} }", - ~[Argument(Argument{ + [Argument(Argument{ position: ArgumentNext, format: fmtdflt(), - method: Some(~Plural(Some(1), ~[ - PluralArm{ selector: Literal(2), result: ~[String("2")] }, - PluralArm{ selector: Literal(3), result: ~[String("3")] }, - PluralArm{ selector: Keyword(Many), result: ~[String("yes")] } - ], ~[String("haha")])) + method: Some(~Plural(Some(1), vec![ + PluralArm{ selector: Literal(2), result: vec![String("2")] }, + PluralArm{ selector: Literal(3), result: vec![String("3")] }, + PluralArm{ selector: Keyword(Many), result: vec![String("yes")] } + ], vec![String("haha")])) })]); } } diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index f87f4a69f17..e1eaa2792bf 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -21,7 +21,7 @@ use option::{Option, Some, None}; use result::{Ok, Err}; use io; use io::{IoError, IoResult, Reader}; -use slice::{OwnedVector, ImmutableVector}; +use slice::{OwnedVector, ImmutableVector, Vector}; use ptr::RawPtr; /// An iterator that reads a single byte on each iteration, @@ -88,7 +88,7 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { 8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_le64(n as i64)) }), _ => { - let mut bytes: ~[u8] = ~[]; + let mut bytes = vec!(); let mut i = size; let mut n = n; while i > 0u { @@ -96,7 +96,7 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { n >>= 8_u64; i -= 1u; } - f(bytes) + f(bytes.as_slice()) } } } @@ -127,14 +127,14 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { 4u => f(unsafe { transmute::<i32, [u8, ..4]>(to_be32(n as i32)) }), 8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_be64(n as i64)) }), _ => { - let mut bytes: ~[u8] = ~[]; + let mut bytes = vec!(); let mut i = size; while i > 0u { let shift = ((i - 1u) * 8u) as u64; bytes.push((n >> shift) as u8); i -= 1u; } - f(bytes) + f(bytes.as_slice()) } } } diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 2fea002d419..b8a58c5cf10 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -483,7 +483,7 @@ pub fn rmdir(path: &Path) -> IoResult<()> { /// Will return an error if the provided `from` doesn't exist, the process lacks /// permissions to view the contents or if the `path` points at a non-directory /// file -pub fn readdir(path: &Path) -> IoResult<~[Path]> { +pub fn readdir(path: &Path) -> IoResult<Vec<Path>> { LocalIo::maybe_raise(|io| { io.fs_readdir(&path.to_c_str(), 0) }) @@ -498,7 +498,7 @@ pub fn walk_dir(path: &Path) -> IoResult<Directories> { /// An iterator which walks over a directory pub struct Directories { - stack: ~[Path], + stack: Vec<Path>, } impl Iterator<Path> for Directories { diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs index 6762e7c6a76..00b2e4f2307 100644 --- a/src/libstd/io/signal.rs +++ b/src/libstd/io/signal.rs @@ -29,6 +29,7 @@ use option::{Some, None}; use result::{Ok, Err}; use rt::rtio::{IoFactory, LocalIo, RtioSignal}; use slice::{ImmutableVector, OwnedVector}; +use vec::Vec; /// Signals that can be sent and received #[repr(int)] @@ -80,7 +81,7 @@ pub enum Signum { /// ``` pub struct Listener { /// A map from signums to handles to keep the handles in memory - handles: ~[(Signum, ~RtioSignal:Send)], + handles: Vec<(Signum, ~RtioSignal:Send)>, /// This is where all the handles send signums, which are received by /// the clients from the receiver. tx: Sender<Signum>, @@ -99,7 +100,7 @@ impl Listener { Listener { tx: tx, rx: rx, - handles: ~[], + handles: vec!(), } } diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index 14b9b5c1e06..dd874fecc52 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -39,7 +39,6 @@ macro_rules! iotest ( use io::process::*; use unstable::running_on_valgrind; use str; - use util; fn f() $b diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index c555fb58db8..c76e079432a 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -47,6 +47,7 @@ use mem::replace; use option::{None, Option, Some}; use rt::task::{Task, LocalStorage}; use slice::{ImmutableVector, MutableVector, OwnedVector}; +use vec::Vec; /** * Indexes a task-local data slot. This pointer is used for comparison to @@ -89,7 +90,7 @@ impl<T: 'static> LocalData for T {} // n.b. If TLS is used heavily in future, this could be made more efficient with // a proper map. #[doc(hidden)] -pub type Map = ~[Option<(*u8, TLSValue, LoanState)>]; +pub type Map = Vec<Option<(*u8, TLSValue, LoanState)>>; type TLSValue = ~LocalData:Send; // Gets the map from the runtime. Lazily initialises if not done so already. @@ -106,7 +107,7 @@ unsafe fn get_local_map() -> &mut Map { // If this is the first time we've accessed TLS, perform similar // actions to the oldsched way of doing things. &LocalStorage(ref mut slot) => { - *slot = Some(~[]); + *slot = Some(vec!()); match *slot { Some(ref mut map_ptr) => { return map_ptr } None => abort() @@ -237,7 +238,7 @@ fn get_with<T:'static, Some(i) => { let ret; let mut return_loan = false; - match map[i] { + match *map.get_mut(i) { Some((_, ref data, ref mut loan)) => { match (state, *loan) { (_, NoLoan) => { @@ -271,7 +272,7 @@ fn get_with<T:'static, // in turn relocated the vector. Hence we do another lookup here to // fixup the loans. if return_loan { - match map[i] { + match *map.get_mut(i) { Some((_, _, ref mut loan)) => { *loan = NoLoan; } None => abort() } @@ -331,7 +332,7 @@ pub fn set<T: 'static>(key: Key<T>, data: T) { // we're not actually sending it to other schedulers or anything. let data: ~LocalData:Send = unsafe { cast::transmute(data) }; match insertion_position(map, keyval) { - Some(i) => { map[i] = Some((keyval, data, NoLoan)); } + Some(i) => { *map.get_mut(i) = Some((keyval, data, NoLoan)); } None => { map.push(Some((keyval, data, NoLoan))); } } } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index e12e0234d96..7205edee611 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -31,6 +31,7 @@ use to_str::ToStr; use slice::{Vector, OwnedVector}; use intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc}; use raw; +use vec::Vec; macro_rules! try( ($me:expr, $e:expr) => ( match $e { @@ -102,8 +103,8 @@ enum VariantState { pub struct ReprVisitor<'a> { ptr: *u8, - ptr_stk: ~[*u8], - var_stk: ~[VariantState], + ptr_stk: Vec<*u8>, + var_stk: Vec<VariantState>, writer: &'a mut io::Writer, last_err: Option<io::IoError>, } @@ -112,8 +113,8 @@ pub fn ReprVisitor<'a>(ptr: *u8, writer: &'a mut io::Writer) -> ReprVisitor<'a> { ReprVisitor { ptr: ptr, - ptr_stk: ~[], - var_stk: ~[], + ptr_stk: vec!(), + var_stk: vec!(), writer: writer, last_err: None, } @@ -154,8 +155,8 @@ impl<'a> ReprVisitor<'a> { // issues we have to recreate it here. let u = ReprVisitor { ptr: ptr, - ptr_stk: ~[], - var_stk: ~[], + ptr_stk: vec!(), + var_stk: vec!(), writer: ::cast::transmute_copy(&self.writer), last_err: None, }; @@ -505,7 +506,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> { _offset: uint, inner: *TyDesc) -> bool { - match self.var_stk[self.var_stk.len() - 1] { + match *self.var_stk.get(self.var_stk.len() - 1) { Matched => { if i != 0 { try!(self, self.writer.write(", ".as_bytes())); @@ -523,7 +524,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> { _disr_val: Disr, n_fields: uint, _name: &str) -> bool { - match self.var_stk[self.var_stk.len() - 1] { + match *self.var_stk.get(self.var_stk.len() - 1) { Matched => { if n_fields > 0 { try!(self, self.writer.write([')' as u8])); diff --git a/src/libstd/rt/at_exit_imp.rs b/src/libstd/rt/at_exit_imp.rs index 4be9c8a84ac..67b8b40b47e 100644 --- a/src/libstd/rt/at_exit_imp.rs +++ b/src/libstd/rt/at_exit_imp.rs @@ -20,8 +20,9 @@ use option::{Some, None}; use ptr::RawPtr; use unstable::sync::Exclusive; use slice::OwnedVector; +use vec::Vec; -type Queue = Exclusive<~[proc():Send]>; +type Queue = Exclusive<Vec<proc():Send>>; // You'll note that these variables are *not* atomic, and this is done on // purpose. This module is designed to have init() called *once* in a @@ -35,7 +36,7 @@ pub fn init() { unsafe { rtassert!(!RUNNING); rtassert!(QUEUE.is_null()); - let state: ~Queue = ~Exclusive::new(~[]); + let state: ~Queue = ~Exclusive::new(vec!()); QUEUE = cast::transmute(state); } } @@ -61,7 +62,7 @@ pub fn run() { QUEUE = 0 as *mut Queue; let mut vec = None; state.with(|arr| { - vec = Some(mem::replace(arr, ~[])); + vec = Some(mem::replace(arr, vec!())); }); vec.take_unwrap() }; diff --git a/src/libstd/rt/rtio.rs b/src/libstd/rt/rtio.rs index 1750e685627..cc8356d2b9a 100644 --- a/src/libstd/rt/rtio.rs +++ b/src/libstd/rt/rtio.rs @@ -20,6 +20,7 @@ use path::Path; use result::Err; use rt::local::Local; use rt::task::Task; +use vec::Vec; use ai = io::net::addrinfo; use io; @@ -168,7 +169,7 @@ pub trait IoFactory { fn fs_rmdir(&mut self, path: &CString) -> IoResult<()>; fn fs_rename(&mut self, path: &CString, to: &CString) -> IoResult<()>; fn fs_readdir(&mut self, path: &CString, flags: c_int) -> - IoResult<~[Path]>; + IoResult<Vec<Path>>; fn fs_lstat(&mut self, path: &CString) -> IoResult<FileStat>; fn fs_chown(&mut self, path: &CString, uid: int, gid: int) -> IoResult<()>; diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs index d01c89878de..8beadce2160 100644 --- a/src/libstd/sync/deque.rs +++ b/src/libstd/sync/deque.rs @@ -62,6 +62,7 @@ use sync::arc::UnsafeArc; use sync::atomics::{AtomicInt, AtomicPtr, SeqCst}; use unstable::sync::Exclusive; use slice::{OwnedVector, ImmutableVector}; +use vec::Vec; // Once the queue is less than 1/K full, then it will be downsized. Note that // the deque requires that this number be less than 2. @@ -116,14 +117,14 @@ pub enum Stolen<T> { /// will only use this structure when allocating a new buffer or deallocating a /// previous one. pub struct BufferPool<T> { - pool: Exclusive<~[~Buffer<T>]>, + pool: Exclusive<Vec<~Buffer<T>>>, } /// An internal buffer used by the chase-lev deque. This structure is actually /// implemented as a circular buffer, and is used as the intermediate storage of /// the data in the deque. /// -/// This type is implemented with *T instead of ~[T] for two reasons: +/// This type is implemented with *T instead of Vec<T> for two reasons: /// /// 1. There is nothing safe about using this buffer. This easily allows the /// same value to be read twice in to rust, and there is nothing to @@ -132,7 +133,7 @@ pub struct BufferPool<T> { /// destructors for values in this buffer (on drop) because the bounds /// are defined by the deque it's owned by. /// -/// 2. We can certainly avoid bounds checks using *T instead of ~[T], although +/// 2. We can certainly avoid bounds checks using *T instead of Vec<T>, although /// LLVM is probably pretty good at doing this already. struct Buffer<T> { storage: *T, @@ -143,7 +144,7 @@ impl<T: Send> BufferPool<T> { /// Allocates a new buffer pool which in turn can be used to allocate new /// deques. pub fn new() -> BufferPool<T> { - BufferPool { pool: Exclusive::new(~[]) } + BufferPool { pool: Exclusive::new(vec!()) } } /// Allocates a new work-stealing deque which will send/receiving memory to @@ -494,7 +495,7 @@ mod tests { } } }) - }).collect::<~[Thread<()>]>(); + }).collect::<Vec<Thread<()>>>(); while remaining.load(SeqCst) > 0 { match w.pop() { @@ -525,7 +526,7 @@ mod tests { Thread::start(proc() { stampede(w, s, 4, 10000); }) - }).collect::<~[Thread<()>]>(); + }).collect::<Vec<Thread<()>>>(); for thread in threads.move_iter() { thread.join(); @@ -556,7 +557,7 @@ mod tests { } } }) - }).collect::<~[Thread<()>]>(); + }).collect::<Vec<Thread<()>>>(); let mut rng = rand::task_rng(); let mut expected = 0; @@ -658,4 +659,3 @@ mod tests { } } } - diff --git a/src/libstd/sync/mpmc_bounded_queue.rs b/src/libstd/sync/mpmc_bounded_queue.rs index 12c05c0d61c..b392cc8ff9a 100644 --- a/src/libstd/sync/mpmc_bounded_queue.rs +++ b/src/libstd/sync/mpmc_bounded_queue.rs @@ -35,7 +35,7 @@ use num::next_power_of_two; use option::{Option, Some, None}; use sync::arc::UnsafeArc; use sync::atomics::{AtomicUint,Relaxed,Release,Acquire}; -use slice; +use vec::Vec; struct Node<T> { sequence: AtomicUint, @@ -44,7 +44,7 @@ struct Node<T> { struct State<T> { pad0: [u8, ..64], - buffer: ~[Node<T>], + buffer: Vec<Node<T>>, mask: uint, pad1: [u8, ..64], enqueue_pos: AtomicUint, @@ -69,7 +69,7 @@ impl<T: Send> State<T> { } else { capacity }; - let buffer = slice::from_fn(capacity, |i| { + let buffer = Vec::from_fn(capacity, |i| { Node { sequence:AtomicUint::new(i), value: None } }); State{ @@ -88,7 +88,7 @@ impl<T: Send> State<T> { let mask = self.mask; let mut pos = self.enqueue_pos.load(Relaxed); loop { - let node = &mut self.buffer[pos & mask]; + let node = self.buffer.get_mut(pos & mask); let seq = node.sequence.load(Acquire); let diff: int = seq as int - pos as int; @@ -114,7 +114,7 @@ impl<T: Send> State<T> { let mask = self.mask; let mut pos = self.dequeue_pos.load(Relaxed); loop { - let node = &mut self.buffer[pos & mask]; + let node = self.buffer.get_mut(pos & mask); let seq = node.sequence.load(Acquire); let diff: int = seq as int - (pos + 1) as int; if diff == 0 { @@ -186,7 +186,7 @@ mod tests { }); } - let mut completion_rxs = ~[]; + let mut completion_rxs = vec![]; for _ in range(0, nthreads) { let (tx, rx) = channel(); completion_rxs.push(rx); |
