about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/lint.rs6
-rw-r--r--src/libstd/ebml.rs2
-rw-r--r--src/test/run-pass/issue-6130.rs20
3 files changed, 25 insertions, 3 deletions
diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs
index aecbcb626e9..591b196bd6f 100644
--- a/src/librustc/middle/lint.rs
+++ b/src/librustc/middle/lint.rs
@@ -551,9 +551,11 @@ fn lint_type_limits(cx: @mut Context) -> visit::vt<()> {
         }
     }
 
+    // for int & uint, be conservative with the warnings, so that the
+    // 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 =>    (int::min_value as i64, int::max_value as i64),
+            ast::ty_i =>    (i64::min_value,        i64::max_value),
             ast::ty_char => (u32::min_value as i64, u32::max_value as i64),
             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),
@@ -564,7 +566,7 @@ fn lint_type_limits(cx: @mut Context) -> visit::vt<()> {
 
     fn uint_ty_range(uint_ty: ast::uint_ty) -> (u64, u64) {
         match uint_ty {
-            ast::ty_u =>   (uint::min_value as u64, uint::max_value as u64),
+            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),
diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs
index 07c1c226d1f..64f78d5ab7b 100644
--- a/src/libstd/ebml.rs
+++ b/src/libstd/ebml.rs
@@ -779,7 +779,7 @@ pub mod writer {
     priv impl Encoder {
         // used internally to emit things like the vector length and so on
         fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) {
-            assert!(v <= 0xFFFF_FFFF_u); // FIXME(#6130) assert warns on 32-bit
+            assert!(v <= 0xFFFF_FFFF_u);
             self.wr_tagged_u32(t as uint, v as u32);
         }
 
diff --git a/src/test/run-pass/issue-6130.rs b/src/test/run-pass/issue-6130.rs
new file mode 100644
index 00000000000..642308c0ca1
--- /dev/null
+++ b/src/test/run-pass/issue-6130.rs
@@ -0,0 +1,20 @@
+// Copyright 2013 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.
+
+#[deny(type_limits)];
+
+fn main() {
+    let i: uint = 0;
+    assert!(i <= 0xFFFF_FFFF_u);
+
+    let i: int = 0;
+    assert!(i >= -0x8000_0000_i);
+    assert!(i <= 0x7FFF_FFFF_i);
+}