提交 df126589 编写于 作者: G Guillaume Gomez

Remove int/uint from libstd/lib.rs

上级 c74d49c8
......@@ -12,7 +12,7 @@
use core::iter::order::*;
use core::iter::MinMaxResult::*;
use core::num::SignedInt;
use core::uint;
use core::usize;
use core::cmp;
use test::Bencher;
......@@ -292,7 +292,7 @@ fn count(st: &mut uint) -> Option<uint> {
fn test_cycle() {
let cycle_len = 3;
let it = count(0, 1).take(cycle_len).cycle();
assert_eq!(it.size_hint(), (uint::MAX, None));
assert_eq!(it.size_hint(), (usize::MAX, None));
for (i, x) in it.take(100).enumerate() {
assert_eq!(i % cycle_len, x);
}
......@@ -365,19 +365,19 @@ fn test_iterator_size_hint() {
let v2 = &[10, 11, 12];
let vi = v.iter();
assert_eq!(c.size_hint(), (uint::MAX, None));
assert_eq!(c.size_hint(), (usize::MAX, None));
assert_eq!(vi.clone().size_hint(), (10, Some(10)));
assert_eq!(c.clone().take(5).size_hint(), (5, Some(5)));
assert_eq!(c.clone().skip(5).size_hint().1, None);
assert_eq!(c.clone().take_while(|_| false).size_hint(), (0, None));
assert_eq!(c.clone().skip_while(|_| false).size_hint(), (0, None));
assert_eq!(c.clone().enumerate().size_hint(), (uint::MAX, None));
assert_eq!(c.clone().chain(vi.clone().cloned()).size_hint(), (uint::MAX, None));
assert_eq!(c.clone().enumerate().size_hint(), (usize::MAX, None));
assert_eq!(c.clone().chain(vi.clone().cloned()).size_hint(), (usize::MAX, None));
assert_eq!(c.clone().zip(vi.clone()).size_hint(), (10, Some(10)));
assert_eq!(c.clone().scan(0, |_,_| Some(0)).size_hint(), (0, None));
assert_eq!(c.clone().filter(|_| false).size_hint(), (0, None));
assert_eq!(c.clone().map(|_| 0).size_hint(), (uint::MAX, None));
assert_eq!(c.clone().map(|_| 0).size_hint(), (usize::MAX, None));
assert_eq!(c.filter_map(|_| Some(0)).size_hint(), (0, None));
assert_eq!(vi.clone().take(5).size_hint(), (5, Some(5)));
......@@ -753,7 +753,7 @@ fn test_range() {
assert_eq!((0..100).size_hint(), (100, Some(100)));
// this test is only meaningful when sizeof uint < sizeof u64
assert_eq!((uint::MAX - 1..uint::MAX).size_hint(), (1, Some(1)));
assert_eq!((usize::MAX - 1..usize::MAX).size_hint(), (1, Some(1)));
assert_eq!((-10..-1).size_hint(), (9, Some(9)));
assert_eq!((-1..-10).size_hint(), (0, Some(0)));
}
......
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
int_module!(int, int);
......@@ -12,7 +12,7 @@
#[cfg(test)]
mod tests {
use core::$T_i::*;
use core::int;
use core::isize;
use core::num::{FromStrRadix, Int, SignedInt};
use core::ops::{Shl, Shr, Not, BitXor, BitAnd, BitOr};
use num;
......@@ -153,7 +153,7 @@ fn test_be() {
fn test_signed_checked_div() {
assert!(10.checked_div(2) == Some(5));
assert!(5.checked_div(0) == None);
assert!(int::MIN.checked_div(-1) == None);
assert!(isize::MIN.checked_div(-1) == None);
}
#[test]
......
......@@ -21,7 +21,6 @@
mod i16;
mod i32;
mod i64;
mod int;
#[macro_use]
mod uint_macros;
......@@ -30,7 +29,6 @@
mod u16;
mod u32;
mod u64;
mod uint;
/// Helper function for testing numeric operations
pub fn test_num<T>(ten: T, two: T) where
......
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
uint_module!(uint, uint);
......@@ -963,7 +963,7 @@ fn t(s: &str, i: uint, u: &[String]) {
"little lamb".to_string(),
"Little lamb".to_string()
]);
t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::MAX,
t("\nMary had a little lamb\nLittle lamb\n", ::std::usize::MAX,
&["Mary had a little lamb\nLittle lamb".to_string()]);
}
......
......@@ -51,8 +51,8 @@
//! enclosing function. On the way down the tree, it identifies those AST
//! nodes and variable IDs that will be needed for the liveness analysis
//! and assigns them contiguous IDs. The liveness id for an AST node is
//! called a `live_node` (it's a newtype'd uint) and the id for a variable
//! is called a `variable` (another newtype'd uint).
//! called a `live_node` (it's a newtype'd usize) and the id for a variable
//! is called a `variable` (another newtype'd usize).
//!
//! On the way back up the tree, as we are about to exit from a function
//! declaration we allocate a `liveness` instance. Now that we know
......@@ -118,7 +118,7 @@
use lint;
use util::nodemap::NodeMap;
use std::{fmt, old_io, uint};
use std::{fmt, old_io, usize};
use std::rc::Rc;
use std::iter::repeat;
use syntax::ast::{self, NodeId, Expr};
......@@ -138,17 +138,17 @@ enum LoopKind<'a> {
}
#[derive(Copy, PartialEq)]
struct Variable(uint);
struct Variable(usize);
#[derive(Copy, PartialEq)]
struct LiveNode(uint);
struct LiveNode(usize);
impl Variable {
fn get(&self) -> uint { let Variable(v) = *self; v }
fn get(&self) -> usize { let Variable(v) = *self; v }
}
impl LiveNode {
fn get(&self) -> uint { let LiveNode(v) = *self; v }
fn get(&self) -> usize { let LiveNode(v) = *self; v }
}
impl Clone for LiveNode {
......@@ -232,11 +232,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl LiveNode {
fn is_valid(&self) -> bool {
self.get() != uint::MAX
self.get() != usize::MAX
}
}
fn invalid_node() -> LiveNode { LiveNode(uint::MAX) }
fn invalid_node() -> LiveNode { LiveNode(usize::MAX) }
struct CaptureInfo {
ln: LiveNode,
......@@ -260,8 +260,8 @@ enum VarKind {
struct IrMaps<'a, 'tcx: 'a> {
tcx: &'a ty::ctxt<'tcx>,
num_live_nodes: uint,
num_vars: uint,
num_live_nodes: usize,
num_vars: usize,
live_node_map: NodeMap<LiveNode>,
variable_map: NodeMap<Variable>,
capture_info_map: NodeMap<Rc<Vec<CaptureInfo>>>,
......@@ -540,9 +540,9 @@ struct Specials {
clean_exit_var: Variable
}
static ACC_READ: uint = 1;
static ACC_WRITE: uint = 2;
static ACC_USE: uint = 4;
static ACC_READ: u32 = 1;
static ACC_WRITE: u32 = 2;
static ACC_USE: u32 = 4;
struct Liveness<'a, 'tcx: 'a> {
ir: &'a mut IrMaps<'a, 'tcx>,
......@@ -631,7 +631,7 @@ fn define_bindings_in_arm_pats(&mut self, pat: Option<&ast::Pat>, succ: LiveNode
succ
}
fn idx(&self, ln: LiveNode, var: Variable) -> uint {
fn idx(&self, ln: LiveNode, var: Variable) -> usize {
ln.get() * self.ir.num_vars + var.get()
}
......@@ -670,7 +670,7 @@ fn assigned_on_exit(&self, ln: LiveNode, var: Variable)
}
fn indices2<F>(&mut self, ln: LiveNode, succ_ln: LiveNode, mut op: F) where
F: FnMut(&mut Liveness<'a, 'tcx>, uint, uint),
F: FnMut(&mut Liveness<'a, 'tcx>, usize, usize),
{
let node_base_idx = self.idx(ln, Variable(0));
let succ_base_idx = self.idx(succ_ln, Variable(0));
......@@ -684,7 +684,7 @@ fn write_vars<F>(&self,
ln: LiveNode,
mut test: F)
-> old_io::IoResult<()> where
F: FnMut(uint) -> LiveNode,
F: FnMut(usize) -> LiveNode,
{
let node_base_idx = self.idx(ln, Variable(0));
for var_idx in 0..self.ir.num_vars {
......@@ -807,7 +807,7 @@ fn define(&mut self, writer: LiveNode, var: Variable) {
}
// Either read, write, or both depending on the acc bitset
fn acc(&mut self, ln: LiveNode, var: Variable, acc: uint) {
fn acc(&mut self, ln: LiveNode, var: Variable, acc: u32) {
debug!("{:?} accesses[{:x}] {:?}: {}",
ln, acc, var, self.ln_str(ln));
......@@ -1283,7 +1283,7 @@ fn propagate_through_lvalue_components(&mut self,
}
// see comment on propagate_through_lvalue()
fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: u32)
-> LiveNode {
match expr.node {
ast::ExprPath(..) => {
......@@ -1298,7 +1298,7 @@ fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
}
}
fn access_path(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
fn access_path(&mut self, expr: &Expr, succ: LiveNode, acc: u32)
-> LiveNode {
match self.ir.tcx.def_map.borrow()[expr.id].full_def() {
DefLocal(nid) => {
......
......@@ -789,7 +789,7 @@ fn pat_score(def_map: &DefMap, pat: &ast::Pat) -> uint {
// Irrefutable columns always go first, they'd only be duplicated in the branches.
if total_score == 0 {
std::uint::MAX
std::usize::MAX
} else {
total_score
}
......
......@@ -221,14 +221,12 @@
mod uint_macros;
#[path = "num/isize.rs"] pub mod isize;
pub use isize as int;
#[path = "num/i8.rs"] pub mod i8;
#[path = "num/i16.rs"] pub mod i16;
#[path = "num/i32.rs"] pub mod i32;
#[path = "num/i64.rs"] pub mod i64;
#[path = "num/usize.rs"] pub mod usize;
pub use usize as uint;
#[path = "num/u8.rs"] pub mod u8;
#[path = "num/u16.rs"] pub mod u16;
#[path = "num/u32.rs"] pub mod u32;
......
......@@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::{int, i8, i16, i32, i64};
use std::{isize, i8, i16, i32, i64};
use std::thread;
fn main() {
assert!(thread::spawn(move|| { int::MIN / -1; }).join().is_err());
assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
//~^ ERROR attempted to divide with overflow in a constant expression
assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
//~^ ERROR attempted to divide with overflow in a constant expression
......@@ -32,7 +32,7 @@ fn main() {
//~^ ERROR attempted to divide by zero in a constant expression
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
//~^ ERROR attempted to divide by zero in a constant expression
assert!(thread::spawn(move|| { int::MIN % -1; }).join().is_err());
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
//~^ ERROR attempted remainder with overflow in a constant expression
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
//~^ ERROR attempted remainder with overflow in a constant expression
......
......@@ -9,7 +9,7 @@
// except according to those terms.
fn main() {
pub use std::uint; //~ ERROR: visibility has no effect
pub use std::usize; //~ ERROR: visibility has no effect
pub struct A; //~ ERROR: visibility has no effect
pub enum B {} //~ ERROR: visibility has no effect
pub trait C { //~ ERROR: visibility has no effect
......
......@@ -10,10 +10,10 @@
// error-pattern:index out of bounds: the len is 3 but the index is
use std::uint;
use std::usize;
use std::mem::size_of;
fn main() {
let xs = [1, 2, 3];
xs[uint::MAX / size_of::<int>() + 1];
xs[usize::MAX / size_of::<isize>() + 1];
}
......@@ -11,11 +11,11 @@
// error-pattern:capacity overflow
use std::collections::hash_map::HashMap;
use std::uint;
use std::usize;
use std::mem::size_of;
fn main() {
let threshold = uint::MAX / size_of::<(u64, u64, u64)>();
let threshold = usize::MAX / size_of::<(u64, u64, u64)>();
let mut h = HashMap::<u64, u64>::with_capacity(threshold + 100);
h.insert(0, 0);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册