about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-08-29 16:11:06 -0700
committerBrian Anderson <banderson@mozilla.com>2012-08-29 16:23:36 -0700
commitc0c8d3aa8fdd054372f91c997913b33146bdf9bd (patch)
tree92ce54582b167358b3f09a0bc3861c643201c1aa /src
parentee2ce036ccd53d8c19689d86cf8b3bd5cf37f40f (diff)
downloadrust-c0c8d3aa8fdd054372f91c997913b33146bdf9bd.tar.gz
rust-c0c8d3aa8fdd054372f91c997913b33146bdf9bd.zip
core: Demode int/uint mods
Diffstat (limited to 'src')
-rw-r--r--src/libcore/int-template.rs12
-rw-r--r--src/libcore/io.rs2
-rw-r--r--src/libcore/str.rs2
-rw-r--r--src/libcore/uint-template.rs12
-rw-r--r--src/libcore/vec.rs4
-rw-r--r--src/libstd/arena.rs4
-rw-r--r--src/libstd/net_tcp.rs2
-rw-r--r--src/libstd/par.rs4
-rw-r--r--src/libstd/rope.rs2
-rw-r--r--src/libsyntax/ast_util.rs4
-rw-r--r--src/libsyntax/parse/comments.rs2
-rw-r--r--src/rustc/back/rpath.rs2
-rw-r--r--src/rustc/driver/rustc.rs2
-rw-r--r--src/rustc/middle/trans/foreign.rs2
-rw-r--r--src/rustc/middle/ty.rs4
15 files changed, 34 insertions, 26 deletions
diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs
index 2f32376e715..ac4aceeaa95 100644
--- a/src/libcore/int-template.rs
+++ b/src/libcore/int-template.rs
@@ -1,3 +1,7 @@
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 import T = inst::T;
 import cmp::{Eq, Ord};
 import num::from_int;
@@ -21,8 +25,8 @@ const bytes : uint = (inst::bits / 8);
 const min_value: T = (-1 as T) << (bits - 1);
 const max_value: T = min_value - 1 as T;
 
-pure fn min(&&x: T, &&y: T) -> T { if x < y { x } else { y } }
-pure fn max(&&x: T, &&y: T) -> T { if x > y { x } else { y } }
+pure fn min(x: &T, y: &T) -> T { if *x < *y { *x } else { *y } }
+pure fn max(x: &T, y: &T) -> T { if *x > *y { *x } else { *y } }
 
 pure fn add(x: &T, y: &T) -> T { *x + *y }
 pure fn sub(x: &T, y: &T) -> T { *x - *y }
@@ -155,7 +159,7 @@ fn parse_buf(buf: ~[u8], radix: uint) -> Option<T> {
 }
 
 /// Parse a string to an int
