diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 04d3c4f90c5..b126e5c55ff 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -1198,7 +1198,14 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } } ast::neg { - oprnd_t = structurally_resolved_type(fcx, oprnd.span, oprnd_t); + // If the operand's type is an integral type variable, we + // don't want to resolve it yet, because the rest of the + // typing context might not have had the opportunity to + // constrain it yet. + if !(ty::type_is_var_integral(oprnd_t)) { + oprnd_t = structurally_resolved_type(fcx, oprnd.span, + oprnd_t); + } if !(ty::type_is_integral(oprnd_t) || ty::type_is_fp(oprnd_t)) { oprnd_t = check_user_unop(fcx, "-", "unary-", expr, diff --git a/src/test/run-pass/integer-literal-suffix-inference.rs b/src/test/run-pass/integer-literal-suffix-inference.rs index 8fd51180477..5d157658aa1 100644 --- a/src/test/run-pass/integer-literal-suffix-inference.rs +++ b/src/test/run-pass/integer-literal-suffix-inference.rs @@ -16,22 +16,22 @@ fn main() { let _i: i8 = -128; let j = -128; - // id_i8(j); + id_i8(j); id_i8(-128); let _i: i16 = -32_768; let j = -32_768; - // id_i16(j); + id_i16(j); id_i16(-32_768); let _i: i32 = -2_147_483_648; let j = -2_147_483_648; - // id_i32(j); + id_i32(j); id_i32(-2_147_483_648); let _i: i64 = -9_223_372_036_854_775_808; let j = -9_223_372_036_854_775_808; - // id_i64(j); + id_i64(j); id_i64(-9_223_372_036_854_775_808); let _i: uint = 1;