Skip to content

capitalized std::int::min_value, max_value #10010 #10075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libextra/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ pub mod reader {
fn read_u8 (&mut self) -> u8 { doc_as_u8 (self.next_doc(EsU8 )) }
fn read_uint(&mut self) -> uint {
let v = doc_as_u64(self.next_doc(EsUint));
if v > (::std::uint::max_value as u64) {
if v > (::std::uint::MAX_VALUE as u64) {
fail!("uint {} too large for this architecture", v);
}
v as uint
Expand All @@ -397,7 +397,7 @@ pub mod reader {
}
fn read_int(&mut self) -> int {
let v = doc_as_u64(self.next_doc(EsInt)) as i64;
if v > (int::max_value as i64) || v < (int::min_value as i64) {
if v > (int::MAX_VALUE as i64) || v < (int::MIN_VALUE as i64) {
debug!("FIXME \\#6122: Removing this makes this function miscompile");
fail!("int {} out of range for this architecture", v);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/getopts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ pub mod groups {
t("hello", 15, [~"hello"]);
t("\nMary had a little lamb\nLittle lamb\n", 15,
[~"Mary had a", ~"little lamb", ~"Little lamb"]);
t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::max_value,
t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::MAX_VALUE,
[~"Mary had a little lamb\nLittle lamb"]);
}
} // end groups module
Expand Down
42 changes: 21 additions & 21 deletions src/libextra/num/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ impl ToPrimitive for BigInt {
if n < m {
Some(-(n as i64))
} else if n == m {
Some(i64::min_value)
Some(i64::MIN_VALUE)
} else {
None
}
Expand All @@ -1214,7 +1214,7 @@ impl FromPrimitive for BigInt {
Some(BigInt::from_biguint(Plus, n))
}
} else if n < 0 {
do FromPrimitive::from_u64(u64::max_value - (n as u64) + 1).and_then |n| {
do FromPrimitive::from_u64(u64::MAX_VALUE - (n as u64) + 1).and_then |n| {
Some(BigInt::from_biguint(Minus, n))
}
} else {
Expand Down Expand Up @@ -1624,7 +1624,7 @@ mod biguint_tests {

check(Zero::zero(), 0);
check(One::one(), 1);
check(i64::max_value.to_biguint().unwrap(), i64::max_value);
check(i64::MAX_VALUE.to_biguint().unwrap(), i64::MAX_VALUE);

check(BigUint::new(~[ ]), 0);
check(BigUint::new(~[ 1 ]), (1 << (0*BigDigit::bits)));
Expand All @@ -1634,9 +1634,9 @@ mod biguint_tests {
check(BigUint::new(~[ 0, 0, 1 ]), (1 << (2*BigDigit::bits)));
check(BigUint::new(~[-1, -1, -1 ]), (1 << (3*BigDigit::bits)) - 1);
check(BigUint::new(~[ 0, 0, 0, 1 ]), (1 << (3*BigDigit::bits)));
check(BigUint::new(~[-1, -1, -1, -1 >> 1]), i64::max_value);
check(BigUint::new(~[-1, -1, -1, -1 >> 1]), i64::MAX_VALUE);

assert_eq!(i64::min_value.to_biguint(), None);
assert_eq!(i64::MIN_VALUE.to_biguint(), None);
assert_eq!(BigUint::new(~[-1, -1, -1, -1 ]).to_i64(), None);
assert_eq!(BigUint::new(~[ 0, 0, 0, 0, 1]).to_i64(), None);
assert_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_i64(), None);
Expand All @@ -1653,15 +1653,15 @@ mod biguint_tests {

check(Zero::zero(), 0);
check(One::one(), 1);
check(i64::max_value.to_biguint().unwrap(), i64::max_value);
check(i64::MAX_VALUE.to_biguint().unwrap(), i64::MAX_VALUE);

check(BigUint::new(~[ ]), 0);
check(BigUint::new(~[ 1 ]), (1 << (0*BigDigit::bits)));
check(BigUint::new(~[-1 ]), (1 << (1*BigDigit::bits)) - 1);
check(BigUint::new(~[ 0, 1 ]), (1 << (1*BigDigit::bits)));
check(BigUint::new(~[-1, -1 >> 1]), i64::max_value);
check(BigUint::new(~[-1, -1 >> 1]), i64::MAX_VALUE);

assert_eq!(i64::min_value.to_biguint(), None);
assert_eq!(i64::MIN_VALUE.to_biguint(), None);
assert_eq!(BigUint::new(~[-1, -1 ]).to_i64(), None);
assert_eq!(BigUint::new(~[ 0, 0, 1]).to_i64(), None);
assert_eq!(BigUint::new(~[-1, -1, -1]).to_i64(), None);
Expand All @@ -1678,8 +1678,8 @@ mod biguint_tests {

check(Zero::zero(), 0);
check(One::one(), 1);
check(u64::min_value.to_biguint().unwrap(), u64::min_value);
check(u64::max_value.to_biguint().unwrap(), u64::max_value);
check(u64::MIN_VALUE.to_biguint().unwrap(), u64::MIN_VALUE);
check(u64::MAX_VALUE.to_biguint().unwrap(), u64::MAX_VALUE);

check(BigUint::new(~[ ]), 0);
check(BigUint::new(~[ 1 ]), (1 << (0*BigDigit::bits)));
Expand All @@ -1689,7 +1689,7 @@ mod biguint_tests {
check(BigUint::new(~[ 0, 0, 1 ]), (1 << (2*BigDigit::bits)));
check(BigUint::new(~[-1, -1, -1 ]), (1 << (3*BigDigit::bits)) - 1);
check(BigUint::new(~[ 0, 0, 0, 1]), (1 << (3*BigDigit::bits)));
check(BigUint::new(~[-1, -1, -1, -1]), u64::max_value);
check(BigUint::new(~[-1, -1, -1, -1]), u64::MAX_VALUE);

assert_eq!(BigUint::new(~[ 0, 0, 0, 0, 1]).to_u64(), None);
assert_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_u64(), None);
Expand All @@ -1706,14 +1706,14 @@ mod biguint_tests {

check(Zero::zero(), 0);
check(One::one(), 1);
check(u64::min_value.to_biguint().unwrap(), u64::min_value);
check(u64::max_value.to_biguint().unwrap(), u64::max_value);
check(u64::MIN_VALUE.to_biguint().unwrap(), u64::MIN_VALUE);
check(u64::MAX_VALUE.to_biguint().unwrap(), u64::MAX_VALUE);

check(BigUint::new(~[ ]), 0);
check(BigUint::new(~[ 1 ]), (1 << (0*BigDigit::bits)));
check(BigUint::new(~[-1 ]), (1 << (1*BigDigit::bits)) - 1);
check(BigUint::new(~[ 0, 1]), (1 << (1*BigDigit::bits)));
check(BigUint::new(~[-1, -1]), u64::max_value);
check(BigUint::new(~[-1, -1]), u64::MAX_VALUE);

assert_eq!(BigUint::new(~[ 0, 0, 1]).to_u64(), None);
assert_eq!(BigUint::new(~[-1, -1, -1]).to_u64(), None);
Expand Down Expand Up @@ -2164,11 +2164,11 @@ mod bigint_tests {

check(Zero::zero(), 0);
check(One::one(), 1);
check(i64::min_value.to_bigint().unwrap(), i64::min_value);
check(i64::max_value.to_bigint().unwrap(), i64::max_value);
check(i64::MIN_VALUE.to_bigint().unwrap(), i64::MIN_VALUE);
check(i64::MAX_VALUE.to_bigint().unwrap(), i64::MAX_VALUE);

assert_eq!(
(i64::max_value as u64 + 1).to_bigint().unwrap().to_i64(),
(i64::MAX_VALUE as u64 + 1).to_bigint().unwrap().to_i64(),
None);

assert_eq!(
Expand All @@ -2194,15 +2194,15 @@ mod bigint_tests {

check(Zero::zero(), 0);
check(One::one(), 1);
check(u64::min_value.to_bigint().unwrap(), u64::min_value);
check(u64::max_value.to_bigint().unwrap(), u64::max_value);
check(u64::MIN_VALUE.to_bigint().unwrap(), u64::MIN_VALUE);
check(u64::MAX_VALUE.to_bigint().unwrap(), u64::MAX_VALUE);

assert_eq!(
BigInt::from_biguint(Plus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(),
None);

let max_value: BigUint = FromPrimitive::from_u64(u64::max_value).unwrap();
assert_eq!(BigInt::from_biguint(Minus, max_value).to_u64(), None);
let MAX_VALUE: BigUint = FromPrimitive::from_u64(u64::MAX_VALUE).unwrap();
assert_eq!(BigInt::from_biguint(Minus, MAX_VALUE).to_u64(), None);
assert_eq!(BigInt::from_biguint(Minus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(), None);
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl Session_ {
pub fn reserve_node_ids(&self, count: uint) -> ast::NodeId {
let v = *self.node_id;
*self.node_id += count;
if v > (int::max_value as uint) {
if v > (int::MAX_VALUE as uint) {
self.bug("Input too large, ran out of node ids!");
}
v as int
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/move_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ impl Clone for MovePathIndex {
}

static InvalidMovePathIndex: MovePathIndex =
MovePathIndex(uint::max_value);
MovePathIndex(uint::MAX_VALUE);

/// Index into `MoveData.moves`, used like a pointer
#[deriving(Eq)]
pub struct MoveIndex(uint);

static InvalidMoveIndex: MoveIndex =
MoveIndex(uint::max_value);
MoveIndex(uint::MAX_VALUE);

pub struct MovePath {
/// Loan path corresponding to this move path
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl<O:DataFlowOperator> DataFlowContext<O> {
len
};
if expanded {
let entry = if self.oper.initial_value() { uint::max_value } else {0};
let entry = if self.oper.initial_value() { uint::MAX_VALUE } else {0};
do self.words_per_id.times {
self.gens.push(0);
self.kills.push(0);
Expand Down Expand Up @@ -905,7 +905,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
}

fn reset(&mut self, bits: &mut [uint]) {
let e = if self.dfcx.oper.initial_value() {uint::max_value} else {0};
let e = if self.dfcx.oper.initial_value() {uint::MAX_VALUE} else {0};
for b in bits.mut_iter() { *b = e; }
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ pub struct Edge<E> {

#[deriving(Eq)]
pub struct NodeIndex(uint);
pub static InvalidNodeIndex: NodeIndex = NodeIndex(uint::max_value);
pub static InvalidNodeIndex: NodeIndex = NodeIndex(uint::MAX_VALUE);

#[deriving(Eq)]
pub struct EdgeIndex(uint);
pub static InvalidEdgeIndex: EdgeIndex = EdgeIndex(uint::max_value);
pub static InvalidEdgeIndex: EdgeIndex = EdgeIndex(uint::MAX_VALUE);

// Use a private field here to guarantee no more instances are created:
pub struct Direction { priv repr: uint }
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,21 +537,21 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) {
// warnings are consistent between 32- and 64-bit platforms
fn int_ty_range(int_ty: ast::int_ty) -> (i64, i64) {
match int_ty {
ast::ty_i => (i64::min_value, i64::max_value),
ast::ty_i8 => (i8::min_value as i64, i8::max_value as i64),
ast::ty_i16 => (i16::min_value as i64, i16::max_value as i64),
ast::ty_i32 => (i32::min_value as i64, i32::max_value as i64),
ast::ty_i64 => (i64::min_value, i64::max_value)
ast::ty_i => (i64::MIN_VALUE, i64::MAX_VALUE),
ast::ty_i8 => (i8::MIN_VALUE as i64, i8::MAX_VALUE as i64),
ast::ty_i16 => (i16::MIN_VALUE as i64, i16::MAX_VALUE as i64),
ast::ty_i32 => (i32::MIN_VALUE as i64, i32::MAX_VALUE as i64),
ast::ty_i64 => (i64::MIN_VALUE, i64::MAX_VALUE)
}
}

fn uint_ty_range(uint_ty: ast::uint_ty) -> (u64, u64) {
match uint_ty {
ast::ty_u => (u64::min_value, u64::max_value),
ast::ty_u8 => (u8::min_value as u64, u8::max_value as u64),
ast::ty_u16 => (u16::min_value as u64, u16::max_value as u64),
ast::ty_u32 => (u32::min_value as u64, u32::max_value as u64),
ast::ty_u64 => (u64::min_value, u64::max_value)
ast::ty_u => (u64::MIN_VALUE, u64::MAX_VALUE),
ast::ty_u8 => (u8::MIN_VALUE as u64, u8::MAX_VALUE as u64),
ast::ty_u16 => (u16::MIN_VALUE as u64, u16::MAX_VALUE as u64),
ast::ty_u32 => (u32::MIN_VALUE as u64, u32::MAX_VALUE as u64),
ast::ty_u64 => (u64::MIN_VALUE, u64::MAX_VALUE)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ impl to_str::ToStr for Variable {

impl LiveNode {
pub fn is_valid(&self) -> bool {
**self != uint::max_value
**self != uint::MAX_VALUE
}
}

fn invalid_node() -> LiveNode { LiveNode(uint::max_value) }
fn invalid_node() -> LiveNode { LiveNode(uint::MAX_VALUE) }

struct CaptureInfo {
ln: LiveNode,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4943,7 +4943,7 @@ impl Resolver {
j -= 1;
for (&k, _) in this.value_ribs[j].bindings.iter() {
maybes.push(interner_get(k));
values.push(uint::max_value);
values.push(uint::MAX_VALUE);
}
}

Expand All @@ -4957,7 +4957,7 @@ impl Resolver {
}

if values.len() > 0 &&
values[smallest] != uint::max_value &&
values[smallest] != uint::MAX_VALUE &&
values[smallest] < name.len() + 2 &&
values[smallest] <= max_distance &&
name != maybes[smallest] {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/datum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ impl Datum {
// either we were asked to deref a specific number of times,
// in which case we should have, or we asked to deref as many
// times as we can
assert!(derefs == max || max == uint::max_value);
assert!(derefs == max || max == uint::MAX_VALUE);
DatumBlock { bcx: bcx, datum: datum }
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/typeck/infer/region_inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ impl RegionVarBindings {
// idea is to report errors that derive from independent
// regions of the graph, but not those that derive from
// overlapping locations.
let mut dup_vec = vec::from_elem(self.num_vars(), uint::max_value);
let mut dup_vec = vec::from_elem(self.num_vars(), uint::MAX_VALUE);

let mut opt_graph = None;

Expand Down Expand Up @@ -1196,7 +1196,7 @@ impl RegionVarBindings {
let classification = var_data[node_idx.to_uint()].classification;

// check whether we've visited this node on some previous walk
if dup_vec[node_idx.to_uint()] == uint::max_value {
if dup_vec[node_idx.to_uint()] == uint::MAX_VALUE {
dup_vec[node_idx.to_uint()] = orig_node_idx.to_uint();
} else if dup_vec[node_idx.to_uint()] != orig_node_idx.to_uint() {
state.dup_found = true;
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ pub fn unindent(s: &str) -> ~str {
let lines = s.any_line_iter().collect::<~[&str]>();
let mut saw_first_line = false;
let mut saw_second_line = false;
let min_indent = do lines.iter().fold(uint::max_value) |min_indent, line| {
let min_indent = do lines.iter().fold(uint::MAX_VALUE) |min_indent, line| {

// After we see the first non-whitespace line, look at
// the line we have. If it is not whitespace, and therefore
Expand All @@ -280,7 +280,7 @@ pub fn unindent(s: &str) -> ~str {
!line.is_whitespace();

let min_indent = if ignore_previous_indents {
uint::max_value
uint::MAX_VALUE
} else {
min_indent
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ mod tests {
#[test]
#[should_fail]
fn test_add_bytes_to_bits_overflow() {
add_bytes_to_bits::<u64>(Bounded::max_value(), 1);
add_bytes_to_bits::<u64>(Bounded::MAX_VALUE(), 1);
}
}

Expand Down
Loading