-fn from_str(s: ~str) -> Option<T> { parse_buf(str::to_bytes(s), 10u) }
+fn from_str(s: &str) -> Option<T> { parse_buf(str::to_bytes(s), 10u) }
 
 /// Convert to a string in a given base
 fn to_str(n: T, radix: uint) -> ~str {
@@ -235,7 +239,7 @@ fn test_to_str() {
 
 #[test]
 fn test_interfaces() {
-    fn test<U:num::Num>(ten: U) {
+    fn test<U:num::Num>(+ten: U) {
         assert (ten.to_int() == 10);
 
         let two: U = from_int(2);
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index d5521b509d4..1fd9b79ad9d 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -284,7 +284,7 @@ type ByteBuf = {buf: &[const u8], mut pos: uint};
 
 impl ByteBuf: Reader {
     fn read(buf: &[mut u8], len: uint) -> uint {
-        let count = uint::min(len, self.buf.len() - self.pos);
+        let count = uint::min(&len, &(self.buf.len() - self.pos));
 
         vec::u8::memcpy(buf,
                         vec::const_view(self.buf, self.pos, self.buf.len()),
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index b0cbf559fec..32665db7966 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -676,7 +676,7 @@ pure fn eq_slice(a: &str, b: &str) -> bool {
     let a_len = a.len();
     let b_len = b.len();
     if a_len != b_len { return false; }
-    let mut end = uint::min(a_len, b_len);
+    let mut end = uint::min(&a_len, &b_len);
 
     let mut i = 0u;
     while i < end {
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs
index e36d0744b2c..f95848f2496 100644
--- a/src/libcore/uint-template.rs
+++ b/src/libcore/uint-template.rs
@@ -1,3 +1,7 @@
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 import T = inst::T;
 import cmp::{Eq, Ord};
 
@@ -20,8 +24,8 @@ const bytes : uint = (inst::bits / 8);
 const min_value: T = 0 as T;
 const max_value: T = 0 as T - 1 as T;
 
-pure fn min(&&x: T, &&y: T) -> T { if x < y { x } else { y } }
-pure fn max(&&x: T, &&y: T) -> T { if x > y { x } else { y } }
+pure fn min(x: &T, y: &T) -> T { if *x < *y { *x } else { *y } }
+pure fn max(x: &T, y: &T) -> T { if *x > *y { *x } else { *y } }
 
 pure fn add(x: &T, y: &T) -> T { *x + *y }
 pure fn sub(x: &T, y: &T) -> T { *x - *y }
@@ -138,10 +142,10 @@ fn parse_buf(buf: &[const u8], radix: uint) -> Option<T> {
 }
 
 /// Parse a string to an int
-fn from_str(s: ~str) -> Option<T> { parse_buf(str::to_bytes(s), 10u) }
+fn from_str(s: &str) -> Option<T> { parse_buf(str::to_bytes(s), 10u) }
 
 /// Parse a string as an unsigned integer.
-fn from_str_radix(buf: ~str, radix: u64) -> Option<u64> {
+fn from_str_radix(buf: &str, radix: u64) -> Option<u64> {
     if str::len(buf) == 0u { return None; }
     let mut i = str::len(buf) - 1u;
     let mut power = 1u64, n = 0u64;
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs
index 33199576c11..ee82971c70e 100644
--- a/src/libcore/vec.rs
+++ b/src/libcore/vec.rs
@@ -1430,7 +1430,7 @@ impl<T: Eq> @[T]: Eq {
 
 pure fn lt<T: Ord>(a: &[T], b: &[T]) -> bool {
     let (a_len, b_len) = (a.len(), b.len());
-    let mut end = uint::min(a_len, b_len);
+    let mut end = uint::min(&a_len, &b_len);
 
     let mut i = 0;
     while i < end {
@@ -1821,7 +1821,7 @@ mod u8 {
     pure fn cmp(a: &~[u8], b: &~[u8]) -> int {
         let a_len = len(*a);
         let b_len = len(*b);
-        let n = uint::min(a_len, b_len) as libc::size_t;
+        let n = uint::min(&a_len, &b_len) as libc::size_t;
         let r = unsafe {
             libc::memcmp(unsafe::to_ptr(*a) as *libc::c_void,
                          unsafe::to_ptr(*b) as *libc::c_void, n) as int
diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs
index 7609fa70454..162e5f2c071 100644
--- a/src/libstd/arena.rs
+++ b/src/libstd/arena.rs
@@ -135,7 +135,7 @@ impl &Arena {
     fn alloc_pod_grow(n_bytes: uint, align: uint) -> *u8 {
         // Allocate a new chunk.
         let chunk_size = at_vec::capacity(self.pod_head.data);
-        let new_min_chunk_size = uint::max(n_bytes, chunk_size);
+        let new_min_chunk_size = uint::max(&n_bytes, &chunk_size);
         self.chunks = @cons(copy self.pod_head, self.chunks);
         self.pod_head =
             chunk(uint::next_power_of_two(new_min_chunk_size + 1u), true);
@@ -177,7 +177,7 @@ impl &Arena {
     fn alloc_nonpod_grow(n_bytes: uint, align: uint) -> (*u8, *u8) {
         // Allocate a new chunk.
         let chunk_size = at_vec::capacity(self.head.data);
-        let new_min_chunk_size = uint::max(n_bytes, chunk_size);
+        let new_min_chunk_size = uint::max(&n_bytes, &chunk_size);
         self.chunks = @cons(copy self.head, self.chunks);
         self.head =
             chunk(uint::next_power_of_two(new_min_chunk_size + 1u), false);
diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs
index cb0fddcfe61..1cc5fa680d2 100644
--- a/src/libstd/net_tcp.rs
+++ b/src/libstd/net_tcp.rs
@@ -772,7 +772,7 @@ impl tcp_socket_buf: io::Reader {
             }
         }
 
-        let count = uint::min(len, self.data.buf.len());
+        let count = uint::min(&len, &self.data.buf.len());
 
         let mut data = ~[];
         self.data.buf <-> data;
diff --git a/src/libstd/par.rs b/src/libstd/par.rs
index 34ea2433bed..ab5062148e0 100644
--- a/src/libstd/par.rs
+++ b/src/libstd/par.rs
@@ -30,7 +30,7 @@ fn map_slices<A: copy send, B: copy send>(
         ~[f()(0u, xs)]
     }
     else {
-        let num_tasks = uint::min(max_tasks, len / min_granularity);
+        let num_tasks = uint::min(&max_tasks, &(len / min_granularity));
 
         let items_per_task = len / num_tasks;
 
@@ -38,7 +38,7 @@ fn map_slices<A: copy send, B: copy send>(
         let mut base = 0u;
         log(info, ~"spawning tasks");
         while base < len {
-            let end = uint::min(len, base + items_per_task);
+            let end = uint::min(&len, &(base + items_per_task));
             // FIXME: why is the ::<A, ()> annotation required here? (#2617)
             do vec::as_buf::<A, ()>(xs) |p, _len| {
                 let f = f();
diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs
index 2a7cdeefc7d..32a97bac508 100644
--- a/src/libstd/rope.rs
+++ b/src/libstd/rope.rs
@@ -1002,7 +1002,7 @@ mod node {
                      right   : right,
              char_len: char_len(left) + char_len(right),
                      byte_len: byte_len(left) + byte_len(right),
-             height: uint::max(height(left), height(right)) + 1u
+             height: uint::max(&height(left), &height(right)) + 1u
                     })
     }
 
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 79df0767ca5..3481b6c93c2 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -563,8 +563,8 @@ fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range {
     let min = @mut int::max_value;
     let max = @mut int::min_value;
     do visit_ids_fn |id| {
-        *min = int::min(*min, id);
-        *max = int::max(*max, id + 1);
+        *min = int::min(min, &id);
+        *max = int::max(max, &(id + 1));
     }
     return {min:*min, max:*max};
 }
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 7b18ca532e0..b4c9eb6f69e 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -182,7 +182,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
                                         s: ~str, col: uint) unsafe {
     let mut s1;
     let len = str::len(s);
-    if all_whitespace(s, 0u, uint::min(len, col)) {
+    if all_whitespace(s, 0u, uint::min(&len, &col)) {
         if col < len {
             s1 = str::slice(s, col, len);
         } else { s1 = ~""; }
diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs
index fa02b617606..286ca505714 100644
--- a/src/rustc/back/rpath.rs
+++ b/src/rustc/back/rpath.rs
@@ -128,7 +128,7 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
     assert len1 > 0u;
     assert len2 > 0u;
 
-    let max_common_path = uint::min(len1, len2) - 1u;
+    let max_common_path = uint::min(&len1, &len2) - 1u;
     let mut start_idx = 0u;
     while start_idx < max_common_path
         && split1[start_idx] == split2[start_idx] {
diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs
index 927b6b3da2b..7e56a8caedd 100644
--- a/src/rustc/driver/rustc.rs
+++ b/src/rustc/driver/rustc.rs
@@ -81,7 +81,7 @@ Options:
 fn describe_warnings() {
     let lint_dict = lint::get_lint_dict();
     let mut max_key = 0u;
-    for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); }
+    for lint_dict.each_key |k| { max_key = uint::max(&k.len(), &max_key); }
     fn padded(max: uint, s: ~str) -> ~str {
         str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
     }
diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs
index d760e47296e..2c410b886d7 100644
--- a/src/rustc/middle/trans/foreign.rs
+++ b/src/rustc/middle/trans/foreign.rs
@@ -82,7 +82,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
             3 /* double */ => 8u,
             10 /* struct */ => {
               do vec::foldl(0u, struct_tys(ty)) |a, t| {
-                    uint::max(a, ty_align(t))
+                    uint::max(&a, &ty_align(t))
                 }
             }
             11 /* array */ => {
diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs
index 18d54dbf5d8..5e8b2644363 100644
--- a/src/rustc/middle/ty.rs
+++ b/src/rustc/middle/ty.rs
@@ -1856,9 +1856,9 @@ fn type_size(cx: ctxt, ty: t) -> uint {
         let variants = substd_enum_variants(cx, did, substs);
         variants.foldl( // find max size of any variant
             0,
-            |m, v| uint::max(m,
+            |m, v| uint::max(&m,
                              // find size of this variant:
-                             v.args.foldl(0, |s, a| s + type_size(cx, a))))
+                             &v.args.foldl(0, |s, a| s + type_size(cx, a))))
       }
 
       ty_param(_) | ty_self => {