diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 16834c379190f90055e17029ab81df4ec7c6ea85..e3f6ba40aefda3fabec4088d0c87f680d5c95ff8 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -74,7 +74,7 @@ import rscope::{in_binding_rscope, region_scope, type_rscope}; import syntax::ast::ty_i; import typeck::infer::{unify_methods}; // infcx.set() -import typeck::infer::{force_level, force_none, force_non_region_vars_only, +import typeck::infer::{force_level, force_none, force_ty_vars_only, force_all}; type fn_ctxt = @@ -1174,14 +1174,7 @@ fn check_expr_fn(fcx: @fn_ctxt, } } ast::neg { - // 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); - } + 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, @@ -2116,7 +2109,7 @@ fn instantiate_path(fcx: @fn_ctxt, // resolution is possible, then an error is reported. fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t { alt infer::resolve_shallow(fcx.infcx, tp, - force_non_region_vars_only) { + force_ty_vars_only) { result::ok(t_s) if !ty::type_is_var(t_s) { ret t_s; } _ { fcx.ccx.tcx.sess.span_fatal diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index 2a1f136048703ae0dd354dafa97c41c4886dd08c..d545702048fd10989c16ee2a500fec54bbfad3a5 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -197,7 +197,7 @@ fn bar() { export assignment; export root, to_str; export int_ty_set_all; -export force_level, force_none, force_non_region_vars_only, force_all; +export force_level, force_none, force_ty_vars_only, force_all; // Bitvector to represent sets of integral types enum int_ty_set = uint; @@ -1093,9 +1093,9 @@ enum force_level { // Any unconstrained variables are OK. force_none, - // Unconstrained region vars are OK; unconstrained ty vars and - // integral ty vars result in an error. - force_non_region_vars_only, + // Unconstrained region vars and integral ty vars are OK; + // unconstrained general-purpose ty vars result in an error. + force_ty_vars_only, // Any unconstrained variables result in an error. force_all, @@ -1237,7 +1237,7 @@ fn resolve_ty_var(vid: tv_vid) -> ty::t { { ub:_, lb:some(t) } { self.resolve1(t) } { ub:none, lb:none } { alt self.force_vars { - force_non_region_vars_only | force_all { + force_ty_vars_only | force_all { self.err = some(unresolved_ty(vid)); } force_none { /* ok */ } @@ -1260,7 +1260,7 @@ fn resolve_ty_var_integral(vid: tvi_vid) -> ty::t { some(t) { t } none { alt self.force_vars { - force_non_region_vars_only | force_all { + force_all { // As a last resort, default to int. let ty = ty::mk_int(self.infcx.tcx); self.infcx.set( @@ -1270,7 +1270,7 @@ fn resolve_ty_var_integral(vid: tvi_vid) -> ty::t { nde.rank)); ty } - force_none { + force_none | force_ty_vars_only { ty::mk_var_integral(self.infcx.tcx, vid) } }