From 3023bd872949ce4ba45e13dbcd30d6b98963d0ed Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 25 Sep 2012 18:27:45 -0700 Subject: Demode dvec --- src/libstd/map.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstd/map.rs') diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 9bdf6e15ee5..06df5a9e8ae 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -356,7 +356,7 @@ mod chained { } impl T: ops::Index { - pure fn index(&&k: K) -> V { + pure fn index(+k: K) -> V { unsafe { self.get(k) } -- cgit 1.4.1-3-g733a5 From bc9efaad9c978f71bd7ac2c91efbc957e25d43fb Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 28 Sep 2012 00:22:18 -0700 Subject: std: Eliminate deprecated patterns --- src/libstd/arc.rs | 1 - src/libstd/arena.rs | 1 - src/libstd/base64.rs | 1 - src/libstd/bitv.rs | 61 ++++++++++++++++++++++---------------------- src/libstd/cell.rs | 1 - src/libstd/cmp.rs | 1 - src/libstd/comm.rs | 1 - src/libstd/dbg.rs | 1 - src/libstd/deque.rs | 3 +-- src/libstd/fun_treemap.rs | 15 +++++------ src/libstd/getopts.rs | 29 ++++++++++----------- src/libstd/json.rs | 23 ++++++++--------- src/libstd/list.rs | 13 +++++----- src/libstd/map.rs | 3 +-- src/libstd/md4.rs | 1 - src/libstd/net_ip.rs | 17 ++++++------ src/libstd/net_tcp.rs | 34 ++++++++++++------------ src/libstd/net_url.rs | 3 +-- src/libstd/prettyprint.rs | 1 - src/libstd/prettyprint2.rs | 1 - src/libstd/rope.rs | 17 ++++++------ src/libstd/serialization.rs | 4 +-- src/libstd/serialization2.rs | 11 ++++---- src/libstd/sha1.rs | 1 - src/libstd/smallintmap.rs | 5 ++-- src/libstd/sort.rs | 1 - src/libstd/std.rc | 1 + src/libstd/sync.rs | 1 - src/libstd/tempfile.rs | 1 - src/libstd/term.rs | 5 ++-- src/libstd/test.rs | 27 ++++++++++---------- src/libstd/time.rs | 3 +-- src/libstd/timer.rs | 1 - src/libstd/treemap.rs | 1 - src/libstd/unicode.rs | 1 - src/libstd/uv_global_loop.rs | 1 - src/libstd/uv_iotask.rs | 3 +-- 37 files changed, 130 insertions(+), 165 deletions(-) (limited to 'src/libstd/map.rs') diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 1f26822ed9f..a4d19b110d7 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -1,6 +1,5 @@ // NB: transitionary, de-mode-ing. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /** * 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 fbe9a2ddae6..de3c5774bfe 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -23,7 +23,6 @@ // to waste time running the destructors of POD. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; export Arena, arena_with_size; diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 995910e635d..9bad4d39750 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use io::Reader; pub trait ToBase64 { diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 0ff0c0b6457..33065fffd03 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use vec::{to_mut, from_elem}; @@ -241,22 +240,22 @@ priv impl Bitv { self.die(); } match self.rep { - Small(s) => match other.rep { - Small(s1) => match op { - Union => s.union(s1, self.nbits), - Intersect => s.intersect(s1, self.nbits), - Assign => s.become(s1, self.nbits), - Difference => s.difference(s1, self.nbits) + Small(ref s) => match other.rep { + Small(ref s1) => match op { + Union => s.union(*s1, self.nbits), + Intersect => s.intersect(*s1, self.nbits), + Assign => s.become(*s1, self.nbits), + Difference => s.difference(*s1, self.nbits) }, Big(_) => self.die() }, - Big(s) => match other.rep { + Big(ref s) => match other.rep { Small(_) => self.die(), - Big(s1) => match op { - Union => s.union(s1, self.nbits), - Intersect => s.intersect(s1, self.nbits), - Assign => s.become(s1, self.nbits), - Difference => s.difference(s1, self.nbits) + Big(ref s1) => match op { + Union => s.union(*s1, self.nbits), + Intersect => s.intersect(*s1, self.nbits), + Assign => s.become(*s1, self.nbits), + Difference => s.difference(*s1, self.nbits) } } } @@ -297,10 +296,10 @@ impl Bitv { #[inline(always)] fn clone() -> ~Bitv { ~match self.rep { - Small(b) => { + Small(ref b) => { Bitv{nbits: self.nbits, rep: Small(~SmallBitv{bits: b.bits})} } - Big(b) => { + Big(ref b) => { let st = to_mut(from_elem(self.nbits / uint_bits + 1, 0)); let len = st.len(); for uint::range(0, len) |i| { st[i] = b.storage[i]; }; @@ -314,8 +313,8 @@ impl Bitv { pure fn get(i: uint) -> bool { assert (i < self.nbits); match self.rep { - Big(b) => b.get(i), - Small(s) => s.get(i) + Big(ref b) => b.get(i), + Small(ref s) => s.get(i) } } @@ -328,8 +327,8 @@ impl Bitv { fn set(i: uint, x: bool) { assert (i < self.nbits); match self.rep { - Big(b) => b.set(i, x), - Small(s) => s.set(i, x) + Big(ref b) => b.set(i, x), + Small(ref s) => s.set(i, x) } } @@ -343,12 +342,12 @@ impl Bitv { fn equal(v1: Bitv) -> bool { if self.nbits != v1.nbits { return false; } match self.rep { - Small(b) => match v1.rep { - Small(b1) => b.equals(b1, self.nbits), + Small(ref b) => match v1.rep { + Small(ref b1) => b.equals(*b1, self.nbits), _ => false }, - Big(s) => match v1.rep { - Big(s1) => s.equals(s1, self.nbits), + Big(ref s) => match v1.rep { + Big(ref s1) => s.equals(*s1, self.nbits), Small(_) => return false } } @@ -358,8 +357,8 @@ impl Bitv { #[inline(always)] fn clear() { match self.rep { - Small(b) => b.clear(), - Big(s) => for s.each_storage() |w| { w = 0u } + Small(ref b) => b.clear(), + Big(ref s) => for s.each_storage() |w| { w = 0u } } } @@ -367,16 +366,16 @@ impl Bitv { #[inline(always)] fn set_all() { match self.rep { - Small(b) => b.set_all(), - Big(s) => for s.each_storage() |w| { w = !0u } } + Small(ref b) => b.set_all(), + Big(ref s) => for s.each_storage() |w| { w = !0u } } } /// Invert all bits #[inline(always)] fn invert() { match self.rep { - Small(b) => b.invert(), - Big(s) => for s.each_storage() |w| { w = !w } } + Small(ref b) => b.invert(), + Big(ref s) => for s.each_storage() |w| { w = !w } } } /** @@ -395,7 +394,7 @@ impl Bitv { #[inline(always)] fn is_true() -> bool { match self.rep { - Small(b) => b.is_true(self.nbits), + Small(ref b) => b.is_true(self.nbits), _ => { for self.each() |i| { if !i { return false; } } true @@ -415,7 +414,7 @@ impl Bitv { /// Returns true if all bits are 0 fn is_false() -> bool { match self.rep { - Small(b) => b.is_false(self.nbits), + Small(ref b) => b.is_false(self.nbits), Big(_) => { for self.each() |i| { if i { return false; } } true diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index bc16aa2e03e..4ef695f4198 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /// A dynamic, mutable location. /// /// Similar to a mutable option type, but friendlier. diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index 52c50a39f25..2ec0bf41675 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /// Additional general-purpose comparison functionality. const fuzzy_epsilon: float = 1.0e-6; diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index e2d4646d670..58958d6115e 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -6,7 +6,6 @@ Higher level communication abstractions. // NB: transitionary, de-mode-ing. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use pipes::{Channel, Recv, Chan, Port, Selectable}; diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index ac343053bed..26b2a02ec9c 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; //! Unsafe debugging functions for inspecting values. use cast::reinterpret_cast; diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 8506bd5f6fc..515f033b1f1 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -1,6 +1,5 @@ //! A deque. Untested as of yet. Likely buggy #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; #[forbid(non_camel_case_types)]; use option::{Some, None}; @@ -46,7 +45,7 @@ fn create() -> Deque { move rv } fn get(elts: &DVec>, i: uint) -> T { - match (*elts).get_elt(i) { Some(t) => t, _ => fail } + match (*elts).get_elt(i) { Some(move t) => t, _ => fail } } type Repr = {mut nelts: uint, diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index 778a62eebbe..6388e8983d2 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -1,5 +1,4 @@ #[warn(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /*! * A functional key,value store that works on anything. @@ -37,7 +36,7 @@ fn insert(m: Treemap, +k: K, +v: V) -> Treemap { @match m { @Empty => Node(@k, @v, @Empty, @Empty), - @Node(@kk, vv, left, right) => { + @Node(@copy kk, vv, left, right) => { if k < kk { Node(@kk, vv, insert(left, k, v), right) } else if k == kk { @@ -51,10 +50,10 @@ fn insert(m: Treemap, +k: K, +v: V) fn find(m: Treemap, +k: K) -> Option { match *m { Empty => None, - Node(@kk, @v, left, right) => { - if k == kk { + Node(@ref kk, @copy v, left, right) => { + if k == *kk { Some(v) - } else if k < kk { find(left, move k) } else { find(right, move k) } + } else if k < *kk { find(left, move k) } else { find(right, move k) } } } } @@ -68,11 +67,9 @@ fn traverse(m: Treemap, f: fn((&K), (&V))) { matches to me, so I changed it. but that may be a de-optimization -- tjc */ - Node(@k, @v, left, right) => { - // copy v to make aliases work out - let v1 = v; + Node(@ref k, @ref v, left, right) => { traverse(left, f); - f(&k, &v1); + f(k, v); traverse(right, f); } } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 7a47db8a7f0..3106ed953b1 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -63,7 +63,6 @@ */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::Eq; use core::result::{Err, Ok}; @@ -110,9 +109,9 @@ fn mkname(nm: &str) -> Name { impl Name : Eq { pure fn eq(other: &Name) -> bool { match self { - Long(e0a) => { + Long(ref e0a) => { match (*other) { - Long(e0b) => e0a == e0b, + Long(ref e0b) => e0a == e0b, _ => false } } @@ -177,7 +176,7 @@ fn is_arg(arg: &str) -> bool { fn name_str(nm: &Name) -> ~str { return match *nm { Short(ch) => str::from_char(ch), - Long(s) => s + Long(copy s) => s }; } @@ -200,12 +199,12 @@ enum Fail_ { /// Convert a `fail_` enum into an error string fn fail_str(+f: Fail_) -> ~str { return match f { - ArgumentMissing(nm) => ~"Argument to option '" + nm + ~"' missing.", - UnrecognizedOption(nm) => ~"Unrecognized option: '" + nm + ~"'.", - OptionMissing(nm) => ~"Required option '" + nm + ~"' missing.", - OptionDuplicated(nm) => ~"Option '" + nm + ~"' given more than once.", - UnexpectedArgument(nm) => { - ~"Option " + nm + ~" does not take an argument." + ArgumentMissing(ref nm) => ~"Argument to option '" + *nm + ~"' missing.", + UnrecognizedOption(ref nm) => ~"Unrecognized option: '" + *nm + ~"'.", + OptionMissing(ref nm) => ~"Required option '" + *nm + ~"' missing.", + OptionDuplicated(ref nm) => ~"Option '" + *nm + ~"' given more than once.", + UnexpectedArgument(ref nm) => { + ~"Option " + *nm + ~" does not take an argument." } }; } @@ -382,7 +381,7 @@ fn opts_present(+mm: Matches, names: &[~str]) -> bool { * argument */ fn opt_str(+mm: Matches, nm: &str) -> ~str { - return match opt_val(mm, nm) { Val(s) => s, _ => fail }; + return match opt_val(mm, nm) { Val(copy s) => s, _ => fail }; } /** @@ -394,7 +393,7 @@ fn opt_str(+mm: Matches, nm: &str) -> ~str { fn opts_str(+mm: Matches, names: &[~str]) -> ~str { for vec::each(names) |nm| { match opt_val(mm, *nm) { - Val(s) => return s, + Val(copy s) => return s, _ => () } } @@ -411,7 +410,7 @@ fn opts_str(+mm: Matches, names: &[~str]) -> ~str { fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { let mut acc: ~[~str] = ~[]; for vec::each(opt_vals(mm, nm)) |v| { - match *v { Val(s) => acc.push(s), _ => () } + match *v { Val(copy s) => acc.push(s), _ => () } } return acc; } @@ -420,7 +419,7 @@ fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { let vals = opt_vals(mm, nm); if vec::len::(vals) == 0u { return None::<~str>; } - return match vals[0] { Val(s) => Some::<~str>(s), _ => None::<~str> }; + return match vals[0] { Val(copy s) => Some::<~str>(s), _ => None::<~str> }; } @@ -434,7 +433,7 @@ fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { fn opt_default(+mm: Matches, nm: &str, def: &str) -> Option<~str> { let vals = opt_vals(mm, nm); if vec::len::(vals) == 0u { return None::<~str>; } - return match vals[0] { Val(s) => Some::<~str>(s), + return match vals[0] { Val(copy s) => Some::<~str>(s), _ => Some::<~str>(str::from_slice(def)) } } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 29535c62b5e..9e53febb85f 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -1,7 +1,6 @@ // Rust JSON serialization library // Copyright (c) 2011 Google Inc. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; #[forbid(non_camel_case_types)]; //! json serialization @@ -252,7 +251,7 @@ pub impl PrettySerializer: serialization2::Serializer { pub fn to_serializer(ser: &S, json: &Json) { match *json { Number(f) => ser.emit_float(f), - String(s) => ser.emit_str(s), + String(ref s) => ser.emit_str(*s), Boolean(b) => ser.emit_bool(b), List(v) => { do ser.emit_vec(v.len()) || { @@ -261,7 +260,7 @@ pub fn to_serializer(ser: &S, json: &Json) { } } } - Object(o) => { + Object(ref o) => { do ser.emit_rec || { let mut idx = 0; for o.each |key, value| { @@ -866,8 +865,8 @@ impl Json : Eq { match self { Number(f0) => match *other { Number(f1) => f0 == f1, _ => false }, - String(s0) => - match *other { String(s1) => s0 == s1, _ => false }, + String(ref s0) => + match *other { String(ref s1) => s0 == s1, _ => false }, Boolean(b0) => match *other { Boolean(b1) => b0 == b1, _ => false }, Null => @@ -910,10 +909,10 @@ impl Json : Ord { } } - String(s0) => { + String(ref s0) => { match *other { Number(_) => false, - String(s1) => s0 < s1, + String(ref s1) => s0 < s1, Boolean(_) | List(_) | Object(_) | Null => true } } @@ -934,10 +933,10 @@ impl Json : Ord { } } - Object(d0) => { + Object(ref d0) => { match *other { Number(_) | String(_) | Boolean(_) | List(_) => false, - Object(d1) => { + Object(ref d1) => { unsafe { let mut d0_flat = ~[]; let mut d1_flat = ~[]; @@ -1065,7 +1064,7 @@ impl @~str: ToJson { impl (A, B): ToJson { fn to_json() -> Json { match self { - (a, b) => { + (ref a, ref b) => { List(~[a.to_json(), b.to_json()]) } } @@ -1075,7 +1074,7 @@ impl (A, B): ToJson { impl (A, B, C): ToJson { fn to_json() -> Json { match self { - (a, b, c) => { + (ref a, ref b, ref c) => { List(~[a.to_json(), b.to_json(), c.to_json()]) } } @@ -1112,7 +1111,7 @@ impl Option: ToJson { fn to_json() -> Json { match self { None => Null, - Some(value) => value.to_json() + Some(ref value) => value.to_json() } } } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index d8f7edada6a..1568c6c099f 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -1,6 +1,5 @@ //! A standard linked list #[warn(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::Eq; use core::option; @@ -47,8 +46,8 @@ fn find(ls: @List, f: fn((&T)) -> bool) -> Option { let mut ls = ls; loop { ls = match *ls { - Cons(hd, tl) => { - if f(&hd) { return Some(hd); } + Cons(ref hd, tl) => { + if f(hd) { return Some(*hd); } tl } Nil => return None @@ -95,7 +94,7 @@ pure fn tail(ls: @List) -> @List { /// Returns the first element of a list pure fn head(ls: @List) -> T { match *ls { - Cons(hd, _) => hd, + Cons(copy hd, _) => hd, // makes me sad _ => fail ~"head invoked on empty list" } @@ -105,7 +104,7 @@ pure fn head(ls: @List) -> T { pure fn append(l: @List, m: @List) -> @List { match *l { Nil => return m, - Cons(x, xs) => { + Cons(copy x, xs) => { let rest = append(xs, m); return @Cons(x, rest); } @@ -151,9 +150,9 @@ fn each(l: @List, f: fn((&T)) -> bool) { impl List : Eq { pure fn eq(other: &List) -> bool { match self { - Cons(e0a, e1a) => { + Cons(ref e0a, e1a) => { match (*other) { - Cons(e0b, e1b) => e0a == e0b && e1a == e1b, + Cons(ref e0b, e1b) => e0a == e0b && e1a == e1b, _ => false } } diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 06df5a9e8ae..fce75cbda75 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -1,7 +1,6 @@ //! A map type #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use io::WriterUtil; use to_str::ToStr; @@ -404,7 +403,7 @@ fn hash_from_vec( let map = HashMap(); for vec::each(items) |item| { match *item { - (key, value) => { + (copy key, copy value) => { map.insert(key, value); } } diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index 6de6ea8b16c..581beb78bdc 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; pub fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { // subtle: if orig_len is merely uint, then the code below diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 347f2b271a1..ad4eb9a0fa6 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -1,6 +1,5 @@ //! Types/fns concerning Internet Protocol (IP), versions 4 & 6 #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use iotask = uv::iotask::IoTask; use interact = uv::iotask::interact; @@ -48,15 +47,15 @@ type ParseAddrErr = { */ fn format_addr(ip: &IpAddr) -> ~str { match *ip { - Ipv4(addr) => unsafe { - let result = uv_ip4_name(&addr); + Ipv4(ref addr) => unsafe { + let result = uv_ip4_name(addr); if result == ~"" { fail ~"failed to convert inner sockaddr_in address to str" } result }, - Ipv6(addr) => unsafe { - let result = uv_ip6_name(&addr); + Ipv6(ref addr) => unsafe { + let result = uv_ip6_name(addr); if result == ~"" { fail ~"failed to convert inner sockaddr_in address to str" } @@ -136,8 +135,8 @@ mod v4 { */ fn parse_addr(ip: &str) -> IpAddr { match try_parse_addr(ip) { - result::Ok(addr) => copy(addr), - result::Err(err_data) => fail err_data.err_msg + result::Ok(copy addr) => addr, + result::Err(ref err_data) => fail err_data.err_msg } } // the simple, old style numberic representation of @@ -223,8 +222,8 @@ mod v6 { */ fn parse_addr(ip: &str) -> IpAddr { match try_parse_addr(ip) { - result::Ok(addr) => copy(addr), - result::Err(err_data) => fail err_data.err_msg + result::Ok(copy addr) => addr, + result::Err(copy err_data) => fail err_data.err_msg } } fn try_parse_addr(ip: &str) -> result::Result { diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index a0ba8aae3f1..011c7e6a0c7 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -168,7 +168,7 @@ fn connect(+input_ip: ip::IpAddr, port: uint, ptr::addr_of((*socket_data_ptr).connect_req); let addr_str = ip::format_addr(&input_ip); let connect_result = match input_ip { - ip::Ipv4(addr) => { + ip::Ipv4(ref addr) => { // have to "recreate" the sockaddr_in/6 // since the ip_addr discards the port // info.. should probably add an additional @@ -233,7 +233,7 @@ fn connect(+input_ip: ip::IpAddr, port: uint, log(debug, ~"tcp::connect - received success on result_po"); result::Ok(TcpSocket(socket_data)) } - ConnFailure(err_data) => { + ConnFailure(ref err_data) => { core::comm::recv(closed_signal_po); log(debug, ~"tcp::connect - received failure on result_po"); // still have to free the malloc'd stream handle.. @@ -535,7 +535,7 @@ fn accept(new_conn: TcpNewConnection) } // UNSAFE LIBUV INTERACTION END match core::comm::recv(result_po) { - Some(err_data) => result::Err(err_data), + Some(copy err_data) => result::Err(err_data), None => result::Ok(TcpSocket(client_socket_data)) } } @@ -623,13 +623,13 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint, server_data_ptr); let addr_str = ip::format_addr(&loc_ip); let bind_result = match loc_ip { - ip::Ipv4(addr) => { + ip::Ipv4(ref addr) => { log(debug, fmt!("addr: %?", addr)); let in_addr = uv::ll::ip4_addr(addr_str, port as int); uv::ll::tcp_bind(server_stream_ptr, ptr::addr_of(in_addr)) } - ip::Ipv6(addr) => { + ip::Ipv6(ref addr) => { log(debug, fmt!("addr: %?", addr)); let in_addr = uv::ll::ip6_addr(addr_str, port as int); uv::ll::tcp_bind6(server_stream_ptr, @@ -666,7 +666,7 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint, setup_ch.recv() }; match setup_result { - Some(err_data) => { + Some(ref err_data) => { do iotask::interact(iotask) |loop_ptr| unsafe { log(debug, fmt!("tcp::listen post-kill recv hl interact %?", loop_ptr)); @@ -703,7 +703,7 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint, stream_closed_po.recv(); match kill_result { // some failure post bind/listen - Some(err_data) => result::Err(GenericListenErr(err_data.err_name, + Some(ref err_data) => result::Err(GenericListenErr(err_data.err_name, err_data.err_msg)), // clean exit None => result::Ok(()) @@ -884,7 +884,7 @@ fn read_common_impl(socket_data: *TcpSocketData, timeout_msecs: uint) Some(core::comm::recv(result::get(&rs_result))) }; log(debug, ~"tcp::read after recv_timeout"); - match read_result { + match move read_result { None => { log(debug, ~"tcp::read: timed out.."); let err_data = { @@ -894,7 +894,7 @@ fn read_common_impl(socket_data: *TcpSocketData, timeout_msecs: uint) read_stop_common_impl(socket_data); result::Err(err_data) } - Some(data_result) => { + Some(move data_result) => { log(debug, ~"tcp::read got data"); read_stop_common_impl(socket_data); data_result @@ -924,7 +924,7 @@ fn read_stop_common_impl(socket_data: *TcpSocketData) -> } }; match core::comm::recv(stop_po) { - Some(err_data) => result::Err(err_data.to_tcp_err()), + Some(ref err_data) => result::Err(err_data.to_tcp_err()), None => result::Ok(()) } } @@ -954,7 +954,7 @@ fn read_start_common_impl(socket_data: *TcpSocketData) } }; match core::comm::recv(start_po) { - Some(err_data) => result::Err(err_data.to_tcp_err()), + Some(ref err_data) => result::Err(err_data.to_tcp_err()), None => result::Ok((*socket_data).reader_po) } } @@ -1001,7 +1001,7 @@ fn write_common_impl(socket_data_ptr: *TcpSocketData, // aftermath, so we don't have to sit here blocking. match core::comm::recv(result_po) { TcpWriteSuccess => result::Ok(()), - TcpWriteError(err_data) => result::Err(err_data.to_tcp_err()) + TcpWriteError(ref err_data) => result::Err(err_data.to_tcp_err()) } } @@ -1530,8 +1530,8 @@ mod test { log(debug, ~"SERVER: successfully accepted"+ ~"connection!"); let received_req_bytes = read(&sock, 0u); - match received_req_bytes { - result::Ok(data) => { + match move received_req_bytes { + result::Ok(move data) => { log(debug, ~"SERVER: got REQ str::from_bytes.."); log(debug, fmt!("SERVER: REQ data len: %?", vec::len(data))); @@ -1542,7 +1542,7 @@ mod test { log(debug, ~"SERVER: after write.. die"); core::comm::send(kill_ch, None); } - result::Err(err_data) => { + result::Err(move err_data) => { log(debug, fmt!("SERVER: error recvd: %s %s", err_data.err_name, err_data.err_msg)); core::comm::send(kill_ch, Some(err_data)); @@ -1560,9 +1560,9 @@ mod test { // err check on listen_result if result::is_err(&listen_result) { match result::get_err(&listen_result) { - GenericListenErr(name, msg) => { + GenericListenErr(ref name, ref msg) => { fail fmt!("SERVER: exited abnormally name %s msg %s", - name, msg); + *name, *msg); } AccessDenied => { fail ~"SERVER: exited abnormally, got access denied.."; diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 33e657c390b..00226c4e81e 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -1,6 +1,5 @@ //! Types/fns concerning URLs (see RFC 3986) #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::Eq; use map::HashMap; @@ -661,7 +660,7 @@ fn from_str(rawurl: &str) -> result::Result { impl Url : FromStr { static fn from_str(s: &str) -> Option { match from_str(s) { - Ok(url) => Some(url), + Ok(move url) => Some(url), Err(_) => None } } diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index fa4c41dfa13..bc528800666 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use io::Writer; use io::WriterUtil; diff --git a/src/libstd/prettyprint2.rs b/src/libstd/prettyprint2.rs index c0e76662bcb..325d240eb57 100644 --- a/src/libstd/prettyprint2.rs +++ b/src/libstd/prettyprint2.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use io::Writer; use io::WriterUtil; diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 4680448e275..1d88b89277d 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -24,7 +24,6 @@ */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /// The type of ropes. type Rope = node::Root; @@ -738,14 +737,14 @@ mod node { //FIXME (#2744): Could we do this without the pattern-matching? match (*node) { Leaf(y) => return y.byte_len, - Concat(y) => return y.byte_len + Concat(ref y) => return y.byte_len } } pure fn char_len(node: @Node) -> uint { match (*node) { Leaf(y) => return y.char_len, - Concat(y) => return y.char_len + Concat(ref y) => return y.char_len } } @@ -835,7 +834,7 @@ mod node { fn flatten(node: @Node) -> @Node unsafe { match (*node) { Leaf(_) => return node, - Concat(x) => { + Concat(ref x) => { return @Leaf({ byte_offset: 0u, byte_len: x.byte_len, @@ -913,7 +912,7 @@ mod node { char_len: char_len, content: x.content}); } - node::Concat(x) => { + node::Concat(ref x) => { let left_len: uint = node::byte_len(x.left); if byte_offset <= left_len { if byte_offset + byte_len <= left_len { @@ -976,7 +975,7 @@ mod node { char_len: char_len, content: x.content}); } - node::Concat(x) => { + node::Concat(ref x) => { if char_offset == 0u && char_len == x.char_len {return node;} let left_len : uint = node::char_len(x.left); if char_offset <= left_len { @@ -1015,7 +1014,7 @@ mod node { fn height(node: @Node) -> uint { match (*node) { Leaf(_) => return 0u, - Concat(x) => return x.height + Concat(ref x) => return x.height } } @@ -1067,7 +1066,7 @@ mod node { loop { match (*current) { Leaf(x) => return it(x), - Concat(x) => if loop_leaves(x.left, it) { //non tail call + Concat(ref x) => if loop_leaves(x.left, it) { //non tail call current = x.right; //tail call } else { return false; @@ -1134,7 +1133,7 @@ mod node { let current = it.stack[it.stackpos]; it.stackpos -= 1; match (*current) { - Concat(x) => { + Concat(ref x) => { it.stackpos += 1; it.stack[it.stackpos] = x.right; it.stackpos += 1; diff --git a/src/libstd/serialization.rs b/src/libstd/serialization.rs index af581ba4958..a385924e846 100644 --- a/src/libstd/serialization.rs +++ b/src/libstd/serialization.rs @@ -245,9 +245,9 @@ fn serialize_Option(s: S, v: Option, st: fn(T)) { None => do s.emit_enum_variant(~"none", 0u, 0u) { }, - Some(v) => do s.emit_enum_variant(~"some", 1u, 1u) { + Some(ref v) => do s.emit_enum_variant(~"some", 1u, 1u) { do s.emit_enum_variant_arg(0u) { - st(v) + st(*v) } } } diff --git a/src/libstd/serialization2.rs b/src/libstd/serialization2.rs index 81941627ef6..09954affc21 100644 --- a/src/libstd/serialization2.rs +++ b/src/libstd/serialization2.rs @@ -5,7 +5,6 @@ Core serialization interfaces. */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; #[forbid(non_camel_case_types)]; pub trait Serializer { @@ -235,7 +234,7 @@ pub impl Option: Serializable { None => do s.emit_enum_variant(~"none", 0u, 0u) { }, - Some(v) => do s.emit_enum_variant(~"some", 1u, 1u) { + Some(ref v) => do s.emit_enum_variant(~"some", 1u, 1u) { s.emit_enum_variant_arg(0u, || v.serialize(s)) } } @@ -261,7 +260,7 @@ pub impl< > (T0, T1): Serializable { fn serialize(&self, s: &S) { match *self { - (t0, t1) => { + (ref t0, ref t1) => { do s.emit_tup(2) { s.emit_tup_elt(0, || t0.serialize(s)); s.emit_tup_elt(1, || t1.serialize(s)); @@ -287,7 +286,7 @@ pub impl< > (T0, T1, T2): Serializable { fn serialize(&self, s: &S) { match *self { - (t0, t1, t2) => { + (ref t0, ref t1, ref t2) => { do s.emit_tup(3) { s.emit_tup_elt(0, || t0.serialize(s)); s.emit_tup_elt(1, || t1.serialize(s)); @@ -316,7 +315,7 @@ pub impl< > (T0, T1, T2, T3): Serializable { fn serialize(&self, s: &S) { match *self { - (t0, t1, t2, t3) => { + (ref t0, ref t1, ref t2, ref t3) => { do s.emit_tup(4) { s.emit_tup_elt(0, || t0.serialize(s)); s.emit_tup_elt(1, || t1.serialize(s)); @@ -348,7 +347,7 @@ pub impl< > (T0, T1, T2, T3, T4): Serializable { fn serialize(&self, s: &S) { match *self { - (t0, t1, t2, t3, t4) => { + (ref t0, ref t1, ref t2, ref t3, ref t4) => { do s.emit_tup(5) { s.emit_tup_elt(0, || t0.serialize(s)); s.emit_tup_elt(1, || t1.serialize(s)); diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 178bf2be7fe..05890035273 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -13,7 +13,6 @@ */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /* * A SHA-1 implementation derived from Paul E. Jones's reference diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 5fc8ead59fd..e3927ef188c 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -3,7 +3,6 @@ * are O(highest integer key). */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::option; use core::option::{Some, None}; @@ -56,7 +55,7 @@ pure fn get(self: SmallIntMap, key: uint) -> T { error!("smallintmap::get(): key not present"); fail; } - Some(v) => return v + Some(move v) => return v } } @@ -117,7 +116,7 @@ impl SmallIntMap: map::Map { let mut idx = 0u, l = self.v.len(); while idx < l { match self.v.get_elt(idx) { - Some(elt) => if !it(&idx, &elt) { break }, + Some(ref elt) => if !it(&idx, elt) { break }, None => () } idx += 1u; diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 20a18b88320..f783addcf50 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -1,6 +1,5 @@ //! Sorting methods #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use vec::{len, push}; use core::cmp::{Eq, Ord}; diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 96d7b8c20fc..5370f20cfa1 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -23,6 +23,7 @@ not required in or otherwise suitable for the core library. #[allow(vecs_implicitly_copyable)]; #[deny(non_camel_case_types)]; +#[forbid(deprecated_pattern)]; extern mod core(vers = "0.4"); use core::*; diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 7638b43ad86..c94a1ab46bf 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -1,6 +1,5 @@ // NB: transitionary, de-mode-ing. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /** * The concurrency primitives you know and love. * diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index 5c59bc02cb7..84c04aa1bd7 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -1,7 +1,6 @@ //! Temporary files and directories #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::option; use option::{None, Some}; diff --git a/src/libstd/term.rs b/src/libstd/term.rs index af7fde5a174..2c12fd11e6e 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -1,6 +1,5 @@ //! Simple ANSI color library #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::Option; @@ -38,9 +37,9 @@ pub fn color_supported() -> bool { let supported_terms = ~[~"xterm-color", ~"xterm", ~"screen-bce", ~"xterm-256color"]; return match os::getenv(~"TERM") { - option::Some(env) => { + option::Some(ref env) => { for vec::each(supported_terms) |term| { - if *term == env { return true; } + if *term == *env { return true; } } false } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 50366768e96..cb69c60a1c2 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -6,7 +6,6 @@ // while providing a base that other test frameworks may build off of. #[warn(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::Eq; use either::Either; @@ -59,8 +58,8 @@ type TestDesc = { fn test_main(args: &[~str], tests: &[TestDesc]) { let opts = match parse_opts(args) { - either::Left(o) => o, - either::Right(m) => fail m + either::Left(move o) => o, + either::Right(move m) => fail m }; if !run_tests_console(&opts, tests) { fail ~"Some tests failed"; } } @@ -76,8 +75,8 @@ fn parse_opts(args: &[~str]) -> OptRes { let opts = ~[getopts::optflag(~"ignored"), getopts::optopt(~"logfile")]; let matches = match getopts::getopts(args_, opts) { - Ok(m) => m, - Err(f) => return either::Right(getopts::fail_str(f)) + Ok(move m) => m, + Err(move f) => return either::Right(getopts::fail_str(f)) }; let filter = @@ -120,13 +119,13 @@ fn run_tests_console(opts: &TestOpts, fn callback(event: &TestEvent, st: ConsoleTestState) { debug!("callback(event=%?)", event); match *event { - TeFiltered(filtered_tests) => { - st.total = vec::len(filtered_tests); + TeFiltered(ref filtered_tests) => { + st.total = filtered_tests.len(); let noun = if st.total != 1u { ~"tests" } else { ~"test" }; st.out.write_line(fmt!("\nrunning %u %s", st.total, noun)); } - TeWait(test) => st.out.write_str(fmt!("test %s ... ", test.name)), - TeResult(test, result) => { + TeWait(ref test) => st.out.write_str(fmt!("test %s ... ", test.name)), + TeResult(copy test, result) => { match st.log_out { Some(f) => write_log(f, result, &test), None => () @@ -141,7 +140,7 @@ fn run_tests_console(opts: &TestOpts, st.failed += 1u; write_failed(st.out, st.use_color); st.out.write_line(~""); - st.failures.push(copy test); + st.failures.push(test); } TrIgnored => { st.ignored += 1u; @@ -154,11 +153,11 @@ fn run_tests_console(opts: &TestOpts, } let log_out = match opts.logfile { - Some(path) => match io::file_writer(&Path(path), + Some(ref path) => match io::file_writer(&Path(*path), ~[io::Create, io::Truncate]) { result::Ok(w) => Some(w), - result::Err(s) => { - fail(fmt!("can't open output file: %s", s)) + result::Err(ref s) => { + fail(fmt!("can't open output file: %s", *s)) } }, None => None @@ -347,7 +346,7 @@ fn filter_tests(opts: &TestOpts, } else { let filter_str = match opts.filter { - option::Some(f) => f, + option::Some(copy f) => f, option::None => ~"" }; diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 890a7a0b468..2975d27e064 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::Eq; use libc::{c_char, c_int, c_long, size_t, time_t}; @@ -576,7 +575,7 @@ fn strptime(s: &str, format: &str) -> Result { match rdr.read_char() { '%' => match parse_type(s, pos, rdr.read_char(), &tm) { Ok(next) => pos = next, - Err(e) => { result = Err(e); break; } + Err(copy e) => { result = Err(e); break; } }, c => { if c != ch { break } diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 1476d6bdf31..ae79892b873 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -1,7 +1,6 @@ //! Utilities that leverage libuv's `uv_timer_*` API #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use uv = uv; use uv::iotask; diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 3419f1cb90c..184dfd36279 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -6,7 +6,6 @@ * red-black tree or something else. */ #[warn(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::{Eq, Ord}; use core::option::{Some, None}; diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index e76b8529730..d353be2b44b 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; mod icu { #[legacy_exports]; diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index cde88db031e..508426588d0 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -1,7 +1,6 @@ //! A process-wide libuv event loop for library use. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; export get; diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 2e008830558..c31238ecf4f 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -6,7 +6,6 @@ */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; export IoTask; export spawn_iotask; @@ -149,7 +148,7 @@ extern fn wake_up_cb(async_handle: *ll::uv_async_t, while msg_po.peek() { match msg_po.recv() { - Interaction(cb) => cb(loop_ptr), + Interaction(ref cb) => (*cb)(loop_ptr), TeardownLoop => begin_teardown(data) } } -- cgit 1.4.1-3-g733a5 From 201513e8590bfc627546054f5ce317add7eef1e6 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 2 Oct 2012 12:02:59 -0700 Subject: De-export std::{fun_treemap, list, map}. Part of #3583. --- src/libstd/fun_treemap.rs | 16 +++++----------- src/libstd/list.rs | 26 +++++++++++++------------- src/libstd/map.rs | 32 ++++++++++++-------------------- src/libstd/std.rc | 3 --- 4 files changed, 30 insertions(+), 47 deletions(-) (limited to 'src/libstd/map.rs') diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index 6388e8983d2..2973c8cc9f7 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -15,13 +15,7 @@ use core::cmp::{Eq, Ord}; use option::{Some, None}; use option = option; -export Treemap; -export init; -export insert; -export find; -export traverse; - -type Treemap = @TreeNode; +pub type Treemap = @TreeNode; enum TreeNode { Empty, @@ -29,10 +23,10 @@ enum TreeNode { } /// Create a treemap -fn init() -> Treemap { @Empty } +pub fn init() -> Treemap { @Empty } /// Insert a value into the map -fn insert(m: Treemap, +k: K, +v: V) +pub fn insert(m: Treemap, +k: K, +v: V) -> Treemap { @match m { @Empty => Node(@k, @v, @Empty, @Empty), @@ -47,7 +41,7 @@ fn insert(m: Treemap, +k: K, +v: V) } /// Find a value based on the key -fn find(m: Treemap, +k: K) -> Option { +pub fn find(m: Treemap, +k: K) -> Option { match *m { Empty => None, Node(@ref kk, @copy v, left, right) => { @@ -59,7 +53,7 @@ fn find(m: Treemap, +k: K) -> Option { } /// Visit all pairs in the map in order. -fn traverse(m: Treemap, f: fn((&K), (&V))) { +pub fn traverse(m: Treemap, f: fn((&K), (&V))) { match *m { Empty => (), /* diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 2a7019f5a58..5b0931ebdee 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -6,13 +6,13 @@ use core::option; use option::*; use option::{Some, None}; -enum List { +pub enum List { Cons(T, @List), Nil, } /// Cregate a list from a vector -fn from_vec(v: &[T]) -> @List { +pub fn from_vec(v: &[T]) -> @List { vec::foldr(v, @Nil::, |h, t| @Cons(*h, t)) } @@ -29,7 +29,7 @@ fn from_vec(v: &[T]) -> @List { * * z - The initial value * * f - The function to apply */ -fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { +pub fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { let mut accum: T = z; do iter(ls) |elt| { accum = f(&accum, elt);} accum @@ -42,7 +42,7 @@ fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -fn find(ls: @List, f: fn((&T)) -> bool) -> Option { +pub fn find(ls: @List, f: fn((&T)) -> bool) -> Option { let mut ls = ls; loop { ls = match *ls { @@ -56,7 +56,7 @@ fn find(ls: @List, f: fn((&T)) -> bool) -> Option { } /// Returns true if a list contains an element with the given value -fn has(ls: @List, +elt: T) -> bool { +pub fn has(ls: @List, +elt: T) -> bool { for each(ls) |e| { if *e == elt { return true; } } @@ -64,7 +64,7 @@ fn has(ls: @List, +elt: T) -> bool { } /// Returns true if the list is empty -pure fn is_empty(ls: @List) -> bool { +pub pure fn is_empty(ls: @List) -> bool { match *ls { Nil => true, _ => false @@ -72,19 +72,19 @@ pure fn is_empty(ls: @List) -> bool { } /// Returns true if the list is not empty -pure fn is_not_empty(ls: @List) -> bool { +pub pure fn is_not_empty(ls: @List) -> bool { return !is_empty(ls); } /// Returns the length of a list -fn len(ls: @List) -> uint { +pub fn len(ls: @List) -> uint { let mut count = 0u; iter(ls, |_e| count += 1u); count } /// Returns all but the first element of a list -pure fn tail(ls: @List) -> @List { +pub pure fn tail(ls: @List) -> @List { match *ls { Cons(_, tl) => return tl, Nil => fail ~"list empty" @@ -92,7 +92,7 @@ pure fn tail(ls: @List) -> @List { } /// Returns the first element of a list -pure fn head(ls: @List) -> T { +pub pure fn head(ls: @List) -> T { match *ls { Cons(copy hd, _) => hd, // makes me sad @@ -101,7 +101,7 @@ pure fn head(ls: @List) -> T { } /// Appends one list to another -pure fn append(l: @List, m: @List) -> @List { +pub pure fn append(l: @List, m: @List) -> @List { match *l { Nil => return m, Cons(copy x, xs) => { @@ -120,7 +120,7 @@ pure fn push(ll: &mut @list, +vv: T) { */ /// Iterate over a list -fn iter(l: @List, f: fn((&T))) { +pub fn iter(l: @List, f: fn((&T))) { let mut cur = l; loop { cur = match *cur { @@ -134,7 +134,7 @@ fn iter(l: @List, f: fn((&T))) { } /// Iterate over a list -fn each(l: @List, f: fn((&T)) -> bool) { +pub fn each(l: @List, f: fn((&T)) -> bool) { let mut cur = l; loop { cur = match *cur { diff --git a/src/libstd/map.rs b/src/libstd/map.rs index fce75cbda75..84fee092562 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -11,16 +11,12 @@ use core::cmp::Eq; use hash::Hash; use to_bytes::IterBytes; -export HashMap, hashfn, eqfn, Set, Map, chained, set_add; -export hash_from_vec; -export vec_from_set; - /// A convenience type to treat a hashmap as a set -type Set = HashMap; +pub type Set = HashMap; -type HashMap = chained::T; +pub type HashMap = chained::T; -trait Map { +pub trait Map { /// Return the number of elements in the map pure fn size() -> uint; @@ -82,10 +78,9 @@ trait Map { } mod util { - #[legacy_exports]; - type Rational = {num: int, den: int}; // : int::positive(*.den); + pub type Rational = {num: int, den: int}; // : int::positive(*.den); - pure fn rational_leq(x: Rational, y: Rational) -> bool { + pub pure fn rational_leq(x: Rational, y: Rational) -> bool { // NB: Uses the fact that rationals have positive denominators WLOG: x.num * y.den <= y.num * x.den @@ -95,9 +90,7 @@ mod util { // FIXME (#2344): package this up and export it as a datatype usable for // external code that doesn't want to pay the cost of a box. -mod chained { - #[legacy_exports]; - export T, mk, HashMap; +pub mod chained { const initial_capacity: uint = 32u; // 2^5 @@ -113,7 +106,7 @@ mod chained { mut chains: ~[mut Option<@Entry>] } - type T = @HashMap_; + pub type T = @HashMap_; enum SearchResult { NotFound, @@ -366,7 +359,7 @@ mod chained { vec::to_mut(vec::from_elem(nchains, None)) } - fn mk() -> T { + pub fn mk() -> T { let slf: T = @HashMap_ {count: 0u, chains: chains(initial_capacity)}; slf @@ -378,18 +371,18 @@ Function: hashmap Construct a hashmap. */ -fn HashMap() +pub fn HashMap() -> HashMap { chained::mk() } /// Convenience function for adding keys to a hashmap with nil type keys -fn set_add(set: Set, +key: K) -> bool { +pub fn set_add(set: Set, +key: K) -> bool { set.insert(key, ()) } /// Convert a set into a vector. -fn vec_from_set(s: Set) -> ~[T] { +pub fn vec_from_set(s: Set) -> ~[T] { do vec::build_sized(s.size()) |push| { for s.each_key() |k| { push(k); @@ -398,7 +391,7 @@ fn vec_from_set(s: Set) -> ~[T] { } /// Construct a hashmap from a vector -fn hash_from_vec( +pub fn hash_from_vec( items: &[(K, V)]) -> HashMap { let map = HashMap(); for vec::each(items) |item| { @@ -517,7 +510,6 @@ impl @Mut>: #[cfg(test)] mod tests { - #[legacy_exports]; #[test] fn test_simple() { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 4d5eefec053..4831ac993a2 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -77,11 +77,8 @@ mod comm; mod bitv; mod deque; -#[legacy_exports] mod fun_treemap; -#[legacy_exports] mod list; -#[legacy_exports] mod map; mod rope; mod smallintmap; -- cgit 1.4.1-3-g733a5 From f33539e446d6f41d4a3296ed50a8f968e7950483 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 3 Oct 2012 12:21:48 -0700 Subject: Remove uses of + mode from libstd More or less the same as my analogous commit for libcore. Had to remove the forbid(deprecated_modes) pragma from some files -- will restore it after the snapshot. --- src/libstd/arc.rs | 22 +++++++++--------- src/libstd/bitv.rs | 4 ++-- src/libstd/cell.rs | 6 ++--- src/libstd/dbg.rs | 8 +++---- src/libstd/deque.rs | 14 ++++++------ src/libstd/getopts.rs | 25 ++++++++++---------- src/libstd/json.rs | 4 ++-- src/libstd/list.rs | 2 +- src/libstd/map.rs | 52 +++++++++++++++++++++--------------------- src/libstd/net_tcp.rs | 14 ++++++------ src/libstd/net_url.rs | 12 +++++----- src/libstd/rope.rs | 4 ++-- src/libstd/smallintmap.rs | 20 ++++++++-------- src/libstd/std.rc | 3 --- src/libstd/sync.rs | 14 ++++++------ src/libstd/test.rs | 4 ++-- src/libstd/time.rs | 4 ++-- src/libstd/timer.rs | 4 ++-- src/libstd/uv_iotask.rs | 4 ++-- src/libstd/uv_ll.rs | 6 ++--- src/test/bench/graph500-bfs.rs | 2 +- 21 files changed, 113 insertions(+), 115 deletions(-) (limited to 'src/libstd/map.rs') diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 9d15deab660..60db62ce01a 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap /** * Concurrency-enabled mechanisms for sharing mutable and/or immutable state * between tasks. @@ -66,7 +66,7 @@ impl &Condvar { struct ARC { x: SharedMutableState } /// Create an atomically reference counted wrapper. -pub fn ARC(+data: T) -> ARC { +pub fn ARC(data: T) -> ARC { ARC { x: unsafe { shared_mutable_state(move data) } } } @@ -98,7 +98,7 @@ pub fn clone(rc: &ARC) -> ARC { * unwrap from a task that holds another reference to the same ARC; it is * guaranteed to deadlock. */ -fn unwrap(+rc: ARC) -> T { +fn unwrap(rc: ARC) -> T { let ARC { x: x } <- rc; unsafe { unwrap_shared_mutable_state(move x) } } @@ -113,14 +113,14 @@ struct MutexARCInner { lock: Mutex, failed: bool, data: T } struct MutexARC { x: SharedMutableState> } /// Create a mutex-protected ARC with the supplied data. -pub fn MutexARC(+user_data: T) -> MutexARC { +pub fn MutexARC(user_data: T) -> MutexARC { mutex_arc_with_condvars(move user_data, 1) } /** * Create a mutex-protected ARC with the supplied data and a specified number * of condvars (as sync::mutex_with_condvars). */ -pub fn mutex_arc_with_condvars(+user_data: T, +pub fn mutex_arc_with_condvars(user_data: T, num_condvars: uint) -> MutexARC { let data = MutexARCInner { lock: mutex_with_condvars(num_condvars), @@ -191,7 +191,7 @@ impl &MutexARC { * Will additionally fail if another task has failed while accessing the arc. */ // FIXME(#2585) make this a by-move method on the arc -pub fn unwrap_mutex_arc(+arc: MutexARC) -> T { +pub fn unwrap_mutex_arc(arc: MutexARC) -> T { let MutexARC { x: x } <- arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let MutexARCInner { failed: failed, data: data, _ } <- inner; @@ -247,14 +247,14 @@ struct RWARC { } /// Create a reader/writer ARC with the supplied data. -pub fn RWARC(+user_data: T) -> RWARC { +pub fn RWARC(user_data: T) -> RWARC { rw_arc_with_condvars(move user_data, 1) } /** * Create a reader/writer ARC with the supplied data and a specified number * of condvars (as sync::rwlock_with_condvars). */ -pub fn rw_arc_with_condvars(+user_data: T, +pub fn rw_arc_with_condvars(user_data: T, num_condvars: uint) -> RWARC { let data = RWARCInner { lock: rwlock_with_condvars(num_condvars), @@ -334,7 +334,7 @@ impl &RWARC { * } * ~~~ */ - fn write_downgrade(blk: fn(+v: RWWriteMode) -> U) -> U { + fn write_downgrade(blk: fn(v: RWWriteMode) -> U) -> U { let state = unsafe { get_shared_mutable_state(&self.x) }; do borrow_rwlock(state).write_downgrade |write_mode| { check_poison(false, state.failed); @@ -344,7 +344,7 @@ impl &RWARC { } /// To be called inside of the write_downgrade block. - fn downgrade(+token: RWWriteMode/&a) -> RWReadMode/&a { + fn downgrade(token: RWWriteMode/&a) -> RWReadMode/&a { // The rwlock should assert that the token belongs to us for us. let state = unsafe { get_shared_immutable_state(&self.x) }; let RWWriteMode((data, t, _poison)) <- token; @@ -369,7 +369,7 @@ impl &RWARC { * in write mode. */ // FIXME(#2585) make this a by-move method on the arc -pub fn unwrap_rw_arc(+arc: RWARC) -> T { +pub fn unwrap_rw_arc(arc: RWARC) -> T { let RWARC { x: x, _ } <- arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let RWARCInner { failed: failed, data: data, _ } <- inner; diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index bb556ed2ca3..77f0d39c338 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -1,4 +1,4 @@ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use vec::{to_mut, from_elem}; @@ -95,7 +95,7 @@ struct BigBitv { mut storage: ~[mut uint] } -fn BigBitv(+storage: ~[mut uint]) -> BigBitv { +fn BigBitv(storage: ~[mut uint]) -> BigBitv { BigBitv {storage: storage} } diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 43e47e1e1a9..866dbce1c08 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -1,4 +1,4 @@ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap /// A dynamic, mutable location. /// /// Similar to a mutable option type, but friendlier. @@ -8,7 +8,7 @@ pub struct Cell { } /// Creates a new full cell with the given value. -pub fn Cell(+value: T) -> Cell { +pub fn Cell(value: T) -> Cell { Cell { value: Some(move value) } } @@ -29,7 +29,7 @@ impl Cell { } /// Returns the value, failing if the cell is full. - fn put_back(+value: T) { + fn put_back(value: T) { if !self.is_empty() { fail ~"attempt to put a value back into a full cell"; } diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index df97df51643..f85d4655ad1 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -1,4 +1,4 @@ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap //! Unsafe debugging functions for inspecting values. use cast::reinterpret_cast; @@ -20,7 +20,7 @@ pub fn debug_tydesc() { rustrt::debug_tydesc(sys::get_type_desc::()); } -pub fn debug_opaque(+x: T) { +pub fn debug_opaque(x: T) { rustrt::debug_opaque(sys::get_type_desc::(), ptr::addr_of(&x) as *()); } @@ -28,11 +28,11 @@ pub fn debug_box(x: @T) { rustrt::debug_box(sys::get_type_desc::(), ptr::addr_of(&x) as *()); } -pub fn debug_tag(+x: T) { +pub fn debug_tag(x: T) { rustrt::debug_tag(sys::get_type_desc::(), ptr::addr_of(&x) as *()); } -pub fn debug_fn(+x: T) { +pub fn debug_fn(x: T) { rustrt::debug_fn(sys::get_type_desc::(), ptr::addr_of(&x) as *()); } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index da05174a6f5..f4fbc11c4f7 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -1,5 +1,5 @@ //! A deque. Untested as of yet. Likely buggy -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap #[forbid(non_camel_case_types)]; use option::{Some, None}; @@ -8,8 +8,8 @@ use core::cmp::{Eq}; pub trait Deque { fn size() -> uint; - fn add_front(+v: T); - fn add_back(+v: T); + fn add_front(v: T); + fn add_back(v: T); fn pop_front() -> T; fn pop_back() -> T; fn peek_front() -> T; @@ -27,7 +27,7 @@ pub fn create() -> Deque { * Grow is only called on full elts, so nelts is also len(elts), unlike * elsewhere. */ - fn grow(nelts: uint, lo: uint, +elts: ~[Cell]) + fn grow(nelts: uint, lo: uint, elts: ~[Cell]) -> ~[Cell] { let mut elts = move elts; assert (nelts == vec::len(elts)); @@ -55,7 +55,7 @@ pub fn create() -> Deque { impl Repr: Deque { fn size() -> uint { return self.nelts; } - fn add_front(+t: T) { + fn add_front(t: T) { let oldlo: uint = self.lo; if self.lo == 0u { self.lo = self.elts.len() - 1u; @@ -68,7 +68,7 @@ pub fn create() -> Deque { self.elts.set_elt(self.lo, Some(t)); self.nelts += 1u; } - fn add_back(+t: T) { + fn add_back(t: T) { if self.lo == self.hi && self.nelts != 0u { self.elts.swap(|v| grow(self.nelts, self.lo, move v)); self.lo = 0u; @@ -200,7 +200,7 @@ mod tests { assert (deq.get(3) == d); } - fn test_parameterized(+a: T, +b: T, +c: T, +d: T) { + fn test_parameterized(a: T, +b: T, +c: T, +d: T) { let deq: deque::Deque = deque::create::(); assert (deq.size() == 0u); deq.add_front(a); diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 9d127f5db47..8fd775c4773 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -62,7 +62,7 @@ * } */ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use core::cmp::Eq; use core::result::{Err, Ok}; @@ -179,7 +179,7 @@ pub enum Fail_ { } /// Convert a `fail_` enum into an error string -pub fn fail_str(+f: Fail_) -> ~str { +pub fn fail_str(f: Fail_) -> ~str { return match f { ArgumentMissing(ref nm) => { ~"Argument to option '" + *nm + ~"' missing." @@ -335,7 +335,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe { free: free}); } -fn opt_vals(+mm: Matches, nm: &str) -> ~[Optval] { +fn opt_vals(mm: Matches, nm: &str) -> ~[Optval] { return match find_opt(mm.opts, mkname(nm)) { Some(id) => mm.vals[id], None => { @@ -345,15 +345,15 @@ fn opt_vals(+mm: Matches, nm: &str) -> ~[Optval] { }; } -fn opt_val(+mm: Matches, nm: &str) -> Optval { return opt_vals(mm, nm)[0]; } +fn opt_val(mm: Matches, nm: &str) -> Optval { return opt_vals(mm, nm)[0]; } /// Returns true if an option was matched -pub fn opt_present(+mm: Matches, nm: &str) -> bool { +pub fn opt_present(mm: Matches, nm: &str) -> bool { return vec::len::(opt_vals(mm, nm)) > 0u; } /// Returns true if any of several options were matched -pub fn opts_present(+mm: Matches, names: &[~str]) -> bool { +pub fn opts_present(mm: Matches, names: &[~str]) -> bool { for vec::each(names) |nm| { match find_opt(mm.opts, mkname(*nm)) { Some(_) => return true, @@ -370,7 +370,7 @@ pub fn opts_present(+mm: Matches, names: &[~str]) -> bool { * Fails if the option was not matched or if the match did not take an * argument */ -pub fn opt_str(+mm: Matches, nm: &str) -> ~str { +pub fn opt_str(mm: Matches, nm: &str) -> ~str { return match opt_val(mm, nm) { Val(copy s) => s, _ => fail }; } @@ -380,7 +380,8 @@ pub fn opt_str(+mm: Matches, nm: &str) -> ~str { * Fails if the no option was provided from the given list, or if the no such * option took an argument */ -pub fn opts_str(+mm: Matches, names: &[~str]) -> ~str { +pub fn opts_str(mm: Matches, names: &[~str]) -> ~str { +>>>>>>> Remove uses of + mode from libstd for vec::each(names) |nm| { match opt_val(mm, *nm) { Val(copy s) => return s, @@ -397,7 +398,7 @@ pub fn opts_str(+mm: Matches, names: &[~str]) -> ~str { * * Used when an option accepts multiple values. */ -pub fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { +pub fn opt_strs(mm: Matches, nm: &str) -> ~[~str] { let mut acc: ~[~str] = ~[]; for vec::each(opt_vals(mm, nm)) |v| { match *v { Val(copy s) => acc.push(s), _ => () } @@ -406,7 +407,7 @@ pub fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { } /// Returns the string argument supplied to a matching option or none -pub fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { +pub fn opt_maybe_str(mm: Matches, nm: &str) -> Option<~str> { let vals = opt_vals(mm, nm); if vec::len::(vals) == 0u { return None::<~str>; } return match vals[0] { @@ -423,7 +424,7 @@ pub fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { * present but no argument was provided, and the argument if the option was * present and an argument was provided. */ -pub fn opt_default(+mm: Matches, nm: &str, def: &str) -> Option<~str> { +pub fn opt_default(mm: Matches, nm: &str, def: &str) -> Option<~str> { let vals = opt_vals(mm, nm); if vec::len::(vals) == 0u { return None::<~str>; } return match vals[0] { Val(copy s) => Some::<~str>(s), @@ -451,7 +452,7 @@ mod tests { use opt = getopts; use result::{Err, Ok}; - fn check_fail_type(+f: Fail_, ft: FailType) { + fn check_fail_type(f: Fail_, ft: FailType) { match f { ArgumentMissing(_) => assert ft == ArgumentMissing_, UnrecognizedOption(_) => assert ft == UnrecognizedOption_, diff --git a/src/libstd/json.rs b/src/libstd/json.rs index d3713bdb29d..f244f2869a6 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -1,6 +1,6 @@ // Rust JSON serialization library // Copyright (c) 2011 Google Inc. -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap #[forbid(non_camel_case_types)]; //! json serialization @@ -370,7 +370,7 @@ priv impl Parser { self.ch } - fn error(+msg: ~str) -> Result { + fn error(msg: ~str) -> Result { Err(Error { line: self.line, col: self.col, msg: @msg }) } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 5b0931ebdee..4ff493f5ab9 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -29,7 +29,7 @@ pub fn from_vec(v: &[T]) -> @List { * * z - The initial value * * f - The function to apply */ -pub fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { +pub fn foldl(z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { let mut accum: T = z; do iter(ls) |elt| { accum = f(&accum, elt);} accum diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 84fee092562..cc42c562376 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -1,6 +1,6 @@ //! A map type -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use io::WriterUtil; use to_str::ToStr; @@ -28,10 +28,10 @@ pub trait Map { * * Returns true if the key did not already exist in the map */ - fn insert(+v: K, +v: V) -> bool; + fn insert(v: K, +v: V) -> bool; /// Returns true if the map contains a value for the specified key - fn contains_key(+key: K) -> bool; + fn contains_key(key: K) -> bool; /// Returns true if the map contains a value for the specified /// key, taking the key by reference. @@ -41,31 +41,31 @@ pub trait Map { * Get the value for the specified key. Fails if the key does not exist in * the map. */ - fn get(+key: K) -> V; + fn get(key: K) -> V; /** * Get the value for the specified key. If the key does not exist in * the map then returns none. */ - pure fn find(+key: K) -> Option; + pure fn find(key: K) -> Option; /** * Remove and return a value from the map. Returns true if the * key was present in the map, otherwise false. */ - fn remove(+key: K) -> bool; + fn remove(key: K) -> bool; /// Clear the map, removing all key/value pairs. fn clear(); /// Iterate over all the key/value pairs in the map by value - pure fn each(fn(+key: K, +value: V) -> bool); + pure fn each(fn(key: K, +value: V) -> bool); /// Iterate over all the keys in the map by value - pure fn each_key(fn(+key: K) -> bool); + pure fn each_key(fn(key: K) -> bool); /// Iterate over all the values in the map by value - pure fn each_value(fn(+value: V) -> bool); + pure fn each_value(fn(value: V) -> bool); /// Iterate over all the key/value pairs in the map by reference pure fn each_ref(fn(key: &K, value: &V) -> bool); @@ -201,7 +201,7 @@ pub mod chained { impl T: Map { pure fn size() -> uint { self.count } - fn contains_key(+k: K) -> bool { + fn contains_key(k: K) -> bool { self.contains_key_ref(&k) } @@ -213,7 +213,7 @@ pub mod chained { } } - fn insert(+k: K, +v: V) -> bool { + fn insert(k: K, +v: V) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(&k, hash) { NotFound => { @@ -255,7 +255,7 @@ pub mod chained { } } - pure fn find(+k: K) -> Option { + pure fn find(k: K) -> Option { unsafe { match self.search_tbl(&k, k.hash_keyed(0,0) as uint) { NotFound => None, @@ -265,7 +265,7 @@ pub mod chained { } } - fn get(+k: K) -> V { + fn get(k: K) -> V { let opt_v = self.find(k); if opt_v.is_none() { fail fmt!("Key not found in table: %?", k); @@ -273,7 +273,7 @@ pub mod chained { option::unwrap(move opt_v) } - fn remove(+k: K) -> bool { + fn remove(k: K) -> bool { match self.search_tbl(&k, k.hash_keyed(0,0) as uint) { NotFound => false, FoundFirst(idx, entry) => { @@ -294,15 +294,15 @@ pub mod chained { self.chains = chains(initial_capacity); } - pure fn each(blk: fn(+key: K, +value: V) -> bool) { + pure fn each(blk: fn(key: K, +value: V) -> bool) { self.each_ref(|k, v| blk(*k, *v)) } - pure fn each_key(blk: fn(+key: K) -> bool) { + pure fn each_key(blk: fn(key: K) -> bool) { self.each_key_ref(|p| blk(*p)) } - pure fn each_value(blk: fn(+value: V) -> bool) { + pure fn each_value(blk: fn(value: V) -> bool) { self.each_value_ref(|p| blk(*p)) } @@ -377,7 +377,7 @@ pub fn HashMap() } /// Convenience function for adding keys to a hashmap with nil type keys -pub fn set_add(set: Set, +key: K) -> bool { +pub fn set_add(set: Set, key: K) -> bool { set.insert(key, ()) } @@ -415,13 +415,13 @@ impl @Mut>: } } - fn insert(+key: K, +value: V) -> bool { + fn insert(key: K, value: V) -> bool { do self.borrow_mut |p| { p.insert(key, value) } } - fn contains_key(+key: K) -> bool { + fn contains_key(key: K) -> bool { do self.borrow_const |p| { p.contains_key(&key) } @@ -433,13 +433,13 @@ impl @Mut>: } } - fn get(+key: K) -> V { + fn get(key: K) -> V { do self.borrow_const |p| { p.get(&key) } } - pure fn find(+key: K) -> Option { + pure fn find(key: K) -> Option { unsafe { do self.borrow_const |p| { p.find(&key) @@ -447,7 +447,7 @@ impl @Mut>: } } - fn remove(+key: K) -> bool { + fn remove(key: K) -> bool { do self.borrow_mut |p| { p.remove(&key) } @@ -459,7 +459,7 @@ impl @Mut>: } } - pure fn each(op: fn(+key: K, +value: V) -> bool) { + pure fn each(op: fn(key: K, +value: V) -> bool) { unsafe { do self.borrow_imm |p| { p.each(|k, v| op(*k, *v)) @@ -467,7 +467,7 @@ impl @Mut>: } } - pure fn each_key(op: fn(+key: K) -> bool) { + pure fn each_key(op: fn(key: K) -> bool) { unsafe { do self.borrow_imm |p| { p.each_key(|k| op(*k)) @@ -475,7 +475,7 @@ impl @Mut>: } } - pure fn each_value(op: fn(+value: V) -> bool) { + pure fn each_value(op: fn(value: V) -> bool) { unsafe { do self.borrow_imm |p| { p.each_value(|v| op(*v)) diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 59cb0d36f77..be38f16aff7 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -129,7 +129,7 @@ enum TcpConnectErrData { * the remote host. In the event of failure, a * `net::tcp::tcp_connect_err_data` instance will be returned */ -fn connect(+input_ip: ip::IpAddr, port: uint, +fn connect(input_ip: ip::IpAddr, port: uint, iotask: IoTask) -> result::Result unsafe { let result_po = core::comm::Port::(); @@ -570,7 +570,7 @@ fn accept(new_conn: TcpNewConnection) * successful/normal shutdown, and a `tcp_listen_err_data` enum in the event * of listen exiting because of an error */ -fn listen(+host_ip: ip::IpAddr, port: uint, backlog: uint, +fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint, iotask: IoTask, +on_establish_cb: fn~(comm::Chan>), +new_connect_cb: fn~(TcpNewConnection, @@ -587,7 +587,7 @@ fn listen(+host_ip: ip::IpAddr, port: uint, backlog: uint, } } -fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint, +fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint, iotask: IoTask, +on_establish_cb: fn~(comm::Chan>), +on_connect_cb: fn~(*uv::ll::uv_tcp_t)) @@ -728,7 +728,7 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint, * * A buffered wrapper that you can cast as an `io::reader` or `io::writer` */ -fn socket_buf(+sock: TcpSocket) -> TcpSocketBuf { +fn socket_buf(sock: TcpSocket) -> TcpSocketBuf { TcpSocketBuf(@{ sock: move sock, mut buf: ~[] }) } @@ -738,7 +738,7 @@ impl TcpSocket { result::Result<~[u8], TcpErrData>>, TcpErrData> { read_start(&self) } - fn read_stop(+read_port: + fn read_stop(read_port: comm::Port>) -> result::Result<(), TcpErrData> { read_stop(&self, move read_port) @@ -1476,7 +1476,7 @@ mod test { */ } - fn buf_write(+w: &W, val: &str) { + fn buf_write(w: &W, val: &str) { log(debug, fmt!("BUF_WRITE: val len %?", str::len(val))); do str::byte_slice(val) |b_slice| { log(debug, fmt!("BUF_WRITE: b_slice len %?", @@ -1485,7 +1485,7 @@ mod test { } } - fn buf_read(+r: &R, len: uint) -> ~str { + fn buf_read(r: &R, len: uint) -> ~str { let new_bytes = (*r).read_bytes(len); log(debug, fmt!("in buf_read.. new_bytes len: %?", vec::len(new_bytes))); diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 920751d690f..6dca075405b 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -1,5 +1,5 @@ //! Types/fns concerning URLs (see RFC 3986) -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after a snapshot use core::cmp::Eq; use map::HashMap; @@ -36,7 +36,7 @@ type UserInfo = { type Query = ~[(~str, ~str)]; -fn Url(+scheme: ~str, +user: Option, +host: ~str, +fn Url(scheme: ~str, +user: Option, +host: ~str, +port: Option<~str>, +path: ~str, +query: Query, +fragment: Option<~str>) -> Url { Url { scheme: move scheme, user: move user, host: move host, @@ -44,7 +44,7 @@ fn Url(+scheme: ~str, +user: Option, +host: ~str, fragment: move fragment } } -fn UserInfo(+user: ~str, +pass: Option<~str>) -> UserInfo { +fn UserInfo(user: ~str, +pass: Option<~str>) -> UserInfo { {user: move user, pass: move pass} } @@ -306,7 +306,7 @@ fn userinfo_from_str(uinfo: &str) -> UserInfo { return UserInfo(user, pass); } -fn userinfo_to_str(+userinfo: UserInfo) -> ~str { +fn userinfo_to_str(userinfo: UserInfo) -> ~str { if option::is_some(&userinfo.pass) { return str::concat(~[copy userinfo.user, ~":", option::unwrap(copy userinfo.pass), @@ -334,7 +334,7 @@ fn query_from_str(rawquery: &str) -> Query { return query; } -fn query_to_str(+query: Query) -> ~str { +fn query_to_str(query: Query) -> ~str { let mut strvec = ~[]; for query.each |kv| { let (k, v) = copy *kv; @@ -681,7 +681,7 @@ impl Url : FromStr { * result in just "http://somehost.com". * */ -fn to_str(+url: Url) -> ~str { +fn to_str(url: Url) -> ~str { let user = if url.user.is_some() { userinfo_to_str(option::unwrap(copy url.user)) } else { diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index d14a4854555..5df4fc10a03 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -379,7 +379,7 @@ Section: Iterating * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -pub fn loop_chars(rope: Rope, it: fn(+c: char) -> bool) -> bool { +pub fn loop_chars(rope: Rope, it: fn(c: char) -> bool) -> bool { match (rope) { node::Empty => return true, node::Content(x) => return node::loop_chars(x, it) @@ -1037,7 +1037,7 @@ mod node { return result; } - pub fn loop_chars(node: @Node, it: fn(+c: char) -> bool) -> bool { + pub fn loop_chars(node: @Node, it: fn(c: char) -> bool) -> bool { return loop_leaves(node,|leaf| { str::all_between(*leaf.content, leaf.byte_offset, diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 2e7f47e0af0..58ecbb0d6c3 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -2,7 +2,7 @@ * A simple map based on a vector for small integer keys. Space requirements * are O(highest integer key). */ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use core::option; use core::option::{Some, None}; @@ -28,7 +28,7 @@ pub fn mk() -> SmallIntMap { * the specified key then the original value is replaced. */ #[inline(always)] -pub fn insert(self: SmallIntMap, key: uint, +val: T) { +pub fn insert(self: SmallIntMap, key: uint, val: T) { //io::println(fmt!("%?", key)); self.v.grow_set_elt(key, &None, Some(val)); } @@ -77,12 +77,12 @@ impl SmallIntMap: map::Map { sz } #[inline(always)] - fn insert(+key: uint, +value: V) -> bool { + fn insert(key: uint, value: V) -> bool { let exists = contains_key(self, key); insert(self, key, value); return !exists; } - fn remove(+key: uint) -> bool { + fn remove(key: uint) -> bool { if key >= self.v.len() { return false; } @@ -93,23 +93,23 @@ impl SmallIntMap: map::Map { fn clear() { self.v.set(~[]); } - fn contains_key(+key: uint) -> bool { + fn contains_key(key: uint) -> bool { contains_key(self, key) } fn contains_key_ref(key: &uint) -> bool { contains_key(self, *key) } - fn get(+key: uint) -> V { get(self, key) } - pure fn find(+key: uint) -> Option { find(self, key) } + fn get(key: uint) -> V { get(self, key) } + pure fn find(key: uint) -> Option { find(self, key) } fn rehash() { fail } - pure fn each(it: fn(+key: uint, +value: V) -> bool) { + pure fn each(it: fn(key: uint, +value: V) -> bool) { self.each_ref(|k, v| it(*k, *v)) } - pure fn each_key(it: fn(+key: uint) -> bool) { + pure fn each_key(it: fn(key: uint) -> bool) { self.each_ref(|k, _v| it(*k)) } - pure fn each_value(it: fn(+value: V) -> bool) { + pure fn each_value(it: fn(value: V) -> bool) { self.each_ref(|_k, v| it(*v)) } pure fn each_ref(it: fn(key: &uint, value: &V) -> bool) { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 202cb4932db..683ea589b91 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -18,9 +18,6 @@ not required in or otherwise suitable for the core library. #[no_core]; -// tjc: Added legacy_modes back in because it still uses + mode. -// Remove once + mode gets expunged from std. -#[legacy_modes]; #[legacy_exports]; #[allow(vecs_implicitly_copyable)]; diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index f66f2f5b5d3..f66134d3892 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap /** * The concurrency primitives you know and love. * @@ -69,7 +69,7 @@ struct SemInner { enum Sem = Exclusive>; #[doc(hidden)] -fn new_sem(count: int, +q: Q) -> Sem { +fn new_sem(count: int, q: Q) -> Sem { Sem(exclusive(SemInner { mut count: count, waiters: new_waitqueue(), blocked: q })) } @@ -535,7 +535,7 @@ impl &RWlock { * } * ~~~ */ - fn write_downgrade(blk: fn(+v: RWlockWriteMode) -> U) -> U { + fn write_downgrade(blk: fn(v: RWlockWriteMode) -> U) -> U { // Implementation slightly different from the slicker 'write's above. // The exit path is conditional on whether the caller downgrades. let mut _release = None; @@ -551,7 +551,7 @@ impl &RWlock { } /// To be called inside of the write_downgrade block. - fn downgrade(+token: RWlockWriteMode/&a) -> RWlockReadMode/&a { + fn downgrade(token: RWlockWriteMode/&a) -> RWlockReadMode/&a { if !ptr::ref_eq(self, token.lock) { fail ~"Can't downgrade() with a different rwlock's write_mode!"; } @@ -957,7 +957,7 @@ mod tests { drop { self.c.send(()); } } - fn SendOnFailure(+c: pipes::Chan<()>) -> SendOnFailure { + fn SendOnFailure(c: pipes::Chan<()>) -> SendOnFailure { SendOnFailure { c: c } @@ -1038,7 +1038,7 @@ mod tests { } } #[cfg(test)] - fn test_rwlock_exclusion(+x: ~RWlock, mode1: RWlockMode, + fn test_rwlock_exclusion(x: ~RWlock, mode1: RWlockMode, mode2: RWlockMode) { // Test mutual exclusion between readers and writers. Just like the // mutex mutual exclusion test, a ways above. @@ -1083,7 +1083,7 @@ mod tests { test_rwlock_exclusion(~RWlock(), Downgrade, Downgrade); } #[cfg(test)] - fn test_rwlock_handshake(+x: ~RWlock, mode1: RWlockMode, + fn test_rwlock_handshake(x: ~RWlock, mode1: RWlockMode, mode2: RWlockMode, make_mode2_go_first: bool) { // Much like sem_multi_resource. let x2 = ~x.clone(); diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 1df10a4d799..c5d9dd343fa 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -270,7 +270,7 @@ enum TestEvent { type MonitorMsg = (TestDesc, TestResult); fn run_tests(opts: &TestOpts, tests: &[TestDesc], - callback: fn@(+e: TestEvent)) { + callback: fn@(e: TestEvent)) { let mut filtered_tests = filter_tests(opts, tests); callback(TeFiltered(copy filtered_tests)); @@ -379,7 +379,7 @@ fn filter_tests(opts: &TestOpts, type TestFuture = {test: TestDesc, wait: fn@() -> TestResult}; -fn run_test(+test: TestDesc, monitor_ch: comm::Chan) { +fn run_test(test: TestDesc, monitor_ch: comm::Chan) { if test.ignore { core::comm::send(monitor_ch, (copy test, TrIgnored)); return; diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 43cbc6da9bd..aef3bb2ac0a 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -1,4 +1,4 @@ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use core::cmp::Eq; use libc::{c_char, c_int, c_long, size_t, time_t}; @@ -589,7 +589,7 @@ pub fn strptime(s: &str, format: &str) -> Result { } } -fn strftime(format: &str, +tm: Tm) -> ~str { +fn strftime(format: &str, tm: Tm) -> ~str { fn parse_type(ch: char, tm: &Tm) -> ~str { //FIXME (#2350): Implement missing types. let die = || #fmt("strftime: can't understand this format %c ", diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 8aaf7d3fd87..2aca87b942e 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -1,6 +1,6 @@ //! Utilities that leverage libuv's `uv_timer_*` API -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use uv = uv; use uv::iotask; @@ -24,7 +24,7 @@ use comm = core::comm; * * val - a value of type T to send over the provided `ch` */ pub fn delayed_send(iotask: IoTask, - msecs: uint, ch: comm::Chan, +val: T) { + msecs: uint, ch: comm::Chan, val: T) { unsafe { let timer_done_po = core::comm::Port::<()>(); let timer_done_ch = core::comm::Chan(timer_done_po); diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 876aa6f4af0..4a4a34704be 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -5,7 +5,7 @@ * `interact` function you can execute code in a uv callback. */ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after a snapshot use libc::c_void; use ptr::p2::addr_of; @@ -22,7 +22,7 @@ pub enum IoTask { }) } -pub fn spawn_iotask(+task: task::TaskBuilder) -> IoTask { +pub fn spawn_iotask(task: task::TaskBuilder) -> IoTask { do listen |iotask_ch| { diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index f0594475d04..50636054821 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -642,7 +642,7 @@ extern mod rustrt { fn rust_uv_addrinfo_as_sockaddr_in(input: *addrinfo) -> *sockaddr_in; fn rust_uv_addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6; fn rust_uv_malloc_buf_base_of(sug_size: libc::size_t) -> *u8; - fn rust_uv_free_base_of_buf(++buf: uv_buf_t); + fn rust_uv_free_base_of_buf(+buf: uv_buf_t); fn rust_uv_get_stream_handle_from_connect_req( connect_req: *uv_connect_t) -> *uv_stream_t; @@ -661,8 +661,8 @@ extern mod rustrt { fn rust_uv_get_data_for_req(req: *libc::c_void) -> *libc::c_void; fn rust_uv_set_data_for_req(req: *libc::c_void, data: *libc::c_void); - fn rust_uv_get_base_from_buf(++buf: uv_buf_t) -> *u8; - fn rust_uv_get_len_from_buf(++buf: uv_buf_t) -> libc::size_t; + fn rust_uv_get_base_from_buf(+buf: uv_buf_t) -> *u8; + fn rust_uv_get_len_from_buf(+buf: uv_buf_t) -> libc::size_t; // sizeof testing helpers fn rust_uv_helper_uv_tcp_t_size() -> libc::c_uint; diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index f35a3ce735f..a34fcc89c04 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -251,7 +251,7 @@ fn pbfs(&&graph: arc::ARC, key: node_id) -> bfs_result { colors = do par::mapi_factory(*color_vec) { let colors = arc::clone(&color); let graph = arc::clone(&graph); - fn~(i: uint, c: color) -> color { + fn~(+i: uint, +c: color) -> color { let c : color = c; let colors = arc::get(&colors); let graph = arc::get(&graph); -- cgit 1.4.1-3-g733a5