std: Eliminate deprecated patterns

This commit is contained in:
Brian Anderson 2012-09-28 00:22:18 -07:00
parent 467f2abdd8
commit bc9efaad9c
37 changed files with 130 additions and 165 deletions

View File

@ -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.

View File

@ -23,7 +23,6 @@
// to waste time running the destructors of POD.
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
export Arena, arena_with_size;

View File

@ -1,5 +1,4 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use io::Reader;
pub trait ToBase64 {

View File

@ -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

View File

@ -1,5 +1,4 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
/// A dynamic, mutable location.
///
/// Similar to a mutable option type, but friendlier.

View File

@ -1,5 +1,4 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
/// Additional general-purpose comparison functionality.
const fuzzy_epsilon: float = 1.0e-6;

View File

@ -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};

View File

@ -1,5 +1,4 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
//! Unsafe debugging functions for inspecting values.
use cast::reinterpret_cast;

View File

@ -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<T: Copy>() -> Deque<T> {
move rv
}
fn get<T: Copy>(elts: &DVec<Cell<T>>, i: uint) -> T {
match (*elts).get_elt(i) { Some(t) => t, _ => fail }
match (*elts).get_elt(i) { Some(move t) => t, _ => fail }
}
type Repr<T> = {mut nelts: uint,

View File

@ -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<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K, +v: V)
-> Treemap<K, V> {
@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<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K, +v: V)
fn find<K: Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K) -> Option<V> {
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<K, V: Copy>(m: Treemap<K, V>, 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);
}
}

View File

@ -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::<Optval>(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::<Optval>(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)) }
}

View File

@ -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<S: serialization2::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<S: serialization2::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: ToJson, B: ToJson> (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: ToJson, B: ToJson> (A, B): ToJson {
impl <A: ToJson, B: ToJson, C: ToJson> (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 <A: ToJson> Option<A>: ToJson {
fn to_json() -> Json {
match self {
None => Null,
Some(value) => value.to_json()
Some(ref value) => value.to_json()
}
}
}

View File

@ -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<T: Copy>(ls: @List<T>, f: fn((&T)) -> bool) -> Option<T> {
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<T: Copy>(ls: @List<T>) -> @List<T> {
/// Returns the first element of a list
pure fn head<T: Copy>(ls: @List<T>) -> 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<T: Copy>(ls: @List<T>) -> T {
pure fn append<T: Copy>(l: @List<T>, m: @List<T>) -> @List<T> {
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<T>(l: @List<T>, f: fn((&T)) -> bool) {
impl<T:Eq> List<T> : Eq {
pure fn eq(other: &List<T>) -> 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
}
}

View File

@ -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<K: Eq IterBytes Hash Const Copy, V: Copy>(
let map = HashMap();
for vec::each(items) |item| {
match *item {
(key, value) => {
(copy key, copy value) => {
map.insert(key, value);
}
}

View File

@ -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

View File

@ -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<IpAddr,ParseAddrErr> {

View File

@ -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..";

View File

@ -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<Url, ~str> {
impl Url : FromStr {
static fn from_str(s: &str) -> Option<Url> {
match from_str(s) {
Ok(url) => Some(url),
Ok(move url) => Some(url),
Err(_) => None
}
}

View File

@ -1,5 +1,4 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use io::Writer;
use io::WriterUtil;

View File

@ -1,5 +1,4 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use io::Writer;
use io::WriterUtil;

View File

@ -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;

View File

@ -245,9 +245,9 @@ fn serialize_Option<S: Serializer,T>(s: S, v: Option<T>, 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)
}
}
}

View File

@ -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<T: Serializable> Option<T>: 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<S: Serializer>(&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<S: Serializer>(&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<S: Serializer>(&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<S: Serializer>(&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));

View File

@ -13,7 +13,6 @@
*/
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
/*
* A SHA-1 implementation derived from Paul E. Jones's reference

View File

@ -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<T: Copy>(self: SmallIntMap<T>, key: uint) -> T {
error!("smallintmap::get(): key not present");
fail;
}
Some(v) => return v
Some(move v) => return v
}
}
@ -117,7 +116,7 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
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;

View File

@ -1,6 +1,5 @@
//! Sorting methods
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use vec::{len, push};
use core::cmp::{Eq, Ord};

View File

@ -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::*;

View File

@ -1,6 +1,5 @@
// NB: transitionary, de-mode-ing.
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
/**
* The concurrency primitives you know and love.
*

View File

@ -1,7 +1,6 @@
//! Temporary files and directories
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use core::option;
use option::{None, Some};

View File

@ -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
}

View File

@ -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 => ~""
};

View File

@ -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<Tm, ~str> {
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 }

View File

@ -1,7 +1,6 @@
//! Utilities that leverage libuv's `uv_timer_*` API
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use uv = uv;
use uv::iotask;

View File

@ -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};

View File

@ -1,5 +1,4 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
mod icu {
#[legacy_exports];

View File

@ -1,7 +1,6 @@
//! A process-wide libuv event loop for library use.
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
export get;

View File

@ -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)
}
}