Skip to content

Commit bc9efaa

Browse files
committed
std: Eliminate deprecated patterns
1 parent 467f2ab commit bc9efaa

37 files changed

+130
-165
lines changed

src/libstd/arc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// NB: transitionary, de-mode-ing.
22
#[forbid(deprecated_mode)];
3-
#[forbid(deprecated_pattern)];
43
/**
54
* Concurrency-enabled mechanisms for sharing mutable and/or immutable state
65
* between tasks.

src/libstd/arena.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
// to waste time running the destructors of POD.
2424

2525
#[forbid(deprecated_mode)];
26-
#[forbid(deprecated_pattern)];
2726

2827
export Arena, arena_with_size;
2928

src/libstd/base64.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#[forbid(deprecated_mode)];
2-
#[forbid(deprecated_pattern)];
32
use io::Reader;
43

54
pub trait ToBase64 {

src/libstd/bitv.rs

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#[forbid(deprecated_mode)];
2-
#[forbid(deprecated_pattern)];
32

43
use vec::{to_mut, from_elem};
54

@@ -241,22 +240,22 @@ priv impl Bitv {
241240
self.die();
242241
}
243242
match self.rep {
244-
Small(s) => match other.rep {
245-
Small(s1) => match op {
246-
Union => s.union(s1, self.nbits),
247-
Intersect => s.intersect(s1, self.nbits),
248-
Assign => s.become(s1, self.nbits),
249-
Difference => s.difference(s1, self.nbits)
243+
Small(ref s) => match other.rep {
244+
Small(ref s1) => match op {
245+
Union => s.union(*s1, self.nbits),
246+
Intersect => s.intersect(*s1, self.nbits),
247+
Assign => s.become(*s1, self.nbits),
248+
Difference => s.difference(*s1, self.nbits)
250249
},
251250
Big(_) => self.die()
252251
},
253-
Big(s) => match other.rep {
252+
Big(ref s) => match other.rep {
254253
Small(_) => self.die(),
255-
Big(s1) => match op {
256-
Union => s.union(s1, self.nbits),
257-
Intersect => s.intersect(s1, self.nbits),
258-
Assign => s.become(s1, self.nbits),
259-
Difference => s.difference(s1, self.nbits)
254+
Big(ref s1) => match op {
255+
Union => s.union(*s1, self.nbits),
256+
Intersect => s.intersect(*s1, self.nbits),
257+
Assign => s.become(*s1, self.nbits),
258+
Difference => s.difference(*s1, self.nbits)
260259
}
261260
}
262261
}
@@ -297,10 +296,10 @@ impl Bitv {
297296
#[inline(always)]
298297
fn clone() -> ~Bitv {
299298
~match self.rep {
300-
Small(b) => {
299+
Small(ref b) => {
301300
Bitv{nbits: self.nbits, rep: Small(~SmallBitv{bits: b.bits})}
302301
}
303-
Big(b) => {
302+
Big(ref b) => {
304303
let st = to_mut(from_elem(self.nbits / uint_bits + 1, 0));
305304
let len = st.len();
306305
for uint::range(0, len) |i| { st[i] = b.storage[i]; };
@@ -314,8 +313,8 @@ impl Bitv {
314313
pure fn get(i: uint) -> bool {
315314
assert (i < self.nbits);
316315
match self.rep {
317-
Big(b) => b.get(i),
318-
Small(s) => s.get(i)
316+
Big(ref b) => b.get(i),
317+
Small(ref s) => s.get(i)
319318
}
320319
}
321320

@@ -328,8 +327,8 @@ impl Bitv {
328327
fn set(i: uint, x: bool) {
329328
assert (i < self.nbits);
330329
match self.rep {
331-
Big(b) => b.set(i, x),
332-
Small(s) => s.set(i, x)
330+
Big(ref b) => b.set(i, x),
331+
Small(ref s) => s.set(i, x)
333332
}
334333
}
335334

@@ -343,12 +342,12 @@ impl Bitv {
343342
fn equal(v1: Bitv) -> bool {
344343
if self.nbits != v1.nbits { return false; }
345344
match self.rep {
346-
Small(b) => match v1.rep {
347-
Small(b1) => b.equals(b1, self.nbits),
345+
Small(ref b) => match v1.rep {
346+
Small(ref b1) => b.equals(*b1, self.nbits),
348347
_ => false
349348
},
350-
Big(s) => match v1.rep {
351-
Big(s1) => s.equals(s1, self.nbits),
349+
Big(ref s) => match v1.rep {
350+
Big(ref s1) => s.equals(*s1, self.nbits),
352351
Small(_) => return false
353352
}
354353
}
@@ -358,25 +357,25 @@ impl Bitv {
358357
#[inline(always)]
359358
fn clear() {
360359
match self.rep {
361-
Small(b) => b.clear(),
362-
Big(s) => for s.each_storage() |w| { w = 0u }
360+
Small(ref b) => b.clear(),
361+
Big(ref s) => for s.each_storage() |w| { w = 0u }
363362
}
364363
}
365364

366365
/// Set all bits to 1
367366
#[inline(always)]
368367
fn set_all() {
369368
match self.rep {
370-
Small(b) => b.set_all(),
371-
Big(s) => for s.each_storage() |w| { w = !0u } }
369+
Small(ref b) => b.set_all(),
370+
Big(ref s) => for s.each_storage() |w| { w = !0u } }
372371
}
373372

374373
/// Invert all bits
375374
#[inline(always)]
376375
fn invert() {
377376
match self.rep {
378-
Small(b) => b.invert(),
379-
Big(s) => for s.each_storage() |w| { w = !w } }
377+
Small(ref b) => b.invert(),
378+
Big(ref s) => for s.each_storage() |w| { w = !w } }
380379
}
381380

382381
/**
@@ -395,7 +394,7 @@ impl Bitv {
395394
#[inline(always)]
396395
fn is_true() -> bool {
397396
match self.rep {
398-
Small(b) => b.is_true(self.nbits),
397+
Small(ref b) => b.is_true(self.nbits),
399398
_ => {
400399
for self.each() |i| { if !i { return false; } }
401400
true
@@ -415,7 +414,7 @@ impl Bitv {
415414
/// Returns true if all bits are 0
416415
fn is_false() -> bool {
417416
match self.rep {
418-
Small(b) => b.is_false(self.nbits),
417+
Small(ref b) => b.is_false(self.nbits),
419418
Big(_) => {
420419
for self.each() |i| { if i { return false; } }
421420
true

src/libstd/cell.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#[forbid(deprecated_mode)];
2-
#[forbid(deprecated_pattern)];
32
/// A dynamic, mutable location.
43
///
54
/// Similar to a mutable option type, but friendlier.

src/libstd/cmp.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#[forbid(deprecated_mode)];
2-
#[forbid(deprecated_pattern)];
32
/// Additional general-purpose comparison functionality.
43
54
const fuzzy_epsilon: float = 1.0e-6;

src/libstd/comm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Higher level communication abstractions.
66

77
// NB: transitionary, de-mode-ing.
88
#[forbid(deprecated_mode)];
9-
#[forbid(deprecated_pattern)];
109

1110
use pipes::{Channel, Recv, Chan, Port, Selectable};
1211

src/libstd/dbg.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#[forbid(deprecated_mode)];
2-
#[forbid(deprecated_pattern)];
32
//! Unsafe debugging functions for inspecting values.
43
54
use cast::reinterpret_cast;

src/libstd/deque.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! A deque. Untested as of yet. Likely buggy
22
#[forbid(deprecated_mode)];
3-
#[forbid(deprecated_pattern)];
43
#[forbid(non_camel_case_types)];
54

65
use option::{Some, None};
@@ -46,7 +45,7 @@ fn create<T: Copy>() -> Deque<T> {
4645
move rv
4746
}
4847
fn get<T: Copy>(elts: &DVec<Cell<T>>, i: uint) -> T {
49-
match (*elts).get_elt(i) { Some(t) => t, _ => fail }
48+
match (*elts).get_elt(i) { Some(move t) => t, _ => fail }
5049
}
5150

5251
type Repr<T> = {mut nelts: uint,

src/libstd/fun_treemap.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#[warn(deprecated_mode)];
2-
#[forbid(deprecated_pattern)];
32

43
/*!
54
* 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)
3736
-> Treemap<K, V> {
3837
@match m {
3938
@Empty => Node(@k, @v, @Empty, @Empty),
40-
@Node(@kk, vv, left, right) => {
39+
@Node(@copy kk, vv, left, right) => {
4140
if k < kk {
4241
Node(@kk, vv, insert(left, k, v), right)
4342
} else if k == kk {
@@ -51,10 +50,10 @@ fn insert<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K, +v: V)
5150
fn find<K: Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K) -> Option<V> {
5251
match *m {
5352
Empty => None,
54-
Node(@kk, @v, left, right) => {
55-
if k == kk {
53+
Node(@ref kk, @copy v, left, right) => {
54+
if k == *kk {
5655
Some(v)
57-
} else if k < kk { find(left, move k) } else { find(right, move k) }
56+
} else if k < *kk { find(left, move k) } else { find(right, move k) }
5857
}
5958
}
6059
}
@@ -68,11 +67,9 @@ fn traverse<K, V: Copy>(m: Treemap<K, V>, f: fn((&K), (&V))) {
6867
matches to me, so I changed it. but that may be a
6968
de-optimization -- tjc
7069
*/
71-
Node(@k, @v, left, right) => {
72-
// copy v to make aliases work out
73-
let v1 = v;
70+
Node(@ref k, @ref v, left, right) => {
7471
traverse(left, f);
75-
f(&k, &v1);
72+
f(k, v);
7673
traverse(right, f);
7774
}
7875
}

