about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2012-08-13 17:11:33 -0700
committerGraydon Hoare <graydon@mozilla.com>2012-08-13 17:11:33 -0700
commit91612dbb7e37b53223a57557a442e29a84f0f6bf (patch)
tree2e60b8b85100333d99b2d7643a7742e036c93e99
parent52255f898c1af5a59ebb4b127d5946a005c7eae8 (diff)
downloadrust-91612dbb7e37b53223a57557a442e29a84f0f6bf.tar.gz
rust-91612dbb7e37b53223a57557a442e29a84f0f6bf.zip
De-mode-ify a few minor libcore modules.
-rw-r--r--src/libcore/bool.rs16
-rw-r--r--src/libcore/box.rs4
-rw-r--r--src/libcore/char.rs4
-rw-r--r--src/libcore/cmath.rs4
-rw-r--r--src/libcore/cmp.rs4
-rw-r--r--src/libcore/dlist.rs4
-rw-r--r--src/libcore/dvec.rs6
-rw-r--r--src/libcore/either.rs49
-rw-r--r--src/libstd/timer.rs4
-rw-r--r--src/rustc/middle/trans/alt.rs2
-rw-r--r--src/test/bench/core-vec-append.rs2
-rw-r--r--src/test/run-fail/bug-811.rs4
-rw-r--r--src/test/run-pass/dvec-test.rs2
13 files changed, 69 insertions, 36 deletions
diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs
index f8eb96996d0..b25f713aacd 100644
--- a/src/libcore/bool.rs
+++ b/src/libcore/bool.rs
@@ -1,5 +1,9 @@
 // -*- rust -*-
 
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 //! Boolean logic
 
 export not, and, or, xor, implies;
@@ -38,11 +42,13 @@ pure fn is_true(v: bool) -> bool { v }
 pure fn is_false(v: bool) -> bool { !v }
 
 /// Parse logic value from `s`
