Skip to content

Commit df12658

Browse files
Remove int/uint from libstd/lib.rs
1 parent c74d49c commit df12658

File tree

13 files changed

+39
-65
lines changed

13 files changed

+39
-65
lines changed

Diff for: src/libcoretest/iter.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use core::iter::*;
1212
use core::iter::order::*;
1313
use core::iter::MinMaxResult::*;
1414
use core::num::SignedInt;
15-
use core::uint;
15+
use core::usize;
1616
use core::cmp;
1717

1818
use test::Bencher;
@@ -292,7 +292,7 @@ fn test_unfoldr() {
292292
fn test_cycle() {
293293
let cycle_len = 3;
294294
let it = count(0, 1).take(cycle_len).cycle();
295-
assert_eq!(it.size_hint(), (uint::MAX, None));
295+
assert_eq!(it.size_hint(), (usize::MAX, None));
296296
for (i, x) in it.take(100).enumerate() {
297297
assert_eq!(i % cycle_len, x);
298298
}
@@ -365,19 +365,19 @@ fn test_iterator_size_hint() {
365365
let v2 = &[10, 11, 12];
366366
let vi = v.iter();
367367

368-
assert_eq!(c.size_hint(), (uint::MAX, None));
368+
assert_eq!(c.size_hint(), (usize::MAX, None));
369369
assert_eq!(vi.clone().size_hint(), (10, Some(10)));
370370

371371
assert_eq!(c.clone().take(5).size_hint(), (5, Some(5)));
372372
assert_eq!(c.clone().skip(5).size_hint().1, None);
373373
assert_eq!(c.clone().take_while(|_| false).size_hint(), (0, None));
374374
assert_eq!(c.clone().skip_while(|_| false).size_hint(), (0, None));
375-
assert_eq!(c.clone().enumerate().size_hint(), (uint::MAX, None));
376-
assert_eq!(c.clone().chain(vi.clone().cloned()).size_hint(), (uint::MAX, None));
375+
assert_eq!(c.clone().enumerate().size_hint(), (usize::MAX, None));
376+
assert_eq!(c.clone().chain(vi.clone().cloned()).size_hint(), (usize::MAX, None));
377377
assert_eq!(c.clone().zip(vi.clone()).size_hint(), (10, Some(10)));
378378
assert_eq!(c.clone().scan(0, |_,_| Some(0)).size_hint(), (0, None));
379379
assert_eq!(c.clone().filter(|_| false).size_hint(), (0, None));
380-
assert_eq!(c.clone().map(|_| 0).size_hint(), (uint::MAX, None));
380+
assert_eq!(c.clone().map(|_| 0).size_hint(), (usize::MAX, None));
381381
assert_eq!(c.filter_map(|_| Some(0)).size_hint(), (0, None));
382382

383383
assert_eq!(vi.clone().take(5).size_hint(), (5, Some(5)));
@@ -753,7 +753,7 @@ fn test_range() {
753753

754754
assert_eq!((0..100).size_hint(), (100, Some(100)));
755755
// this test is only meaningful when sizeof uint < sizeof u64
756-
assert_eq!((uint::MAX - 1..uint::MAX).size_hint(), (1, Some(1)));
756+
assert_eq!((usize::MAX - 1..usize::MAX).size_hint(), (1, Some(1)));
757757
assert_eq!((-10..-1).size_hint(), (9, Some(9)));
758758
assert_eq!((-1..-10).size_hint(), (0, Some(0)));
759759
}

Diff for: src/libcoretest/num/int.rs

-11
This file was deleted.

Diff for: src/libcoretest/num/int_macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ macro_rules! int_module { ($T:ty, $T_i:ident) => (
1212
#[cfg(test)]
1313
mod tests {
1414
use core::$T_i::*;
15-
use core::int;
15+
use core::isize;
1616
use core::num::{FromStrRadix, Int, SignedInt};
1717
use core::ops::{Shl, Shr, Not, BitXor, BitAnd, BitOr};
1818
use num;
@@ -153,7 +153,7 @@ mod tests {
153153
fn test_signed_checked_div() {
154154
assert!(10.checked_div(2) == Some(5));
155155
assert!(5.checked_div(0) == None);
156-
assert!(int::MIN.checked_div(-1) == None);
156+
assert!(isize::MIN.checked_div(-1) == None);
157157
}
158158

159159
#[test]

Diff for: src/libcoretest/num/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ mod i8;
2121
mod i16;
2222
mod i32;
2323
mod i64;
24-
mod int;
2524

2625
#[macro_use]
2726
mod uint_macros;
@@ -30,7 +29,6 @@ mod u8;
3029
mod u16;
3130
mod u32;
3231
mod u64;
33-
mod uint;
3432

3533
/// Helper function for testing numeric operations
3634
pub fn test_num<T>(ten: T, two: T) where

Diff for: src/libcoretest/num/uint.rs

-11
This file was deleted.

Diff for: src/libgetopts/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ fn test_split_within() {
963963
"little lamb".to_string(),
964964
"Little lamb".to_string()
965965
]);
966-
t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::MAX,
966+
t("\nMary had a little lamb\nLittle lamb\n", ::std::usize::MAX,
967967
&["Mary had a little lamb\nLittle lamb".to_string()]);
968968
}
969969

Diff for: src/librustc/middle/liveness.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
//! enclosing function. On the way down the tree, it identifies those AST
5252
//! nodes and variable IDs that will be needed for the liveness analysis
5353
//! and assigns them contiguous IDs. The liveness id for an AST node is
54-
//! called a `live_node` (it's a newtype'd uint) and the id for a variable
55-
//! is called a `variable` (another newtype'd uint).
54+
//! called a `live_node` (it's a newtype'd usize) and the id for a variable
55+
//! is called a `variable` (another newtype'd usize).
5656
//!
5757
//! On the way back up the tree, as we are about to exit from a function
5858
//! declaration we allocate a `liveness` instance. Now that we know
@@ -118,7 +118,7 @@ use middle::ty::ClosureTyper;
118118
use lint;
119119
use util::nodemap::NodeMap;
120120

121-
use std::{fmt, old_io, uint};
121+
use std::{fmt, old_io, usize};
122122
use std::rc::Rc;
123123
use std::iter::repeat;
124124
use syntax::ast::{self, NodeId, Expr};
@@ -138,17 +138,17 @@ enum LoopKind<'a> {
138138
}
139139

140140
#[derive(Copy, PartialEq)]
141-
struct Variable(uint);
141+
struct Variable(usize);
142142

143143
#[derive(Copy, PartialEq)]
144-
struct LiveNode(uint);
144+
struct LiveNode(usize);
145145

146146
impl Variable {
147-
fn get(&self) -> uint { let Variable(v) = *self; v }
147+
fn get(&self) -> usize { let Variable(v) = *self; v }
148148
}
149149

150150
impl LiveNode {
151-
fn get(&self) -> uint { let LiveNode(v) = *self; v }
151+
fn get(&self) -> usize { let LiveNode(v) = *self; v }
152152
}
153153

154154
impl Clone for LiveNode {
@@ -232,11 +232,11 @@ impl fmt::Debug for Variable {
232232

233233
impl LiveNode {
234234
fn is_valid(&self) -> bool {
235-
self.get() != uint::MAX
235+
self.get() != usize::MAX
236236
}
237237
}
238238

239-
fn invalid_node() -> LiveNode { LiveNode(uint::MAX) }
239+
fn invalid_node() -> LiveNode { LiveNode(usize::MAX) }
240240

241241
struct CaptureInfo {
242242
ln: LiveNode,
@@ -260,8 +260,8 @@ enum VarKind {
260260
struct IrMaps<'a, 'tcx: 'a> {
261261
tcx: &'a ty::ctxt<'tcx>,
262262

263-
num_live_nodes: uint,
264-
num_vars: uint,
263+
num_live_nodes: usize,
264+
num_vars: usize,
265265
live_node_map: NodeMap<LiveNode>,
266266
variable_map: NodeMap<Variable>,
267267
capture_info_map: NodeMap<Rc<Vec<CaptureInfo>>>,
@@ -540,9 +540,9 @@ struct Specials {
540540
clean_exit_var: Variable
541541
}
542542

543-
static ACC_READ: uint = 1;
544-
static ACC_WRITE: uint = 2;
545-
static ACC_USE: uint = 4;
543+
static ACC_READ: u32 = 1;
544+
static ACC_WRITE: u32 = 2;
545+
static ACC_USE: u32 = 4;
546546

547547
struct Liveness<'a, 'tcx: 'a> {
548548
ir: &'a mut IrMaps<'a, 'tcx>,
@@ -631,7 +631,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
631631
succ
632632
}
633633

634-
fn idx(&self, ln: LiveNode, var: Variable) -> uint {
634+
fn idx(&self, ln: LiveNode, var: Variable) -> usize {
635635
ln.get() * self.ir.num_vars + var.get()
636636
}
637637

@@ -670,7 +670,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
670670
}
671671

672672
fn indices2<F>(&mut self, ln: LiveNode, succ_ln: LiveNode, mut op: F) where
673-
F: FnMut(&mut Liveness<'a, 'tcx>, uint, uint),
673+
F: FnMut(&mut Liveness<'a, 'tcx>, usize, usize),
674674
{
675675
let node_base_idx = self.idx(ln, Variable(0));
676676
let succ_base_idx = self.idx(succ_ln, Variable(0));
@@ -684,7 +684,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
684684
ln: LiveNode,
685685
mut test: F)
686686
-> old_io::IoResult<()> where
687-
F: FnMut(uint) -> LiveNode,
687+
F: FnMut(usize) -> LiveNode,
688688
{
689689
let node_base_idx = self.idx(ln, Variable(0));
690690
for var_idx in 0..self.ir.num_vars {
@@ -807,7 +807,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
807807
}
808808

809809
// Either read, write, or both depending on the acc bitset
810-
fn acc(&mut self, ln: LiveNode, var: Variable, acc: uint) {
810+
fn acc(&mut self, ln: LiveNode, var: Variable, acc: u32) {
811811
debug!("{:?} accesses[{:x}] {:?}: {}",
812812
ln, acc, var, self.ln_str(ln));
813813

@@ -1283,7 +1283,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
12831283
}
12841284

12851285
// see comment on propagate_through_lvalue()
1286-
fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
1286+
fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: u32)
12871287
-> LiveNode {
12881288
match expr.node {
12891289
ast::ExprPath(..) => {
@@ -1298,7 +1298,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
12981298
}
12991299
}
13001300

1301-
fn access_path(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
1301+
fn access_path(&mut self, expr: &Expr, succ: LiveNode, acc: u32)
13021302
-> LiveNode {
13031303
match self.ir.tcx.def_map.borrow()[expr.id].full_def() {
13041304
DefLocal(nid) => {

Diff for: src/librustc_trans/trans/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ fn pick_column_to_specialize(def_map: &DefMap, m: &[Match]) -> Option<uint> {
789789

790790
// Irrefutable columns always go first, they'd only be duplicated in the branches.
791791
if total_score == 0 {
792-
std::uint::MAX
792+
std::usize::MAX
793793
} else {
794794
total_score
795795
}

Diff for: src/libstd/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,12 @@ mod int_macros;
221221
mod uint_macros;
222222

223223
#[path = "num/isize.rs"] pub mod isize;
224-
pub use isize as int;
225224
#[path = "num/i8.rs"] pub mod i8;
226225
#[path = "num/i16.rs"] pub mod i16;
227226
#[path = "num/i32.rs"] pub mod i32;
228227
#[path = "num/i64.rs"] pub mod i64;
229228

230229
#[path = "num/usize.rs"] pub mod usize;
231-
pub use usize as uint;
232230
#[path = "num/u8.rs"] pub mod u8;
233231
#[path = "num/u16.rs"] pub mod u16;
234232
#[path = "num/u32.rs"] pub mod u32;

Diff for: src/test/compile-fail/issue-8460-const.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::{int, i8, i16, i32, i64};
11+
use std::{isize, i8, i16, i32, i64};
1212
use std::thread;
1313

1414
fn main() {
15-
assert!(thread::spawn(move|| { int::MIN / -1; }).join().is_err());
15+
assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
1616
//~^ ERROR attempted to divide with overflow in a constant expression
1717
assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
1818
//~^ ERROR attempted to divide with overflow in a constant expression
@@ -32,7 +32,7 @@ fn main() {
3232
//~^ ERROR attempted to divide by zero in a constant expression
3333
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
3434
//~^ ERROR attempted to divide by zero in a constant expression
35-
assert!(thread::spawn(move|| { int::MIN % -1; }).join().is_err());
35+
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
3636
//~^ ERROR attempted remainder with overflow in a constant expression
3737
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
3838
//~^ ERROR attempted remainder with overflow in a constant expression

Diff for: src/test/compile-fail/unnecessary-private.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
pub use std::uint; //~ ERROR: visibility has no effect
12+
pub use std::usize; //~ ERROR: visibility has no effect
1313
pub struct A; //~ ERROR: visibility has no effect
1414
pub enum B {} //~ ERROR: visibility has no effect
1515
pub trait C { //~ ERROR: visibility has no effect

Diff for: src/test/run-fail/bounds-check-no-overflow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
// error-pattern:index out of bounds: the len is 3 but the index is
1212

13-
use std::uint;
13+
use std::usize;
1414
use std::mem::size_of;
1515

1616
fn main() {
1717
let xs = [1, 2, 3];
18-
xs[uint::MAX / size_of::<int>() + 1];
18+
xs[usize::MAX / size_of::<isize>() + 1];
1919
}

Diff for: src/test/run-fail/hashmap-capacity-overflow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
// error-pattern:capacity overflow
1212

1313
use std::collections::hash_map::HashMap;
14-
use std::uint;
14+
use std::usize;
1515
use std::mem::size_of;
1616

1717
fn main() {
18-
let threshold = uint::MAX / size_of::<(u64, u64, u64)>();
18+
let threshold = usize::MAX / size_of::<(u64, u64, u64)>();
1919
let mut h = HashMap::<u64, u64>::with_capacity(threshold + 100);
2020
h.insert(0, 0);
2121
}

0 commit comments

Comments
 (0)