src/libstd/getopts.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
*/
6464

6565
#[forbid(deprecated_mode)];
66-
#[forbid(deprecated_pattern)];
6766

6867
use core::cmp::Eq;
6968
use core::result::{Err, Ok};
@@ -110,9 +109,9 @@ fn mkname(nm: &str) -> Name {
110109
impl Name : Eq {
111110
pure fn eq(other: &Name) -> bool {
112111
match self {
113-
Long(e0a) => {
112+
Long(ref e0a) => {
114113
match (*other) {
115-
Long(e0b) => e0a == e0b,
114+
Long(ref e0b) => e0a == e0b,
116115
_ => false
117116
}
118117
}
@@ -177,7 +176,7 @@ fn is_arg(arg: &str) -> bool {
177176
fn name_str(nm: &Name) -> ~str {
178177
return match *nm {
179178
Short(ch) => str::from_char(ch),
180-
Long(s) => s
179+
Long(copy s) => s
181180
};
182181
}
183182

@@ -200,12 +199,12 @@ enum Fail_ {
200199
/// Convert a `fail_` enum into an error string
201200
fn fail_str(+f: Fail_) -> ~str {
202201
return match f {
203-
ArgumentMissing(nm) => ~"Argument to option '" + nm + ~"' missing.",
204-
UnrecognizedOption(nm) => ~"Unrecognized option: '" + nm + ~"'.",
205-
OptionMissing(nm) => ~"Required option '" + nm + ~"' missing.",
206-
OptionDuplicated(nm) => ~"Option '" + nm + ~"' given more than once.",
207-
UnexpectedArgument(nm) => {
208-
~"Option " + nm + ~" does not take an argument."
202+
ArgumentMissing(ref nm) => ~"Argument to option '" + *nm + ~"' missing.",
203+
UnrecognizedOption(ref nm) => ~"Unrecognized option: '" + *nm + ~"'.",
204+
OptionMissing(ref nm) => ~"Required option '" + *nm + ~"' missing.",
205+
OptionDuplicated(ref nm) => ~"Option '" + *nm + ~"' given more than once.",
206+
UnexpectedArgument(ref nm) => {
207+
~"Option " + *nm + ~" does not take an argument."
209208
}
210209
};
211210
}
@@ -382,7 +381,7 @@ fn opts_present(+mm: Matches, names: &[~str]) -> bool {
382381
* argument
383382
*/
384383
fn opt_str(+mm: Matches, nm: &str) -> ~str {
385-
return match opt_val(mm, nm) { Val(s) => s, _ => fail };
384+
return match opt_val(mm, nm) { Val(copy s) => s, _ => fail };
386385
}
387386

388387
/**
@@ -394,7 +393,7 @@ fn opt_str(+mm: Matches, nm: &str) -> ~str {
394393
fn opts_str(+mm: Matches, names: &[~str]) -> ~str {
395394
for vec::each(names) |nm| {
396395
match opt_val(mm, *nm) {
397-
Val(s) => return s,
396+
Val(copy s) => return s,
398397
_ => ()
399398
}
400399
}
@@ -411,7 +410,7 @@ fn opts_str(+mm: Matches, names: &[~str]) -> ~str {
411410
fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] {
412411
let mut acc: ~[~str] = ~[];
413412
for vec::each(opt_vals(mm, nm)) |v| {
414-
match *v { Val(s) => acc.push(s), _ => () }
413+
match *v { Val(copy s) => acc.push(s), _ => () }
415414
}
416415
return acc;
417416
}
@@ -420,7 +419,7 @@ fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] {
420419
fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> {
421420
let vals = opt_vals(mm, nm);
422421
if vec::len::<Optval>(vals) == 0u { return None::<~str>; }
423-
return match vals[0] { Val(s) => Some::<~str>(s), _ => None::<~str> };
422+
return match vals[0] { Val(copy s) => Some::<~str>(s), _ => None::<~str> };
424423
}
425424

426425

@@ -434,7 +433,7 @@ fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> {
434433
fn opt_default(+mm: Matches, nm: &str, def: &str) -> Option<~str> {
435434
let vals = opt_vals(mm, nm);
436435
if vec::len::<Optval>(vals) == 0u { return None::<~str>; }
437-
return match vals[0] { Val(s) => Some::<~str>(s),
436+
return match vals[0] { Val(copy s) => Some::<~str>(s),
438437
_ => Some::<~str>(str::from_slice(def)) }
439438
}
440439

0 commit comments

Comments
 (0)