Enable integer literal suffix inference.

This commit is contained in:
Lindsey Kuper 2012-06-19 17:06:05 -07:00
parent b1fa8249f1
commit 3cf582b529
4 changed files with 23 additions and 6 deletions

View 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) }

View File

@ -1,4 +1,3 @@
// xfail-test
fn main() {
// the smallest positive values that need these types

View File

@ -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";
}

View File

@ -1,4 +1,3 @@
// xfail-test
fn main() {
// The commented-out lines are ones that fail currently. I'm