Skip to content

Commit

Permalink
Enable integer literal suffix inference.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkuper committed Jun 20, 2012
1 parent b1fa824 commit 3cf582b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/rustc/middle/typeck/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/integer-literal-suffix-inference.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// xfail-test
fn main() {

// the smallest positive values that need these types
Expand Down
22 changes: 22 additions & 0 deletions src/test/run-pass/inferred-suffix-in-pattern-range.rs
Original file line number Diff line number Diff line change
@@ -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";
}
1 change: 0 additions & 1 deletion src/test/run-pass/integer-literal-suffix-inference.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// xfail-test
fn main() {

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

1 comment on commit 3cf582b

@nikomatsakis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulations!

Please sign in to comment.