about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorBrian Anderson <andersrb@gmail.com>2012-08-31 14:51:48 -0700
committerBrian Anderson <andersrb@gmail.com>2012-08-31 14:51:48 -0700
commitafc1ccd282a132eb3206a21a5a0ac8fe4b1c24c7 (patch)
tree87066c4636ce88fc85e8ef6f8feac51d8b1d1a75 /src/libstd
parent3cd54ab1f2f351484a2869120c580b13b2ca7eec (diff)
parent7d57b4864a90776d46898f97a3f4b9b6519cf38d (diff)
Merge pull request #3308 from killerswan/modes7
Remove deprecated modes
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/cmp.rs22
-rw-r--r--src/libstd/dbg.rs8
-rw-r--r--src/libstd/list.rs36
-rw-r--r--src/libstd/prettyprint.rs3
-rw-r--r--src/libstd/rope.rs46
-rw-r--r--src/libstd/tempfile.rs3
6 files changed, 70 insertions, 48 deletions
diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs
index fb42c690246..6484bf298d2 100644
--- a/src/libstd/cmp.rs
+++ b/src/libstd/cmp.rs
@@ -1,34 +1,36 @@
 #[deny(non_camel_case_types)];
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
 /// Additional general-purpose comparison functionality.
 
 const fuzzy_epsilon: float = 1.0e-6;
 
 trait FuzzyEq {
-    pure fn fuzzy_eq(&&other: self) -> bool;
+    pure fn fuzzy_eq(other: &self) -> bool;
 }
 
 impl float: FuzzyEq {
-    pure fn fuzzy_eq(&&other: float) -> bool {
-        return float::abs(self - other) < fuzzy_epsilon;
+    pure fn fuzzy_eq(other: &float) -> bool {
+        return float::abs(self - *other) < fuzzy_epsilon;
     }
 }
 
 impl f32: FuzzyEq {
-    pure fn fuzzy_eq(&&other: f32) -> bool {
-        return f32::abs(self - other) < (fuzzy_epsilon as f32);
+    pure fn fuzzy_eq(other: &f32) -> bool {
+        return f32::abs(self - *other) < (fuzzy_epsilon as f32);
     }
 }
 
 impl f64: FuzzyEq {
-    pure fn fuzzy_eq(&&other: f64) -> bool {
-        return f64::abs(self - other) < (fuzzy_epsilon as f64);
+    pure fn fuzzy_eq(other: &f64) -> bool {
+        return f64::abs(self - *other) < (fuzzy_epsilon as f64);
     }
 }
 
 #[test]
 fn test_fuzzy_equals() {
-    assert ((1.0).fuzzy_eq(1.0));
-    assert ((1.0f32).fuzzy_eq(1.0f32));
-    assert ((1.0f64).fuzzy_eq(1.0f64));
+    assert ((&1.0).fuzzy_eq(&1.0));
+    assert ((&1.0f32).fuzzy_eq(&1.0f32));
+    assert ((&1.0f64).fuzzy_eq(&1.0f64));
 }
 
diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs
index 5ae16759b2f..386cfee1a6a 100644
--- a/src/libstd/dbg.rs
+++ b/src/libstd/dbg.rs
@@ -1,4 +1,6 @@
 #[deny(non_camel_case_types)];
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
 //! Unsafe debugging functions for inspecting values.
 
 import unsafe::reinterpret_cast;
@@ -26,7 +28,7 @@ fn debug_tydesc<T>() {
     rustrt::debug_tydesc(sys::get_type_desc::<T>());
 }
 
-fn debug_opaque<T>(x: T) {
+fn debug_opaque<T>(+x: T) {
     rustrt::debug_opaque(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
 }
 
@@ -34,11 +36,11 @@ fn debug_box<T>(x: @T) {
     rustrt::debug_box(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
 }
 
-fn debug_tag<T>(x: T) {
+fn debug_tag<T>(+x: T) {
     rustrt::debug_tag(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
 }
 
-fn debug_fn<T>(x: T) {
+fn debug_fn<T>(+x: T) {
     rustrt::debug_fn(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
 }
 
diff --git a/src/libstd/list.rs b/src/libstd/list.rs
index 651eb1ab077..e1ff5c8b352 100644
--- a/src/libstd/list.rs
+++ b/src/libstd/list.rs
@@ -1,4 +1,6 @@
 //! A standard linked list
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
 
 import core::cmp::Eq;
 import core::option;
@@ -28,9 +30,9 @@ fn from_vec<T: copy>(v: &[T]) -> @list<T> {
  * * z - The initial value
  * * f - The function to apply
  */
-fn foldl<T: copy, U>(z: T, ls: @list<U>, f: fn(T, U) -> T) -> T {
+fn foldl<T: copy, U>(+z: T, ls: @list<U>, f: fn((&T), (&U)) -> T) -> T {
     let mut accum: T = z;
-    do iter(ls) |elt| { accum = f(accum, elt);}
+    do iter(ls) |elt| { accum = f(&accum, &elt);}
     accum
 }
 
@@ -41,12 +43,12 @@ fn foldl<T: copy, U>(z: T, ls: @list<U>, 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<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> Option<T> {
+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); }
+            if f(&hd) { return Some(hd); }
             tl
           }
           nil => return None
@@ -55,7 +57,7 @@ fn find<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> Option<T> {
 }
 
 /// Returns true if a list contains an element with the given value
-fn has<T: copy Eq>(ls: @list<T>, elt: T) -> bool {
+fn has<T: copy Eq>(ls: @list<T>, +elt: T) -> bool {
     for each(ls) |e| {
         if e == elt { return true; }
     }
@@ -110,10 +112,13 @@ pure fn append<T: copy>(l: @list<T>, m: @list<T>) -> @list<T> {
     }
 }
 
-/// Push an element to the front of a list
-fn push<T: copy>(&l: list<T>, v: T) {
-    l = cons(v, @l);
+/*
+/// Push one element into the front of a list, returning a new list
+/// THIS VERSION DOESN'T ACTUALLY WORK
+pure fn push<T: copy>(ll: &mut @list<T>, +vv: T) {
+    ll = &mut @cons(vv, *ll)
 }
+*/
 
 /// Iterate over a list
 fn iter<T>(l: @list<T>, f: fn(T)) {
@@ -201,7 +206,7 @@ mod tests {
 
     #[test]
     fn test_foldl() {
-        fn add(&&a: uint, &&b: int) -> uint { return a + (b as uint); }
+        fn add(a: &uint, b: &int) -> uint { return *a + (*b as uint); }
         let l = from_vec(~[0, 1, 2, 3, 4]);
         let empty = @list::nil::<int>;
         assert (list::foldl(0u, l, add) == 10u);
@@ -210,8 +215,8 @@ mod tests {
 
     #[test]
     fn test_foldl2() {
-        fn sub(&&a: int, &&b: int) -> int {
-            a - b
+        fn sub(a: &int, b: &int) -> int {
+            *a - *b
         }
         let l = from_vec(~[1, 2, 3, 4]);
         assert (list::foldl(0, l, sub) == -10);
@@ -219,14 +224,14 @@ mod tests {
 
     #[test]
     fn test_find_success() {
-        fn match_(&&i: int) -> bool { return i == 2; }
+        fn match_(i: &int) -> bool { return *i == 2; }
         let l = from_vec(~[0, 1, 2]);
         assert (list::find(l, match_) == option::Some(2));
     }
 
     #[test]
     fn test_find_fail() {
-        fn match_(&&_i: int) -> bool { return false; }
+        fn match_(_i: &int) -> bool { return false; }
         let l = from_vec(~[0, 1, 2]);
         let empty = @list::nil::<int>;
         assert (list::find(l, match_) == option::None::<int>);
@@ -251,6 +256,11 @@ mod tests {
         assert (list::len(empty) == 0u);
     }
 
+    #[test]
+    fn test_append() {
+        assert from_vec(~[1,2,3,4])
+            == list::append(list::from_vec(~[1,2]), list::from_vec(~[3,4]));
+    }
 }
 
 // Local Variables:
diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs
index 259bb4eb612..d9e64d7b1a0 100644
--- a/src/libstd/prettyprint.rs
+++ b/src/libstd/prettyprint.rs
@@ -1,3 +1,6 @@
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 import io::Writer;
 import io::WriterUtil;
 import serialization::serializer;
diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs
index 32a97bac508..12676377def 100644
--- a/src/libstd/rope.rs
+++ b/src/libstd/rope.rs
@@ -23,6 +23,8 @@
  * * access to a character by index is logarithmic (linear in strings);
  */
 
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
 
 /// The type of ropes.
 type rope = node::root;
@@ -436,7 +438,7 @@ mod iterator {
               node::content(x) => return node::leaf_iterator::start(x)
             }
         }
-        fn next(it: node::leaf_iterator::t) -> Option<node::leaf> {
+        fn next(it: &node::leaf_iterator::t) -> Option<node::leaf> {
             return node::leaf_iterator::next(it);
         }
     }
@@ -447,7 +449,7 @@ mod iterator {
               node::content(x) => return node::char_iterator::start(x)
             }
         }
-        fn next(it: node::char_iterator::t) -> Option<char> {
+        fn next(it: &node::char_iterator::t) -> Option<char> {
             return node::char_iterator::next(it)
         }
     }
@@ -751,7 +753,7 @@ mod node {
      * * forest - The forest. This vector is progressively rewritten during
      *            execution and should be discarded as meaningless afterwards.
      */
-    fn tree_from_forest_destructive(forest: ~[mut @node]) -> @node {
+    fn tree_from_forest_destructive(forest: &[mut @node]) -> @node {
         let mut i;
         let mut len = vec::len(forest);
         while len > 1u {
@@ -800,7 +802,7 @@ mod node {
         let mut offset = 0u;//Current position in the buffer
         let it = leaf_iterator::start(node);
         loop {
-            match (leaf_iterator::next(it)) {
+            match (leaf_iterator::next(&it)) {
               option::None => break,
               option::Some(x) => {
                 //FIXME (#2744): Replace with memcpy or something similar
@@ -861,7 +863,7 @@ mod node {
         let mut forest = ~[mut];
         let it = leaf_iterator::start(node);
         loop {
-            match (leaf_iterator::next(it)) {
+            match (leaf_iterator::next(&it)) {
               option::None    => break,
               option::Some(x) => vec::push(forest, @leaf(x))
             }
@@ -1018,7 +1020,7 @@ mod node {
         let itb = char_iterator::start(b);
         let mut result = 0;
         while result == 0 {
-            match ((char_iterator::next(ita), char_iterator::next(itb))) {
+            match ((char_iterator::next(&ita), char_iterator::next(&itb))) {
               (option::None, option::None) => break,
               (option::Some(chara), option::Some(charb)) => {
                 result = char::cmp(chara, charb);
@@ -1121,7 +1123,7 @@ mod node {
             }
         }
 
-        fn next(it: t) -> Option<leaf> {
+        fn next(it: &t) -> Option<leaf> {
             if it.stackpos < 0 { return option::None; }
             loop {
                 let current = it.stack[it.stackpos];
@@ -1162,7 +1164,7 @@ mod node {
             }
         }
 
-        fn next(it: t) -> Option<char> {
+        fn next(it: &t) -> Option<char> {
             loop {
                 match (get_current_or_next_leaf(it)) {
                   option::None => return option::None,
@@ -1177,16 +1179,16 @@ mod node {
             };
         }
 
-        fn get_current_or_next_leaf(it: t) -> Option<leaf> {
-            match (it.leaf) {
-              option::Some(_) => return it.leaf,
+        fn get_current_or_next_leaf(it: &t) -> Option<leaf> {
+            match ((*it).leaf) {
+              option::Some(_) => return (*it).leaf,
               option::None => {
-                let next = leaf_iterator::next(it.leaf_iterator);
+                let next = leaf_iterator::next(&((*it).leaf_iterator));
                 match (next) {
                   option::None => return option::None,
                   option::Some(_) => {
-                    it.leaf          = next;
-                    it.leaf_byte_pos = 0u;
+                    (*it).leaf          = next;
+                    (*it).leaf_byte_pos = 0u;
                     return next;
                   }
                 }
@@ -1194,19 +1196,19 @@ mod node {
             }
         }
 
-        fn get_next_char_in_leaf(it: t) -> Option<char> {
-            match copy it.leaf {
+        fn get_next_char_in_leaf(it: &t) -> Option<char> {
+            match copy (*it).leaf {
               option::None => return option::None,
               option::Some(aleaf) => {
-                if it.leaf_byte_pos >= aleaf.byte_len {
+                if (*it).leaf_byte_pos >= aleaf.byte_len {
                     //We are actually past the end of the leaf
-                    it.leaf = option::None;
+                    (*it).leaf = option::None;
                     return option::None
                 } else {
                     let {ch, next} =
                         str::char_range_at(*aleaf.content,
-                                     it.leaf_byte_pos + aleaf.byte_offset);
-                    it.leaf_byte_pos = next - aleaf.byte_offset;
+                                     (*it).leaf_byte_pos + aleaf.byte_offset);
+                    (*it).leaf_byte_pos = next - aleaf.byte_offset;
                     return option::Some(ch)
                 }
               }
@@ -1274,7 +1276,7 @@ mod tests {
         let rope_iter   = iterator::char::start(r);
         let mut equal   = true;
         while equal {
-            match (node::char_iterator::next(rope_iter)) {
+            match (node::char_iterator::next(&rope_iter)) {
               option::None => {
                 if string_iter < string_len {
                     equal = false;
@@ -1301,7 +1303,7 @@ mod tests {
         let mut len = 0u;
         let it  = iterator::char::start(r);
         loop {
-            match (node::char_iterator::next(it)) {
+            match (node::char_iterator::next(&it)) {
               option::None => break,
               option::Some(_) => len += 1u
             }
diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs
index a10e4605f61..5d2a04c0388 100644
--- a/src/libstd/tempfile.rs
+++ b/src/libstd/tempfile.rs
@@ -1,5 +1,8 @@
 //! Temporary files and directories
 
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 import core::option;
 import option::{None, Some};
 import rand;