diff options
| author | Matthew McPherrin <matthew@mcpherrin.ca> | 2013-02-08 15:21:46 -0500 |
|---|---|---|
| committer | Matthew McPherrin <matthew@mcpherrin.ca> | 2013-02-08 15:21:46 -0500 |
| commit | 46df7985a5f3e1e1a50d0f5f81f32bb1e4be8967 (patch) | |
| tree | 4780d31268ce0e252a6ca47765bd6e8430e370da /src/libstd | |
| parent | 64fedfbc4ef37b56f7bb12e2864f4011e4031ac5 (diff) | |
| parent | 3764cfbf57646becdeefa2996f812cbe40b016e7 (diff) | |
| download | rust-46df7985a5f3e1e1a50d0f5f81f32bb1e4be8967.tar.gz rust-46df7985a5f3e1e1a50d0f5f81f32bb1e4be8967.zip | |
Merge branch 'master' of https://github.com/mozilla/rust
Diffstat (limited to 'src/libstd')
40 files changed, 361 insertions, 430 deletions
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index a8d3f156104..a1fd7a66f7e 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; /** * Concurrency-enabled mechanisms for sharing mutable and/or immutable state * between tasks. diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 3e21a320d44..a2cbe27ea90 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -32,8 +32,6 @@ // overhead when initializing plain-old-data and means we don't need // to waste time running the destructors of POD. -#[forbid(deprecated_mode)]; - use arena; use list; use list::{List, Cons, Nil}; diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 5813e0919d9..d9e121798f1 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; - use core::io::Reader; use core::iter; use core::str; diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index d49c2ef95f6..a94c4f79064 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; - use core::ops; use core::prelude::*; use core::uint; @@ -156,7 +154,7 @@ impl BigBitv { fn each_storage(op: fn(v: &mut uint) -> bool) { for uint::range(0, self.storage.len()) |i| { let mut w = self.storage[i]; - let b = !op(&mut w); + let b = op(&mut w); self.storage[i] = w; if !b { break; } } @@ -981,6 +979,24 @@ mod tests { assert !b1[40]; assert !b1[80]; } + + #[test] + pub fn test_small_clear() { + let b = Bitv(14, true); + b.clear(); + for b.ones |i| { + die!(fmt!("found 1 at %?", i)); + } + } + + #[test] + pub fn test_big_clear() { + let b = Bitv(140, true); + b.clear(); + for b.ones |i| { + die!(fmt!("found 1 at %?", i)); + } + } } // diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index c190d08687a..5ea5418d988 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -35,7 +35,6 @@ * great care must be taken to ensure that a reference to the c_vec::t is * still held if needed. */ -#[forbid(deprecated_mode)]; use core::libc; use core::option; @@ -46,11 +45,11 @@ use core::task; /** * The type representing a foreign chunk of memory * - * Wrapped in a enum for opacity; FIXME #818 when it is possible to have - * truly opaque types, this should be revisited. */ -pub enum CVec<T> { - CVecCtor({ base: *mut T, len: uint, rsrc: @DtorRes}) +pub struct CVec<T> { + priv base: *mut T, + priv len: uint, + priv rsrc: @DtorRes } struct DtorRes { @@ -85,11 +84,11 @@ fn DtorRes(dtor: Option<fn@()>) -> DtorRes { * * len - The number of elements in the buffer */ pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> { - return CVecCtor({ + return CVec{ base: base, len: len, rsrc: @DtorRes(option::None) - }); + }; } /** @@ -105,11 +104,11 @@ pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> { */ pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@()) -> CVec<T> { - return CVecCtor({ + return CVec{ base: base, len: len, rsrc: @DtorRes(option::Some(dtor)) - }); + }; } /* @@ -123,7 +122,7 @@ pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@()) */ pub fn get<T: Copy>(t: CVec<T>, ofs: uint) -> T { assert ofs < len(t); - return unsafe { *ptr::mut_offset((*t).base, ofs) }; + return unsafe { *ptr::mut_offset(t.base, ofs) }; } /** @@ -133,7 +132,7 @@ pub fn get<T: Copy>(t: CVec<T>, ofs: uint) -> T { */ pub fn set<T: Copy>(t: CVec<T>, ofs: uint, v: T) { assert ofs < len(t); - unsafe { *ptr::mut_offset((*t).base, ofs) = v }; + unsafe { *ptr::mut_offset(t.base, ofs) = v }; } /* @@ -141,14 +140,10 @@ pub fn set<T: Copy>(t: CVec<T>, ofs: uint, v: T) { */ /// Returns the length of the vector -pub pure fn len<T>(t: CVec<T>) -> uint { - return (*t).len; -} +pub pure fn len<T>(t: CVec<T>) -> uint { t.len } /// Returns a pointer to the first element of the vector -pub unsafe fn ptr<T>(t: CVec<T>) -> *mut T { - return (*t).base; -} +pub unsafe fn ptr<T>(t: CVec<T>) -> *mut T { t.base } #[cfg(test)] mod tests { diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index aae84a86957..10a896a4089 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; - use core::option; use core::prelude::*; diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index 0bd7538d947..110559ddcef 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; //! Additional general-purpose comparison functionality. use core::f32; diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index f4917934acb..71eb29e26eb 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -14,22 +14,12 @@ Higher level communication abstractions. */ -// NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; - use core::pipes::{GenericChan, GenericSmartChan, GenericPort}; use core::pipes::{Chan, Port, Selectable, Peekable}; use core::pipes; use core::prelude::*; /// An extension of `pipes::stream` that allows both sending and receiving. -#[cfg(stage0)] -pub struct DuplexStream<T:Owned, U:Owned> { - priv chan: Chan<T>, - priv port: Port<U>, -} -#[cfg(stage1)] -#[cfg(stage2)] pub struct DuplexStream<T, U> { priv chan: Chan<T>, priv port: Port<U>, diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index cf1b816f238..7813357caf2 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; //! Unsafe debugging functions for inspecting values. use core::cast::reinterpret_cast; diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 2f001ae866c..465c5d8f8fe 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -9,7 +9,6 @@ // except according to those terms. //! A deque. Untested as of yet. Likely buggy -#[forbid(deprecated_mode)]; #[forbid(non_camel_case_types)]; use core::cmp::Eq; diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 25deaf2a9b5..768d2dbf2d4 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; - use serialize; use core::io; @@ -84,22 +82,27 @@ pub mod reader { } } - fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { + struct Res { + val: uint, + next: uint + } + + fn vuint_at(data: &[u8], start: uint) -> Res { let a = data[start]; if a & 0x80u8 != 0u8 { - return {val: (a & 0x7fu8) as uint, next: start + 1u}; + return Res {val: (a & 0x7fu8) as uint, next: start + 1u}; } if a & 0x40u8 != 0u8 { - return {val: ((a & 0x3fu8) as uint) << 8u | + return Res {val: ((a & 0x3fu8) as uint) << 8u | (data[start + 1u] as uint), next: start + 2u}; } else if a & 0x20u8 != 0u8 { - return {val: ((a & 0x1fu8) as uint) << 16u | + return Res {val: ((a & 0x1fu8) as uint) << 16u | (data[start + 1u] as uint) << 8u | (data[start + 2u] as uint), next: start + 3u}; } else if a & 0x10u8 != 0u8 { - return {val: ((a & 0x0fu8) as uint) << 24u | + return Res {val: ((a & 0x0fu8) as uint) << 24u | (data[start + 1u] as uint) << 16u | (data[start + 2u] as uint) << 8u | (data[start + 3u] as uint), diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index e0d4b95a7e4..d6c2cf5a265 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; - /*! * A functional key,value store that works on anything. * diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 8ddefa401a8..e34574a2e15 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -74,7 +74,6 @@ * do_work(input, output); * } */ -#[forbid(deprecated_mode)]; use core::cmp::Eq; use core::prelude::*; diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 4b34f318e91..99c6c2f008d 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -10,7 +10,6 @@ // Rust JSON serialization library // Copyright (c) 2011 Google Inc. -#[forbid(deprecated_mode)]; #[forbid(non_camel_case_types)]; //! json serialization @@ -856,9 +855,6 @@ pub impl Decoder: serialize::Decoder { debug!("read_vec_elt(idx=%u)", idx); match *self.peek() { List(ref list) => { - // FIXME(#3148)---should be inferred - let list: &self/~[Json] = list; - self.stack.push(&list[idx]); f() } @@ -885,9 +881,6 @@ pub impl Decoder: serialize::Decoder { let top = self.peek(); match *top { Object(ref obj) => { - // FIXME(#3148) This hint should not be necessary. - let obj: &self/~Object = obj; - match obj.find(&name.to_owned()) { None => die!(fmt!("no such field: %s", name)), Some(json) => { @@ -917,8 +910,6 @@ pub impl Decoder: serialize::Decoder { debug!("read_tup_elt(idx=%u)", idx); match *self.peek() { List(ref list) => { - // FIXME(#3148)---should be inferred - let list: &self/~[Json] = list; self.stack.push(&list[idx]); f() } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 3016abee464..140c2013738 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -9,7 +9,6 @@ // except according to those terms. //! A standard linked list -#[forbid(deprecated_mode)]; use core::cmp::Eq; use core::option; diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index e1e2bb2697f..1d831af0e29 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -8,13 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; - use core::str; use core::uint; use core::vec; -pub pure fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { +struct Quad { + a: u32, + b: u32, + c: u32, + d: u32 +} + +pub pure fn md4(msg: &[u8]) -> Quad { // subtle: if orig_len is merely uint, then the code below // which performs shifts by 32 bits or more has undefined // results. @@ -95,11 +100,11 @@ pub pure fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { a += aa; b += bb; c += cc; d += dd; i += 64u; } - return {a: a, b: b, c: c, d: d}; + return Quad {a: a, b: b, c: c, d: d}; } pub pure fn md4_str(msg: &[u8]) -> ~str { - let {a, b, c, d} = md4(msg); + let Quad {a, b, c, d} = md4(msg); pure fn app(a: u32, b: u32, c: u32, d: u32, f: fn(u32)) { f(a); f(b); f(c); f(d); } diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index f4fd69aae1e..511e80b0160 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -9,7 +9,6 @@ // except according to those terms. //! Types/fns concerning Internet Protocol (IP), versions 4 & 6 -#[forbid(deprecated_mode)]; use core::libc; use core::prelude::*; diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 429bd6ae474..c90518f1692 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -10,6 +10,7 @@ //! High-level interface to libuv's TCP functionality // FIXME #4425: Need FFI fixes + #[allow(deprecated_mode)]; use future; diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index b32c97c6998..9403438dde0 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -9,7 +9,8 @@ // except according to those terms. //! Types/fns concerning URLs (see RFC 3986) -#[forbid(deprecated_mode)]; + +#[allow(deprecated_mode)]; use core::cmp::Eq; use core::dvec::DVec; diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index a4d4a4e806b..ad7e8e50e38 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -9,7 +9,6 @@ // except according to those terms. //! A map type - **deprecated**, use `core::hashmap` instead -#[forbid(deprecated_mode)]; use core::container::{Container, Mutable, Map}; use core::cmp::Eq; @@ -226,9 +225,9 @@ pub mod chained { } } - pure fn find(&self, k: K) -> Option<V> { + pure fn find(&self, k: &K) -> Option<V> { unsafe { - match self.search_tbl(&k, k.hash_keyed(0,0) as uint) { + match self.search_tbl(k, k.hash_keyed(0,0) as uint) { NotFound => None, FoundFirst(_, entry) => Some(entry.value), FoundAfter(_, entry) => Some(entry.value) @@ -291,7 +290,7 @@ pub mod chained { return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)); } - pure fn get(&self, k: K) -> V { + pure fn get(&self, k: &K) -> V { let opt_v = self.find(k); if opt_v.is_none() { die!(fmt!("Key not found in table: %?", k)); @@ -364,7 +363,7 @@ pub mod chained { impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: ops::Index<K, V> { pure fn index(&self, k: K) -> V { unsafe { - self.get(k) + self.get(&k) } } } @@ -421,7 +420,6 @@ pub fn hash_from_vec<K: Eq IterBytes Hash Const Copy, V: Copy>( #[cfg(test)] mod tests { use core::option::None; - use core::option; use core::uint; use super::*; @@ -437,13 +435,13 @@ mod tests { assert (hm_uu.insert(10u, 12u)); assert (hm_uu.insert(11u, 13u)); assert (hm_uu.insert(12u, 14u)); - assert (hm_uu.get(11u) == 13u); - assert (hm_uu.get(12u) == 14u); - assert (hm_uu.get(10u) == 12u); + assert (hm_uu.get(&11) == 13u); + assert (hm_uu.get(&12) == 14u); + assert (hm_uu.get(&10) == 12u); assert (!hm_uu.insert(12u, 14u)); - assert (hm_uu.get(12u) == 14u); + assert (hm_uu.get(&12) == 14u); assert (!hm_uu.insert(12u, 12u)); - assert (hm_uu.get(12u) == 12u); + assert (hm_uu.get(&12) == 12u); let ten: ~str = ~"ten"; let eleven: ~str = ~"eleven"; let twelve: ~str = ~"twelve"; @@ -453,40 +451,40 @@ mod tests { assert (hm_su.insert(~"ten", 12u)); assert (hm_su.insert(eleven, 13u)); assert (hm_su.insert(~"twelve", 14u)); - assert (hm_su.get(eleven) == 13u); - assert (hm_su.get(~"eleven") == 13u); - assert (hm_su.get(~"twelve") == 14u); - assert (hm_su.get(~"ten") == 12u); + assert (hm_su.get(&eleven) == 13u); + assert (hm_su.get(&~"eleven") == 13u); + assert (hm_su.get(&~"twelve") == 14u); + assert (hm_su.get(&~"ten") == 12u); assert (!hm_su.insert(~"twelve", 14u)); - assert (hm_su.get(~"twelve") == 14u); + assert (hm_su.get(&~"twelve") == 14u); assert (!hm_su.insert(~"twelve", 12u)); - assert (hm_su.get(~"twelve") == 12u); + assert (hm_su.get(&~"twelve") == 12u); debug!("uint -> str"); let hm_us: HashMap<uint, ~str> = HashMap::<uint, ~str>(); assert (hm_us.insert(10u, ~"twelve")); assert (hm_us.insert(11u, ~"thirteen")); assert (hm_us.insert(12u, ~"fourteen")); - assert hm_us.get(11u) == ~"thirteen"; - assert hm_us.get(12u) == ~"fourteen"; - assert hm_us.get(10u) == ~"twelve"; + assert hm_us.get(&11) == ~"thirteen"; + assert hm_us.get(&12) == ~"fourteen"; + assert hm_us.get(&10) == ~"twelve"; assert (!hm_us.insert(12u, ~"fourteen")); - assert hm_us.get(12u) == ~"fourteen"; + assert hm_us.get(&12) == ~"fourteen"; assert (!hm_us.insert(12u, ~"twelve")); - assert hm_us.get(12u) == ~"twelve"; + assert hm_us.get(&12) == ~"twelve"; debug!("str -> str"); let hm_ss: HashMap<~str, ~str> = HashMap::<~str, ~str>(); assert (hm_ss.insert(ten, ~"twelve")); assert (hm_ss.insert(eleven, ~"thirteen")); assert (hm_ss.insert(twelve, ~"fourteen")); - assert hm_ss.get(~"eleven") == ~"thirteen"; - assert hm_ss.get(~"twelve") == ~"fourteen"; - assert hm_ss.get(~"ten") == ~"twelve"; + assert hm_ss.get(&~"eleven") == ~"thirteen"; + assert hm_ss.get(&~"twelve") == ~"fourteen"; + assert hm_ss.get(&~"ten") == ~"twelve"; assert (!hm_ss.insert(~"twelve", ~"fourteen")); - assert hm_ss.get(~"twelve") == ~"fourteen"; + assert hm_ss.get(&~"twelve") == ~"fourteen"; assert (!hm_ss.insert(~"twelve", ~"twelve")); - assert hm_ss.get(~"twelve") == ~"twelve"; + assert hm_ss.get(&~"twelve") == ~"twelve"; debug!("*** finished test_simple"); } @@ -512,17 +510,17 @@ mod tests { debug!("-----"); i = 0u; while i < num_to_insert { - debug!("get(%u) = %u", i, hm_uu.get(i)); - assert (hm_uu.get(i) == i * i); + debug!("get(%u) = %u", i, hm_uu.get(&i)); + assert (hm_uu.get(&i) == i * i); i += 1u; } assert (hm_uu.insert(num_to_insert, 17u)); - assert (hm_uu.get(num_to_insert) == 17u); + assert (hm_uu.get(&num_to_insert) == 17u); debug!("-----"); i = 0u; while i < num_to_insert { - debug!("get(%u) = %u", i, hm_uu.get(i)); - assert (hm_uu.get(i) == i * i); + debug!("get(%u) = %u", i, hm_uu.get(&i)); + assert (hm_uu.get(&i) == i * i); i += 1u; } debug!("str -> str"); @@ -542,22 +540,22 @@ mod tests { while i < num_to_insert { debug!("get(\"%s\") = \"%s\"", uint::to_str_radix(i, 2u), - hm_ss.get(uint::to_str_radix(i, 2u))); - assert hm_ss.get(uint::to_str_radix(i, 2u)) == + hm_ss.get(&uint::to_str_radix(i, 2u))); + assert hm_ss.get(&uint::to_str_radix(i, 2u)) == uint::to_str_radix(i * i, 2u); i += 1u; } assert (hm_ss.insert(uint::to_str_radix(num_to_insert, 2u), uint::to_str_radix(17u, 2u))); - assert hm_ss.get(uint::to_str_radix(num_to_insert, 2u)) == + assert hm_ss.get(&uint::to_str_radix(num_to_insert, 2u)) == uint::to_str_radix(17u, 2u); debug!("-----"); i = 0u; while i < num_to_insert { debug!("get(\"%s\") = \"%s\"", uint::to_str_radix(i, 2u), - hm_ss.get(uint::to_str_radix(i, 2u))); - assert hm_ss.get(uint::to_str_radix(i, 2u)) == + hm_ss.get(&uint::to_str_radix(i, 2u))); + assert hm_ss.get(&uint::to_str_radix(i, 2u)) == uint::to_str_radix(i * i, 2u); i += 1u; } @@ -589,15 +587,15 @@ mod tests { debug!("-----"); i = 1u; while i < num_to_insert { - debug!("get(%u) = %u", i, hm.get(i)); - assert (hm.get(i) == i * i); + debug!("get(%u) = %u", i, hm.get(&i)); + assert (hm.get(&i) == i * i); i += 2u; } debug!("-----"); i = 1u; while i < num_to_insert { - debug!("get(%u) = %u", i, hm.get(i)); - assert (hm.get(i) == i * i); + debug!("get(%u) = %u", i, hm.get(&i)); + assert (hm.get(&i) == i * i); i += 2u; } debug!("-----"); @@ -611,16 +609,16 @@ mod tests { debug!("-----"); i = 0u; while i < num_to_insert { - debug!("get(%u) = %u", i, hm.get(i)); - assert (hm.get(i) == i * i); + debug!("get(%u) = %u", i, hm.get(&i)); + assert (hm.get(&i) == i * i); i += 1u; } debug!("-----"); assert (hm.len() == num_to_insert); i = 0u; while i < num_to_insert { - debug!("get(%u) = %u", i, hm.get(i)); - assert (hm.get(i) == i * i); + debug!("get(%u) = %u", i, hm.get(&i)); + assert (hm.get(&i) == i * i); i += 1u; } debug!("*** finished test_removal"); @@ -639,9 +637,9 @@ mod tests { fn test_find() { let key = ~"k"; let map = HashMap::<~str, ~str>(); - assert (option::is_none(&map.find(key))); + assert map.find(&key).is_none(); map.insert(key, ~"val"); - assert (option::get(map.find(key)) == ~"val"); + assert map.find(&key).get() == ~"val"; } #[test] @@ -664,9 +662,9 @@ mod tests { (~"c", 3) ]); assert map.len() == 3u; - assert map.get(~"a") == 1; - assert map.get(~"b") == 2; - assert map.get(~"c") == 3; + assert map.get(&~"a") == 1; + assert map.get(&~"b") == 2; + assert map.get(&~"c") == 3; } #[test] @@ -692,11 +690,11 @@ mod tests { map.update_with_key(~"cat", 2, addMoreToCount); // check the total counts - assert 10 == option::get(map.find(~"cat")); - assert 3 == option::get(map.find(~"ferret")); - assert 1 == option::get(map.find(~"mongoose")); + assert map.find(&~"cat").get() == 10; + assert map.find(&~"ferret").get() == 3; + assert map.find(&~"mongoose").get() == 1; // sadly, no mythical animals were counted! - assert None == map.find(~"unicorn"); + assert map.find(&~"unicorn").is_none(); } } diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 779dda0ab29..8293ff1c2af 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; - use core::cast; use core::prelude::*; use core::ptr; @@ -38,7 +36,7 @@ const min_granularity : uint = 1024u; */ fn map_slices<A: Copy Owned, B: Copy Owned>( xs: &[A], - f: fn() -> fn~(uint, v: &[A]) -> B) + f: &fn() -> ~fn(uint, v: &[A]) -> B) -> ~[B] { let len = xs.len(); @@ -93,9 +91,9 @@ fn map_slices<A: Copy Owned, B: Copy Owned>( /// A parallel version of map. pub fn map<A: Copy Owned, B: Copy Owned>( - xs: &[A], f: fn~(&A) -> B) -> ~[B] { + xs: &[A], fn_factory: &fn() -> ~fn(&A) -> B) -> ~[B] { vec::concat(map_slices(xs, || { - let f = copy f; + let f = fn_factory(); fn~(_base: uint, slice : &[A]) -> ~[B] { vec::map(slice, |x| f(x)) } @@ -103,10 +101,12 @@ pub fn map<A: Copy Owned, B: Copy Owned>( } /// A parallel version of mapi. -pub fn mapi<A: Copy Owned, B: Copy Owned>(xs: &[A], - f: fn~(uint, &A) -> B) -> ~[B] { +pub fn mapi<A: Copy Owned, B: Copy Owned>( + xs: &[A], + fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] +{ let slices = map_slices(xs, || { - let f = copy f; + let f = fn_factory(); fn~(base: uint, slice : &[A], copy f) -> ~[B] { vec::mapi(slice, |i, x| { f(i + base, x) @@ -119,32 +119,13 @@ pub fn mapi<A: Copy Owned, B: Copy Owned>(xs: &[A], r } -/** - * A parallel version of mapi. - * - * In this case, f is a function that creates functions to run over the - * inner elements. This is to skirt the need for copy constructors. - */ -pub fn mapi_factory<A: Copy Owned, B: Copy Owned>( - xs: &[A], f: fn() -> fn~(uint, A) -> B) -> ~[B] { - let slices = map_slices(xs, || { - let f = f(); - fn~(base: uint, slice : &[A], move f) -> ~[B] { - vec::mapi(slice, |i, x| { - f(i + base, *x) - }) - } - }); - let r = vec::concat(slices); - log(info, (r.len(), xs.len())); - assert(r.len() == xs.len()); - r -} - /// Returns true if the function holds for all elements in the vector. -pub fn alli<A: Copy Owned>(xs: &[A], f: fn~(uint, &A) -> bool) -> bool { +pub fn alli<A: Copy Owned>( + xs: &[A], + fn_factory: &fn() -> ~fn(uint, &A) -> bool) -> bool +{ do vec::all(map_slices(xs, || { - let f = copy f; + let f = fn_factory(); fn~(base: uint, slice : &[A], copy f) -> bool { vec::alli(slice, |i, x| { f(i + base, x) @@ -154,9 +135,11 @@ pub fn alli<A: Copy Owned>(xs: &[A], f: fn~(uint, &A) -> bool) -> bool { } /// Returns true if the function holds for any elements in the vector. -pub fn any<A: Copy Owned>(xs: &[A], f: fn~(&A) -> bool) -> bool { +pub fn any<A: Copy Owned>( + xs: &[A], + fn_factory: &fn() -> ~fn(&A) -> bool) -> bool { do vec::any(map_slices(xs, || { - let f = copy f; + let f = fn_factory(); fn~(_base : uint, slice: &[A], copy f) -> bool { vec::any(slice, |x| f(x)) } diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index d07c29d624c..dc2e3d3da2b 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; - use serialize; use core::io::Writer; diff --git a/src/libstd/rl.rs b/src/libstd/rl.rs index 5dd2a056327..30baa3cc5f1 100644 --- a/src/libstd/rl.rs +++ b/src/libstd/rl.rs @@ -64,7 +64,7 @@ pub unsafe fn read(prompt: ~str) -> Option<~str> { } } -pub type CompletionCb = fn~(~str, fn(~str)); +pub type CompletionCb = @fn(~str, fn(~str)); fn complete_key(_v: @CompletionCb) {} @@ -75,7 +75,7 @@ pub unsafe fn complete(cb: CompletionCb) { extern fn callback(line: *c_char, completions: *()) { unsafe { - let cb = copy *task::local_data::local_data_get(complete_key) + let cb = *task::local_data::local_data_get(complete_key) .get(); do cb(str::raw::from_c_str(line)) |suggestion| { diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index c7601f6b6b5..f8aef2c5f1e 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -33,8 +33,6 @@ * * access to a character by index is logarithmic (linear in strings); */ -#[forbid(deprecated_mode)]; - use core::cast; use core::char; use core::option; diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 4938ead9ea8..972df73d216 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -14,7 +14,6 @@ Core encoding and decoding interfaces. */ -#[forbid(deprecated_mode)]; #[forbid(non_camel_case_types)]; use core::at_vec; diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index a5c740c343c..6209170ac3d 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -22,8 +22,6 @@ * the `reset` method. */ -#[forbid(deprecated_mode)]; - use core::str; use core::uint; use core::vec; @@ -66,7 +64,7 @@ const k3: u32 = 0xCA62C1D6u32; /// Construct a `sha` object pub fn sha1() -> Sha1 { - type Sha1State = + struct Sha1State {h: ~[mut u32], mut len_low: u32, mut len_high: u32, @@ -258,7 +256,7 @@ pub fn sha1() -> Sha1 { return s; } } - let st = { + let st = Sha1State { h: vec::cast_to_mut(vec::from_elem(digest_buf_len, 0u32)), mut len_low: 0u32, mut len_high: 0u32, diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index a21328b3d63..9af596eb1f5 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -12,7 +12,6 @@ * A simple map based on a vector for small integer keys. Space requirements * are O(highest integer key). */ -#[forbid(deprecated_mode)]; use core::container::{Container, Mutable, Map, Set}; use core::option::{Some, None}; @@ -116,8 +115,6 @@ pub impl<V> SmallIntMap<V> { } pub impl<V: Copy> SmallIntMap<V> { - // FIXME: #4733, remove after the next snapshot - #[cfg(stage2)] fn update_with_key(&mut self, key: uint, val: V, ff: fn(uint, V, V) -> V) -> bool { match self.find(&key) { @@ -126,8 +123,6 @@ pub impl<V: Copy> SmallIntMap<V> { } } - // FIXME: #4733, remove after the next snapshot - #[cfg(stage2)] fn update(&mut self, key: uint, newval: V, ff: fn(V, V) -> V) -> bool { self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)) } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 6e89cd9e24f..680a2b99c4a 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -9,7 +9,6 @@ // except according to those terms. //! Sorting methods -#[forbid(deprecated_mode)]; use core::cmp::{Eq, Ord}; use core::dvec::DVec; @@ -64,14 +63,13 @@ pub pure fn merge_sort<T: Copy>(v: &[const T], le: Le<T>) -> ~[T] { } } -fn part<T: Copy>(arr: &mut [T], left: uint, - right: uint, pivot: uint, compare_func: Le<T>) -> uint { - let pivot_value = arr[pivot]; +fn part<T>(arr: &mut [T], left: uint, + right: uint, pivot: uint, compare_func: Le<T>) -> uint { arr[pivot] <-> arr[right]; let mut storage_index: uint = left; let mut i: uint = left; while i < right { - if compare_func(&arr[i], &pivot_value) { + if compare_func(&arr[i], &arr[right]) { arr[i] <-> arr[storage_index]; storage_index += 1; } @@ -81,8 +79,8 @@ fn part<T: Copy>(arr: &mut [T], left: uint, return storage_index; } -fn qsort<T: Copy>(arr: &mut [T], left: uint, - right: uint, compare_func: Le<T>) { +fn qsort<T>(arr: &mut [T], left: uint, + right: uint, compare_func: Le<T>) { if right > left { let pivot = (left + right) / 2u; let new_pivot = part::<T>(arr, left, right, pivot, compare_func); @@ -100,7 +98,7 @@ fn qsort<T: Copy>(arr: &mut [T], left: uint, * Has worst case O(n^2) performance, average case O(n log n). * This is an unstable sort. */ -pub fn quick_sort<T: Copy>(arr: &mut [T], compare_func: Le<T>) { +pub fn quick_sort<T>(arr: &mut [T], compare_func: Le<T>) { if len::<T>(arr) == 0u { return; } qsort::<T>(arr, 0u, len::<T>(arr) - 1u, compare_func); } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 65122bea750..8c142908d10 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -28,16 +28,8 @@ not required in or otherwise suitable for the core library. #[allow(vecs_implicitly_copyable)]; #[deny(non_camel_case_types)]; -// XXX this is set to allow because there are two methods in encoding -// that can't be silenced otherwise. Most every module is set to forbid -#[allow(deprecated_mode)]; -#[forbid(deprecated_pattern)]; #[allow(deprecated_self)]; - -// Transitional -#[legacy_records]; - #[no_core]; extern mod core(vers = "0.6"); diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 31c596c5038..b7e75897bf1 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; /** * The concurrency primitives you know and love. * diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index f10d54f3271..b786d913639 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -10,8 +10,6 @@ //! Temporary files and directories -#[forbid(deprecated_mode)]; - use core::os; use core::prelude::*; use core::rand; diff --git a/src/libstd/term.rs b/src/libstd/term.rs index ae5949e6f18..5616c7211c1 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -9,7 +9,6 @@ // except according to those terms. //! Simple ANSI color library -#[forbid(deprecated_mode)]; use core::i32; use core::io; diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 5a2693a42c1..e83b759f901 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -15,8 +15,6 @@ // simplest interface possible for representing and running tests // while providing a base that other test frameworks may build off of. -#[forbid(deprecated_mode)]; - use getopts; use sort; use term; @@ -51,20 +49,24 @@ pub type TestName = ~str; // the test succeeds; if the function fails then the test fails. We // may need to come up with a more clever definition of test in order // to support isolation of tests into tasks. -pub type TestFn = fn~(); +pub type TestFn = ~fn(); // The definition of a single test. A test runner will run a list of // these. pub struct TestDesc { name: TestName, - testfn: TestFn, ignore: bool, should_fail: bool } +pub struct TestDescAndFn { + desc: TestDesc, + testfn: TestFn, +} + // The default console test runner. It accepts the command line // arguments and a vector of test_descs (generated at compile time). -pub fn test_main(args: &[~str], tests: &[TestDesc]) { +pub fn test_main(args: &[~str], tests: ~[TestDescAndFn]) { let opts = match parse_opts(args) { either::Left(move o) => o, @@ -92,7 +94,7 @@ pub fn parse_opts(args: &[~str]) -> OptRes { }; let filter = - if vec::len(matches.free) > 0u { + if vec::len(matches.free) > 0 { option::Some(matches.free[0]) } else { option::None }; @@ -111,26 +113,27 @@ pub fn parse_opts(args: &[~str]) -> OptRes { #[deriving_eq] pub enum TestResult { TrOk, TrFailed, TrIgnored, } -type ConsoleTestState = - @{out: io::Writer, - log_out: Option<io::Writer>, - use_color: bool, - mut total: uint, - mut passed: uint, - mut failed: uint, - mut ignored: uint, - mut failures: ~[TestDesc]}; +struct ConsoleTestState { + out: io::Writer, + log_out: Option<io::Writer>, + use_color: bool, + mut total: uint, + mut passed: uint, + mut failed: uint, + mut ignored: uint, + mut failures: ~[TestDesc] +} // A simple console test runner pub fn run_tests_console(opts: &TestOpts, - tests: &[TestDesc]) -> bool { + tests: ~[TestDescAndFn]) -> bool { - fn callback(event: &TestEvent, st: ConsoleTestState) { + fn callback(event: &TestEvent, st: @ConsoleTestState) { debug!("callback(event=%?)", event); match *event { TeFiltered(ref filtered_tests) => { st.total = filtered_tests.len(); - let noun = if st.total != 1u { ~"tests" } else { ~"test" }; + let noun = if st.total != 1 { ~"tests" } else { ~"test" }; st.out.write_line(fmt!("\nrunning %u %s", st.total, noun)); } TeWait(ref test) => st.out.write_str( @@ -142,18 +145,18 @@ pub fn run_tests_console(opts: &TestOpts, } match result { TrOk => { - st.passed += 1u; + st.passed += 1; write_ok(st.out, st.use_color); st.out.write_line(~""); } TrFailed => { - st.failed += 1u; + st.failed += 1; write_failed(st.out, st.use_color); st.out.write_line(~""); st.failures.push(move test); } TrIgnored => { - st.ignored += 1u; + st.ignored += 1; write_ignored(st.out, st.use_color); st.out.write_line(~""); } @@ -174,19 +177,19 @@ pub fn run_tests_console(opts: &TestOpts, }; let st = - @{out: io::stdout(), + @ConsoleTestState{out: io::stdout(), log_out: log_out, use_color: use_color(), - mut total: 0u, - mut passed: 0u, - mut failed: 0u, - mut ignored: 0u, + mut total: 0, + mut passed: 0, + mut failed: 0, + mut ignored: 0, mut failures: ~[]}; run_tests(opts, tests, |x| callback(&x, st)); assert (st.passed + st.failed + st.ignored == st.total); - let success = st.failed == 0u; + let success = st.failed == 0; if !success { print_failures(st); @@ -234,7 +237,7 @@ pub fn run_tests_console(opts: &TestOpts, } } -fn print_failures(st: ConsoleTestState) { +fn print_failures(st: @ConsoleTestState) { st.out.write_line(~"\nfailures:"); let failures = copy st.failures; let failures = vec::map(failures, |test| test.name); @@ -246,29 +249,29 @@ fn print_failures(st: ConsoleTestState) { #[test] fn should_sort_failures_before_printing_them() { + fn dummy() {} + let s = do io::with_str_writer |wr| { let test_a = TestDesc { name: ~"a", - testfn: fn~() { }, ignore: false, should_fail: false }; let test_b = TestDesc { name: ~"b", - testfn: fn~() { }, ignore: false, should_fail: false }; let st = - @{out: wr, + @ConsoleTestState{out: wr, log_out: option::None, use_color: false, - mut total: 0u, - mut passed: 0u, - mut failed: 0u, - mut ignored: 0u, + mut total: 0, + mut passed: 0, + mut failed: 0, + mut ignored: 0, mut failures: ~[move test_b, move test_a]}; print_failures(st); @@ -279,7 +282,7 @@ fn should_sort_failures_before_printing_them() { assert apos < bpos; } -fn use_color() -> bool { return get_concurrency() == 1u; } +fn use_color() -> bool { return get_concurrency() == 1; } enum TestEvent { TeFiltered(~[TestDesc]), @@ -290,51 +293,50 @@ enum TestEvent { type MonitorMsg = (TestDesc, TestResult); fn run_tests(opts: &TestOpts, - tests: &[TestDesc], + tests: ~[TestDescAndFn], callback: fn@(e: TestEvent)) { let mut filtered_tests = filter_tests(opts, tests); - callback(TeFiltered(copy filtered_tests)); + + let filtered_descs = filtered_tests.map(|t| t.desc); + callback(TeFiltered(filtered_descs)); // It's tempting to just spawn all the tests at once, but since we have // many tests that run in other processes we would be making a big mess. let concurrency = get_concurrency(); debug!("using %u test tasks", concurrency); - let total = vec::len(filtered_tests); - let mut run_idx = 0; - let mut wait_idx = 0; - let mut done_idx = 0; + let mut remaining = filtered_tests; + vec::reverse(remaining); + let mut pending = 0; let (p, ch) = stream(); let ch = SharedChan(ch); - while done_idx < total { - while wait_idx < concurrency && run_idx < total { - let test = copy filtered_tests[run_idx]; + while pending > 0 || !remaining.is_empty() { + while pending < concurrency && !remaining.is_empty() { + let test = remaining.pop(); if concurrency == 1 { // We are doing one test at a time so we can print the name // of the test before we run it. Useful for debugging tests // that hang forever. - callback(TeWait(copy test)); + callback(TeWait(test.desc)); } - run_test(move test, ch.clone()); - wait_idx += 1; - run_idx += 1; + run_test(test, ch.clone()); + pending += 1; } - let (test, result) = p.recv(); + let (desc, result) = p.recv(); if concurrency != 1 { - callback(TeWait(copy test)); + callback(TeWait(desc)); } - callback(TeResult(move test, result)); - wait_idx -= 1; - done_idx += 1; + callback(TeResult(desc, result)); + pending -= 1; } } // Windows tends to dislike being overloaded with threads. #[cfg(windows)] -const sched_overcommit : uint = 1u; +const sched_overcommit : uint = 1; #[cfg(unix)] const sched_overcommit : uint = 4u; @@ -342,16 +344,17 @@ const sched_overcommit : uint = 4u; fn get_concurrency() -> uint { unsafe { let threads = rustrt::rust_sched_threads() as uint; - if threads == 1u { 1u } + if threads == 1 { 1 } else { threads * sched_overcommit } } } #[allow(non_implicitly_copyable_typarams)] -pub fn filter_tests(opts: &TestOpts, - tests: &[TestDesc]) - -> ~[TestDesc] { - let mut filtered = vec::slice(tests, 0, tests.len()); +pub fn filter_tests( + opts: &TestOpts, + tests: ~[TestDescAndFn]) -> ~[TestDescAndFn] +{ + let mut filtered = tests; // Remove tests that don't match the test filter filtered = if opts.filter.is_none() { @@ -363,10 +366,10 @@ pub fn filter_tests(opts: &TestOpts, option::None => ~"" }; - fn filter_fn(test: &TestDesc, filter_str: &str) -> - Option<TestDesc> { - if str::contains(test.name, filter_str) { - return option::Some(copy *test); + fn filter_fn(test: TestDescAndFn, filter_str: &str) -> + Option<TestDescAndFn> { + if str::contains(test.desc.name, filter_str) { + return option::Some(test); } else { return option::None; } } @@ -377,26 +380,26 @@ pub fn filter_tests(opts: &TestOpts, filtered = if !opts.run_ignored { move filtered } else { - fn filter(test: &TestDesc) -> Option<TestDesc> { - if test.ignore { - return option::Some(TestDesc { - name: test.name, - testfn: copy test.testfn, - ignore: false, - should_fail: test.should_fail}); - } else { return option::None; } + fn filter(test: TestDescAndFn) -> Option<TestDescAndFn> { + if test.desc.ignore { + let TestDescAndFn {desc, testfn} = test; + Some(TestDescAndFn { + desc: TestDesc {ignore: false, ..desc}, + testfn: testfn + }) + } else { + None + } }; vec::filter_map(filtered, |x| filter(x)) }; // Sort the tests alphabetically - filtered = { - pure fn lteq(t1: &TestDesc, t2: &TestDesc) -> bool { - str::le(t1.name, t2.name) - } - sort::merge_sort(filtered, lteq) - }; + pure fn lteq(t1: &TestDescAndFn, t2: &TestDescAndFn) -> bool { + str::le(t1.desc.name, t2.desc.name) + } + sort::quick_sort(filtered, lteq); move filtered } @@ -406,37 +409,40 @@ struct TestFuture { wait: fn@() -> TestResult, } -pub fn run_test(test: TestDesc, monitor_ch: SharedChan<MonitorMsg>) { - if test.ignore { - monitor_ch.send((copy test, TrIgnored)); +pub fn run_test(test: TestDescAndFn, monitor_ch: SharedChan<MonitorMsg>) { + let TestDescAndFn {desc, testfn} = test; + + if desc.ignore { + monitor_ch.send((desc, TrIgnored)); return; } - do task::spawn |move test| { - let testfn = copy test.testfn; + let testfn_cell = ::cell::Cell(testfn); + do task::spawn { let mut result_future = None; // task::future_result(builder); task::task().unlinked().future_result(|+r| { result_future = Some(move r); - }).spawn(move testfn); + }).spawn(testfn_cell.take()); let task_result = option::unwrap(move result_future).recv(); - let test_result = calc_result(&test, task_result == task::Success); - monitor_ch.send((copy test, test_result)); + let test_result = calc_result(&desc, task_result == task::Success); + monitor_ch.send((desc, test_result)); }; } -fn calc_result(test: &TestDesc, task_succeeded: bool) -> TestResult { +fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult { if task_succeeded { - if test.should_fail { TrFailed } + if desc.should_fail { TrFailed } else { TrOk } } else { - if test.should_fail { TrOk } + if desc.should_fail { TrOk } else { TrFailed } } } #[cfg(test)] mod tests { - use test::{TrFailed, TrIgnored, TrOk, filter_tests, parse_opts, TestDesc}; + use test::{TrFailed, TrIgnored, TrOk, filter_tests, parse_opts, + TestDesc, TestDescAndFn}; use test::{TestOpts, run_test}; use core::either; @@ -447,11 +453,13 @@ mod tests { #[test] pub fn do_not_run_ignored_tests() { fn f() { die!(); } - let desc = TestDesc { - name: ~"whatever", + let desc = TestDescAndFn { + desc: TestDesc { + name: ~"whatever", + ignore: true, + should_fail: false + }, testfn: f, - ignore: true, - should_fail: false }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -463,11 +471,13 @@ mod tests { #[test] pub fn ignored_tests_result_in_ignored() { fn f() { } - let desc = TestDesc { - name: ~"whatever", + let desc = TestDescAndFn { + desc: TestDesc { + name: ~"whatever", + ignore: true, + should_fail: false + }, testfn: f, - ignore: true, - should_fail: false }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -480,11 +490,13 @@ mod tests { #[ignore(cfg(windows))] pub fn test_should_fail() { fn f() { die!(); } - let desc = TestDesc { - name: ~"whatever", + let desc = TestDescAndFn { + desc: TestDesc { + name: ~"whatever", + ignore: false, + should_fail: true + }, testfn: f, - ignore: false, - should_fail: true }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -496,11 +508,13 @@ mod tests { #[test] pub fn test_should_fail_but_succeeds() { fn f() { } - let desc = TestDesc { - name: ~"whatever", + let desc = TestDescAndFn { + desc: TestDesc { + name: ~"whatever", + ignore: false, + should_fail: true + }, testfn: f, - ignore: false, - should_fail: true }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -531,6 +545,8 @@ mod tests { #[test] pub fn filter_for_ignored_option() { + fn dummy() {} + // When we run ignored tests the test filter should filter out all the // unignored tests and flip the ignore flag on the rest to false @@ -541,24 +557,28 @@ mod tests { }; let tests = ~[ - TestDesc { - name: ~"1", - testfn: fn~() { }, - ignore: true, - should_fail: false, + TestDescAndFn { + desc: TestDesc { + name: ~"1", + ignore: true, + should_fail: false, + }, + testfn: dummy, }, - TestDesc { - name: ~"2", - testfn: fn~() { }, - ignore: false, - should_fail: false, + TestDescAndFn { + desc: TestDesc { + name: ~"2", + ignore: false, + should_fail: false + }, + testfn: dummy, }, ]; let filtered = filter_tests(&opts, tests); - assert (vec::len(filtered) == 1u); - assert (filtered[0].name == ~"1"); - assert (filtered[0].ignore == false); + assert (vec::len(filtered) == 1); + assert (filtered[0].desc.name == ~"1"); + assert (filtered[0].desc.ignore == false); } #[test] @@ -578,12 +598,16 @@ mod tests { ~"test::sort_tests"]; let tests = { - let testfn = fn~() { }; + fn testfn() { } let mut tests = ~[]; for vec::each(names) |name| { - let test = TestDesc { - name: *name, testfn: copy testfn, ignore: false, - should_fail: false}; + let test = TestDescAndFn { + desc: TestDesc { + name: *name, ignore: false, + should_fail: false + }, + testfn: testfn, + }; tests.push(move test); } move tests @@ -603,7 +627,7 @@ mod tests { for vec::each(pairs) |p| { match *p { - (ref a, ref b) => { assert (*a == b.name); } + (ref a, ref b) => { assert (*a == b.desc.name); } } } } diff --git a/src/libstd/time.rs b/src/libstd/time.rs index dd25fc36d2d..f696d239d30 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[forbid(deprecated_mode)]; - use core::cmp::{Eq, Ord}; use core::int; use core::libc::{c_char, c_int, c_long, size_t, time_t}; diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index f89830ed12a..1da1bc60314 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -10,8 +10,6 @@ //! Utilities that leverage libuv's `uv_timer_*` API -#[forbid(deprecated_mode)]; - use uv; use uv::iotask; use uv::iotask::IoTask; diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 1105d65a4ed..1e90abcc03d 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -12,8 +12,6 @@ //! trees. The only requirement for the types is that the key implements //! `Ord`, and that the `lt` method provides a total ordering. -#[forbid(deprecated_mode)]; - use core::container::{Container, Mutable, Map, Set}; use core::cmp::{Eq, Ord}; use core::option::{Option, Some, None}; @@ -49,8 +47,8 @@ impl <K: Eq Ord, V: Eq> TreeMap<K, V>: Eq { let mut y = other.iter(); for self.len().times { unsafe { // unsafe as a purity workaround - x = x.next(); - y = y.next(); + map_next(&mut x); + map_next(&mut y); // FIXME: #4492 (ICE), x.get() == y.get() let (x1, x2) = x.get().unwrap(); let (y1, y2) = y.get().unwrap(); @@ -74,8 +72,8 @@ pure fn lt<K: Ord, V>(a: &TreeMap<K, V>, b: &TreeMap<K, V>) -> bool { let (a_len, b_len) = (a.len(), b.len()); for uint::min(a_len, b_len).times { unsafe { // purity workaround - x = x.next(); - y = y.next(); + map_next(&mut x); + map_next(&mut y); let (key_a,_) = x.get().unwrap(); let (key_b,_) = y.get().unwrap(); if *key_a < *key_b { return true; } @@ -142,7 +140,6 @@ impl <K: Ord, V> TreeMap<K, V>: Map<K, V> { loop { match *current { Some(ref r) => { - let r: &self/~TreeNode<K, V> = r; // FIXME: #3148 if *key < r.key { current = &r.left; } else if r.key < *key { @@ -211,32 +208,30 @@ impl <K: Ord, V> TreeMapIterator<K, V> { // Returns the current node, or None if this iterator is at the end. fn get(&const self) -> Option<(&self/K, &self/V)> { match self.current { - Some(res) => Some((&res.key, &res.value)), - None => None + Some(res) => Some((&res.key, &res.value)), + None => None } } +} - /// Advance the iterator to the next node (in order). If this iterator - /// is finished, does nothing. - fn next(self) -> TreeMapIterator/&self<K, V> { - let mut this = self; - while !this.stack.is_empty() || this.node.is_some() { - match *this.node { - Some(ref x) => { - this.stack.push(x); - this.node = &x.left; - } - None => { - let res = this.stack.pop(); - this.node = &res.right; - this.current = Some(res); - return this; - } - } +/// Advance the iterator to the next node (in order). If this iterator +/// is finished, does nothing. +pub fn map_next<K: Ord, V>(iter: &mut TreeMapIterator/&a<K, V>) { + while !iter.stack.is_empty() || iter.node.is_some() { + match *iter.node { + Some(ref x) => { + iter.stack.push(x); + iter.node = &x.left; + } + None => { + let res = iter.stack.pop(); + iter.node = &res.right; + iter.current = Some(res); + return; + } } - this.current = None; - return this; } + iter.current = None; } pub struct TreeSet<T> { @@ -298,18 +293,18 @@ impl <T: Ord> TreeSet<T>: Set<T> { let mut x = self.iter(); let mut y = other.iter(); unsafe { // purity workaround - x = x.next(); - y = y.next(); + set_next(&mut x); + set_next(&mut y); let mut a = x.get(); let mut b = y.get(); while a.is_some() && b.is_some() { let a1 = a.unwrap(); let b1 = b.unwrap(); if a1 < b1 { - x = x.next(); + set_next(&mut x); a = x.get(); } else if b1 < a1 { - y = y.next(); + set_next(&mut y); b = y.get(); } else { return false; @@ -329,8 +324,8 @@ impl <T: Ord> TreeSet<T>: Set<T> { let mut x = self.iter(); let mut y = other.iter(); unsafe { // purity workaround - x = x.next(); - y = y.next(); + set_next(&mut x); + set_next(&mut y); let mut a = x.get(); let mut b = y.get(); while b.is_some() { @@ -346,10 +341,10 @@ impl <T: Ord> TreeSet<T>: Set<T> { } if !(a1 < b1) { - y = y.next(); + set_next(&mut y); b = y.get(); } - x = x.next(); + set_next(&mut x); a = x.get(); } } @@ -362,15 +357,15 @@ impl <T: Ord> TreeSet<T>: Set<T> { let mut y = other.iter(); unsafe { // purity workaround - x = x.next(); - y = y.next(); + set_next(&mut x); + set_next(&mut y); let mut a = x.get(); let mut b = y.get(); while a.is_some() { if b.is_none() { return do a.while_some() |a1| { - if f(a1) { x = x.next(); x.get() } else { None } + if f(a1) { set_next(&mut x); x.get() } else { None } } } @@ -379,11 +374,11 @@ impl <T: Ord> TreeSet<T>: Set<T> { if a1 < b1 { if !f(a1) { return } - x = x.next(); + set_next(&mut x); a = x.get(); } else { - if !(b1 < a1) { x = x.next(); a = x.get() } - y = y.next(); + if !(b1 < a1) { set_next(&mut x); a = x.get() } + set_next(&mut y); b = y.get(); } } @@ -397,15 +392,15 @@ impl <T: Ord> TreeSet<T>: Set<T> { let mut y = other.iter(); unsafe { // purity workaround - x = x.next(); - y = y.next(); + set_next(&mut x); + set_next(&mut y); let mut a = x.get(); let mut b = y.get(); while a.is_some() { if b.is_none() { return do a.while_some() |a1| { - if f(a1) { x.next(); x.get() } else { None } + if f(a1) { set_next(&mut x); x.get() } else { None } } } @@ -414,21 +409,21 @@ impl <T: Ord> TreeSet<T>: Set<T> { if a1 < b1 { if !f(a1) { return } - x = x.next(); + set_next(&mut x); a = x.get(); } else { if b1 < a1 { if !f(b1) { return } } else { - x = x.next(); + set_next(&mut x); a = x.get(); } - y = y.next(); + set_next(&mut y); b = y.get(); } } do b.while_some |b1| { - if f(b1) { y = y.next(); y.get() } else { None } + if f(b1) { set_next(&mut y); y.get() } else { None } } } } @@ -439,8 +434,8 @@ impl <T: Ord> TreeSet<T>: Set<T> { let mut y = other.iter(); unsafe { // purity workaround - x = x.next(); - y = y.next(); + set_next(&mut x); + set_next(&mut y); let mut a = x.get(); let mut b = y.get(); @@ -448,13 +443,13 @@ impl <T: Ord> TreeSet<T>: Set<T> { let a1 = a.unwrap(); let b1 = b.unwrap(); if a1 < b1 { - x = x.next(); + set_next(&mut x); a = x.get(); } else { if !(b1 < a1) { if !f(a1) { return } } - y = y.next(); + set_next(&mut y); b = y.get(); } } @@ -467,15 +462,15 @@ impl <T: Ord> TreeSet<T>: Set<T> { let mut y = other.iter(); unsafe { // purity workaround - x = x.next(); - y = y.next(); + set_next(&mut x); + set_next(&mut y); let mut a = x.get(); let mut b = y.get(); while a.is_some() { if b.is_none() { return do a.while_some() |a1| { - if f(a1) { x = x.next(); x.get() } else { None } + if f(a1) { set_next(&mut x); x.get() } else { None } } } @@ -484,15 +479,15 @@ impl <T: Ord> TreeSet<T>: Set<T> { if b1 < a1 { if !f(b1) { return } - y = y.next(); + set_next(&mut y); b = y.get(); } else { if !f(a1) { return } if !(a1 < b1) { - y = y.next(); + set_next(&mut y); b = y.get() } - x = x.next(); + set_next(&mut x); a = x.get(); } } @@ -525,16 +520,16 @@ impl <T: Ord> TreeSetIterator<T> { /// Returns the current node, or None if this iterator is at the end. fn get(&const self) -> Option<&self/T> { match self.iter.get() { - None => None, - Some((k, _)) => Some(k) + None => None, + Some((k, _)) => Some(k) } } +} - /// Advance the iterator to the next node (in order). If this iterator is - /// finished, does nothing. - fn next(self) -> TreeSetIterator/&self<T> { - TreeSetIterator { iter: self.iter.next() } - } +/// Advance the iterator to the next node (in order). If this iterator is +/// finished, does nothing. +pub fn set_next<T: Ord>(iter: &mut TreeSetIterator/&a<T>) { + map_next(&mut iter.iter); } // Nodes keep track of their level in the tree, starting at 1 in the @@ -746,8 +741,8 @@ mod test_treemap { let v1 = str::to_bytes(~"baz"); let v2 = str::to_bytes(~"foobar"); - m.insert(k1, v1); - m.insert(k2, v2); + m.insert(copy k1, copy v1); + m.insert(copy k2, copy v2); assert m.find(&k2) == Some(&v2); assert m.find(&k1) == Some(&v1); @@ -966,20 +961,20 @@ mod test_treemap { let m = m; let mut iter = m.iter(); - // FIXME: #4492 (ICE): iter.next() == Some((&x1, &y1)) + // FIXME: #4492 (ICE): iter.get() == Some((&x1, &y1)) - iter = iter.next(); + map_next(&mut iter); assert iter.get().unwrap() == (&x1, &y1); - iter = iter.next(); + map_next(&mut iter); assert iter.get().unwrap() == (&x2, &y2); - iter = iter.next(); + map_next(&mut iter); assert iter.get().unwrap() == (&x3, &y3); - iter = iter.next(); + map_next(&mut iter); assert iter.get().unwrap() == (&x4, &y4); - iter = iter.next(); + map_next(&mut iter); assert iter.get().unwrap() == (&x5, &y5); - iter = iter.next(); + map_next(&mut iter); assert iter.get().is_none(); } } diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 736954f6b22..9763f655a6f 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -10,8 +10,6 @@ //! A process-wide libuv event loop for library use. -#[forbid(deprecated_mode)]; - use ll = uv_ll; use iotask = uv_iotask; use get_gl = get; diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 6fcbccf8183..a44fef54b72 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -14,7 +14,6 @@ * The I/O task runs in its own single-threaded scheduler. By using the * `interact` function you can execute code in a uv callback. */ -#[forbid(deprecated_mode)]; use ll = uv_ll; @@ -27,19 +26,17 @@ use core::task::TaskBuilder; use core::task; /// Used to abstract-away direct interaction with a libuv loop. -pub enum IoTask { - IoTask_({ - async_handle: *ll::uv_async_t, - op_chan: SharedChan<IoTaskMsg> - }) +pub struct IoTask { + async_handle: *ll::uv_async_t, + op_chan: SharedChan<IoTaskMsg> } impl IoTask: Clone { fn clone(&self) -> IoTask { - IoTask_({ + IoTask{ async_handle: self.async_handle, op_chan: self.op_chan.clone() - }) + } } } @@ -131,10 +128,10 @@ fn run_loop(iotask_ch: &Chan<IoTask>) { // Send out a handle through which folks can talk to us // while we dwell in the I/O loop - let iotask = IoTask_({ + let iotask = IoTask{ async_handle: async_handle, op_chan: SharedChan(msg_ch) - }); + }; iotask_ch.send(iotask); log(debug, ~"about to run uv loop"); diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index 8bef6eb6c91..ca5a821921a 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -1543,7 +1543,7 @@ pub mod test { let continue_async_handle_ptr = ptr::addr_of(&continue_async_handle); let async_data = - { continue_chan: continue_chan }; + async_handle_data { continue_chan: continue_chan }; let async_data_ptr = ptr::addr_of(&async_data); let server_data = tcp_server_data { diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 95deec08feb..b828c4ef629 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[allow(deprecated_mode)]; + use json; use sha1; use serialize::{Encoder, Encodable, Decoder, Decodable}; @@ -167,20 +169,6 @@ struct Database { } impl Database { - #[cfg(stage0)] - #[cfg(stage1)] - fn prepare(&mut self, fn_name: &str, - declared_inputs: &WorkMap) -> Option<(WorkMap, WorkMap, ~str)> - { - let k = json_encode(&(fn_name, declared_inputs)); - let db_cache = copy self.db_cache; - match db_cache.find(&k) { - None => None, - Some(&v) => Some(json_decode(copy v)) - } - } - - #[cfg(stage2)] fn prepare(&mut self, fn_name: &str, declared_inputs: &WorkMap) -> Option<(WorkMap, WorkMap, ~str)> { @@ -235,13 +223,6 @@ struct Exec { discovered_outputs: WorkMap } -#[cfg(stage0)] -struct Work<T:Owned> { - prep: @Mut<Prep>, - res: Option<Either<T,PortOne<(Exec,T)>>> -} -#[cfg(stage1)] -#[cfg(stage2)] struct Work<T> { prep: @Mut<Prep>, res: Option<Either<T,PortOne<(Exec,T)>>> |