-pure fn from_str(s: ~str) -> option<bool> {
-    match check s {
-      ~"true" => some(true),
-      ~"false" => some(false),
-      _ => none
+pure fn from_str(s: &str) -> option<bool> {
+    if s == "true" {
+        some(true)
+    } else if s == "false" {
+        some(false)
+    } else {
+        none
     }
 }
 
diff --git a/src/libcore/box.rs b/src/libcore/box.rs
index bbafc87774d..be4f7b4e8a6 100644
--- a/src/libcore/box.rs
+++ b/src/libcore/box.rs
@@ -1,5 +1,9 @@
 //! Operations on shared box types
 
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 export ptr_eq;
 
 pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
diff --git a/src/libcore/char.rs b/src/libcore/char.rs
index 98aeddcf273..85e87c9172b 100644
--- a/src/libcore/char.rs
+++ b/src/libcore/char.rs
@@ -1,5 +1,9 @@
 //! Utilities for manipulating the char type
 
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 /*
     Lu  Uppercase_Letter    an uppercase letter
     Ll  Lowercase_Letter    a lowercase letter
diff --git a/src/libcore/cmath.rs b/src/libcore/cmath.rs
index de611ab2c0a..29dff86b237 100644
--- a/src/libcore/cmath.rs
+++ b/src/libcore/cmath.rs
@@ -1,3 +1,7 @@
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 export c_float;
 export c_double;
 
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs
index a336e18a63d..aa39ab2ada4 100644
--- a/src/libcore/cmp.rs
+++ b/src/libcore/cmp.rs
@@ -1,3 +1,7 @@
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 /// Interfaces used for comparison.
 
 trait ord {
diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs
index c3d8def4751..b3f56109ee4 100644
--- a/src/libcore/dlist.rs
+++ b/src/libcore/dlist.rs
@@ -1,3 +1,7 @@
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 /**
  * A doubly-linked list. Supports O(1) head, tail, count, push, pop, etc.
  *
diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs
index 0d3748e187a..e4ff406a9b7 100644
--- a/src/libcore/dvec.rs
+++ b/src/libcore/dvec.rs
@@ -1,3 +1,7 @@
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 // Dynamic Vector
 //
 // A growable vector that makes use of unique pointers so that the
@@ -69,7 +73,7 @@ fn from_vec<A>(+v: ~[mut A]) -> dvec<A> {
 }
 
 /// Consumes the vector and returns its contents
-fn unwrap<A>(-d: dvec<A>) -> ~[mut A] {
+fn unwrap<A>(+d: dvec<A>) -> ~[mut A] {
     let dvec_({data: v}) <- d;
     return v;
 }
diff --git a/src/libcore/either.rs b/src/libcore/either.rs
index 06999513889..6b9c1846c37 100644
--- a/src/libcore/either.rs
+++ b/src/libcore/either.rs
@@ -1,3 +1,7 @@
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 //! A type that represents one of two alternatives
 
 import result::result;
@@ -8,8 +12,8 @@ enum either<T, U> {
     right(U)
 }
 
-fn either<T, U, V>(f_left: fn(T) -> V,
-                   f_right: fn(U) -> V, value: either<T, U>) -> V {
+fn either<T, U, V>(f_left: fn((&T)) -> V,
+                   f_right: fn((&U)) -> V, value: &either<T, U>) -> V {
     /*!
      * Applies a function based on the given either value
      *
@@ -18,13 +22,13 @@ fn either<T, U, V>(f_left: fn(T) -> V,
      * result is returned.
      */
 
-    match value {
-      left(l) => f_left(l),
-      right(r) => f_right(r)
+    match *value {
+      left(ref l) => f_left(l),
+      right(ref r) => f_right(r)
     }
 }
 
-fn lefts<T: copy, U>(eithers: ~[either<T, U>]) -> ~[T] {
+fn lefts<T: copy, U>(eithers: &[either<T, U>]) -> ~[T] {
     //! Extracts from a vector of either all the left values
 
     let mut result: ~[T] = ~[];
@@ -37,7 +41,7 @@ fn lefts<T: copy, U>(eithers: ~[either<T, U>]) -> ~[T] {
     return result;
 }
 
-fn rights<T, U: copy>(eithers: ~[either<T, U>]) -> ~[U] {
+fn rights<T, U: copy>(eithers: &[either<T, U>]) -> ~[U] {
     //! Extracts from a vector of either all the right values
 
     let mut result: ~[U] = ~[];
@@ -50,7 +54,7 @@ fn rights<T, U: copy>(eithers: ~[either<T, U>]) -> ~[U] {
     return result;
 }
 
-fn partition<T: copy, U: copy>(eithers: ~[either<T, U>])
+fn partition<T: copy, U: copy>(eithers: &[either<T, U>])
     -> {lefts: ~[T], rights: ~[U]} {
     /*!
      * Extracts from a vector of either all the left values and right values
@@ -70,17 +74,16 @@ fn partition<T: copy, U: copy>(eithers: ~[either<T, U>])
     return {lefts: lefts, rights: rights};
 }
 
-pure fn flip<T: copy, U: copy>(eith: either<T, U>) -> either<U, T> {
+pure fn flip<T: copy, U: copy>(eith: &either<T, U>) -> either<U, T> {
     //! Flips between left and right of a given either
 
-    match eith {
+    match *eith {
       right(r) => left(r),
       left(l) => right(l)
     }
 }
 
-pure fn to_result<T: copy, U: copy>(
-    eith: either<T, U>) -> result<U, T> {
+pure fn to_result<T: copy, U: copy>(eith: &either<T, U>) -> result<U, T> {
     /*!
      * Converts either::t to a result::t
      *
@@ -88,38 +91,38 @@ pure fn to_result<T: copy, U: copy>(
      * an ok result, and the "left" choice a fail
      */
 
-    match eith {
+    match *eith {
       right(r) => result::ok(r),
       left(l) => result::err(l)
     }
 }
 
-pure fn is_left<T, U>(eith: either<T, U>) -> bool {
+pure fn is_left<T, U>(eith: &either<T, U>) -> bool {
     //! Checks whether the given value is a left
 
-    match eith { left(_) => true, _ => false }
+    match *eith { left(_) => true, _ => false }
 }
 
-pure fn is_right<T, U>(eith: either<T, U>) -> bool {
+pure fn is_right<T, U>(eith: &either<T, U>) -> bool {
     //! Checks whether the given value is a right
 
-    match eith { right(_) => true, _ => false }
+    match *eith { right(_) => true, _ => false }
 }
 
 #[test]
 fn test_either_left() {
     let val = left(10);
-    fn f_left(&&x: int) -> bool { x == 10 }
-    fn f_right(&&_x: uint) -> bool { false }
-    assert (either(f_left, f_right, val));
+    fn f_left(x: &int) -> bool { *x == 10 }
+    fn f_right(_x: &uint) -> bool { false }
+    assert (either(f_left, f_right, &val));
 }
 
 #[test]
 fn test_either_right() {
     let val = right(10u);
-    fn f_left(&&_x: int) -> bool { false }
-    fn f_right(&&x: uint) -> bool { x == 10u }
-    assert (either(f_left, f_right, val));
+    fn f_left(_x: &int) -> bool { false }
+    fn f_right(x: &uint) -> bool { *x == 10u }
+    assert (either(f_left, f_right, &val));
 }
 
 #[test]
diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs
index d19d7a1adcc..336b53daa96 100644
--- a/src/libstd/timer.rs
+++ b/src/libstd/timer.rs
@@ -110,8 +110,8 @@ fn recv_timeout<T: copy send>(iotask: iotask,
                            left_val});
             none
         }, |right_val| {
-            some(right_val)
-        }, comm::select2(timeout_po, wait_po)
+            some(*right_val)
+        }, &comm::select2(timeout_po, wait_po)
     )
 }
 
diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs
index 1e2a9f42291..3b63e6437c9 100644
--- a/src/rustc/middle/trans/alt.rs
+++ b/src/rustc/middle/trans/alt.rs
@@ -297,7 +297,7 @@ fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] {
             }
         }
     }
-    return vec::from_mut(dvec::unwrap(found));
+    return vec::from_mut(dvec::unwrap(move found));
 }
 
 fn extract_variant_args(bcx: block, pat_id: ast::node_id,
diff --git a/src/test/bench/core-vec-append.rs b/src/test/bench/core-vec-append.rs
index 59923a77a38..6456f5db39b 100644
--- a/src/test/bench/core-vec-append.rs
+++ b/src/test/bench/core-vec-append.rs
@@ -17,7 +17,7 @@ fn collect_dvec(num: uint) -> ~[mut uint] {
     for uint::range(0u, num) |i| {
         result.push(i);
     }
-    return dvec::unwrap(result);
+    return dvec::unwrap(move result);
 }
 
 fn main(args: ~[~str]) {
diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs
index e1b9187e0fb..e376085772b 100644
--- a/src/test/run-fail/bug-811.rs
+++ b/src/test/run-fail/bug-811.rs
@@ -1,11 +1,11 @@
 // error-pattern:quux
-fn test00_start(ch: chan_t<int>, message: int) { send(ch, copy message); }
+fn test00_start(ch: chan_t<int>, message: int) { send(ch, message); }
 
 type task_id = int;
 type port_id = int;
 
 enum chan_t<T: send> = {task: task_id, port: port_id};
 
-fn send<T: send>(ch: chan_t<T>, -data: T) { fail; }
+fn send<T: send>(ch: chan_t<T>, data: T) { fail; }
 
 fn main() { fail ~"quux"; }
diff --git a/src/test/run-pass/dvec-test.rs b/src/test/run-pass/dvec-test.rs
index 78b804ecf38..55a8331b8b1 100644
--- a/src/test/run-pass/dvec-test.rs
+++ b/src/test/run-pass/dvec-test.rs
@@ -23,5 +23,5 @@ fn main() {
         assert e == exp[i];
     }
 
-    assert dvec::unwrap(d) == exp;
+    assert dvec::unwrap(move d) == exp;
 }
\ No newline at end of file