]> git.lizzy.rs Git - rust.git/commitdiff
Enable integer literal suffix inference.
authorLindsey Kuper <lindsey@rockstargirl.org>
Wed, 20 Jun 2012 00:06:05 +0000 (17:06 -0700)
committerLindsey Kuper <lindsey@rockstargirl.org>
Wed, 20 Jun 2012 00:06:05 +0000 (17:06 -0700)
src/rustc/middle/typeck/check.rs
src/test/compile-fail/integer-literal-suffix-inference.rs
src/test/run-pass/inferred-suffix-in-pattern-range.rs [new file with mode: 0644]
src/test/run-pass/integer-literal-suffix-inference.rs

index 9b9b92e1e01153bfdd2530fa0b14bea8cf748d18..14b7e847a2a36270b5a7f1e107e934eb129f8322 100644 (file)
@@ -626,10 +626,7 @@ fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t {
       ast::lit_int_unsuffixed(_) {
         // An unsuffixed integer literal could have any integral type,
         // so we create an integral type variable for it.
-        ty::mk_var_integral(tcx, fcx.infcx.next_ty_var_integral_id());
-
-        // FIXME: remove me when #1425 is finished.
-        ty::mk_mach_int(tcx, ty_i)
+        ty::mk_var_integral(tcx, fcx.infcx.next_ty_var_integral_id())
       }
       ast::lit_float(_, t) { ty::mk_mach_float(tcx, t) }
       ast::lit_nil { ty::mk_nil(tcx) }
index 2e868e160fae02eb17e1eff1d8c457b087c31042..96c7983c2baf21809b4cdf5cc9b061efacc0404a 100644 (file)
@@ -1,4 +1,3 @@
-// xfail-test
 fn main() {
 
     // the smallest positive values that need these types
diff --git a/src/test/run-pass/inferred-suffix-in-pattern-range.rs b/src/test/run-pass/inferred-suffix-in-pattern-range.rs
new file mode 100644 (file)
index 0000000..d0647dd
--- /dev/null
@@ -0,0 +1,22 @@
+fn main() {
+    let x = 2;
+    let x_message = alt x {
+      0 to 1     { "not many" }
+      _          { "lots" }
+    };
+    assert x_message == "lots";
+
+    let y = 2i;
+    let y_message = alt y {
+      0 to 1     { "not many" }
+      _          { "lots" }
+    };
+    assert y_message == "lots";
+
+    let z = 1u64;
+    let z_message = alt z {
+      0 to 1     { "not many" }
+      _          { "lots" }
+    };
+    assert z_message == "not many";
+}
index cc3b4cb150f807b628a57935a1213705a68a2ea9..8fd51180477f05cbeaa2287556127226d41b058e 100644 (file)
@@ -1,4 +1,3 @@
-// xfail-test
 fn main() {
 
     // The commented-out lines are ones that fail currently.  I'm