diff options
| author | Lindsey Kuper <lindsey@rockstargirl.org> | 2012-06-21 13:25:25 -0700 |
|---|---|---|
| committer | Lindsey Kuper <lindsey@rockstargirl.org> | 2012-06-21 16:19:04 -0700 |
| commit | abfa8164cd9d64e95039019eb9b4c3fdec2685c5 (patch) | |
| tree | fa581e4cc055b00bed791c70f2a074a6a3ba9709 /src | |
| parent | 317864672df72a0cb33209f78506bedb99d16223 (diff) | |
| download | rust-abfa8164cd9d64e95039019eb9b4c3fdec2685c5.tar.gz rust-abfa8164cd9d64e95039019eb9b4c3fdec2685c5.zip | |
Change the level of forcing in structurally_resolved_type().
A cleaner way to handle suffix inference for unary minus exprs.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rustc/middle/typeck/check.rs | 13 | ||||
| -rw-r--r-- | src/rustc/middle/typeck/infer.rs | 14 |
2 files changed, 10 insertions, 17 deletions
diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 16834c37919..e3f6ba40aef 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -74,7 +74,7 @@ import rscope::{anon_rscope, binding_rscope, empty_rscope, in_anon_rscope}; 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_with_unifier(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 2a1f1360487..d545702048f 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -197,7 +197,7 @@ export fixup_err, fixup_err_to_str; 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 @@ impl methods for resolve_state { { 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 @@ impl methods for resolve_state { 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 @@ impl methods for resolve_state { nde.rank)); ty } - force_none { + force_none | force_ty_vars_only { ty::mk_var_integral(self.infcx.tcx, vid) } } |
