Skip to content

Commit 3cf582b

Browse files
committed
Enable integer literal suffix inference.
1 parent b1fa824 commit 3cf582b

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/rustc/middle/typeck/check.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,7 @@ fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t {
626626
ast::lit_int_unsuffixed(_) {
627627
// An unsuffixed integer literal could have any integral type,
628628
// so we create an integral type variable for it.
629-
ty::mk_var_integral(tcx, fcx.infcx.next_ty_var_integral_id());
630-
631-
// FIXME: remove me when #1425 is finished.
632-
ty::mk_mach_int(tcx, ty_i)
629+
ty::mk_var_integral(tcx, fcx.infcx.next_ty_var_integral_id())
633630
}
634631
ast::lit_float(_, t) { ty::mk_mach_float(tcx, t) }
635632
ast::lit_nil { ty::mk_nil(tcx) }

src/test/compile-fail/integer-literal-suffix-inference.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-test
21
fn main() {
32

43
// the smallest positive values that need these types
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fn main() {
2+
let x = 2;
3+
let x_message = alt x {
4+
0 to 1 { "not many" }
5+
_ { "lots" }
6+
};
7+
assert x_message == "lots";
8+
9+
let y = 2i;
10+
let y_message = alt y {
11+
0 to 1 { "not many" }
12+
_ { "lots" }
13+
};
14+
assert y_message == "lots";
15+
16+
let z = 1u64;
17+
let z_message = alt z {
18+
0 to 1 { "not many" }
19+
_ { "lots" }
20+
};
21+
assert z_message == "not many";
22+
}

src/test/run-pass/integer-literal-suffix-inference.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-test
21
fn main() {
32

43
// The commented-out lines are ones that fail currently. I'm

0 commit comments

Comments
 (0)