Skip to content

Commit b3b6c8e

Browse files
committed
---
yaml --- r: 16052 b: refs/heads/try c: 123c5c4 h: refs/heads/master v: v3
1 parent 91de26e commit b3b6c8e

File tree

9 files changed

+36
-45
lines changed

9 files changed

+36
-45
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: f7cb7b06d53b653b3f9cb585f01605d04ea9fc7d
5+
refs/heads/try: 123c5c43151bda6fd28ced76237acd99d9b4e791
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/middle/typeck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import middle::ty;
5353
import middle::ty::{arg, field, node_type_table, mk_nil,
5454
ty_param_bounds_and_ty, lookup_public_fields};
5555
import middle::ty::{ty_vid, region_vid, vid};
56-
import middle::typeck::infer::{ty_and_region_var_methods};
56+
import middle::typeck::infer::methods;
5757
import util::ppaux::{ty_to_str, tys_to_str, region_to_str,
5858
bound_region_to_str, vstore_to_str};
5959
import std::smallintmap;

branches/try/src/rustc/middle/typeck/check.rs

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,6 @@ impl of region_scope for @fn_ctxt {
445445

446446
impl methods for @fn_ctxt {
447447
fn tag() -> str { #fmt["%x", ptr::addr_of(*self) as uint] }
448-
fn ty_to_str(t: ty::t) -> str {
449-
ty_to_str(self.ccx.tcx, resolve_type_vars_if_possible(self, t))
450-
}
451448
fn block_region() -> result<ty::region, str> {
452449
alt vec::last_opt(self.blocks) {
453450
some(bid) { result::ok(ty::re_scope(bid)) }
@@ -521,8 +518,8 @@ impl methods for @fn_ctxt {
521518
self.ccx.tcx.sess.span_err(
522519
sp,
523520
#fmt["mismatched types: expected `%s` but found `%s` (%s)",
524-
self.ty_to_str(e),
525-
self.ty_to_str(a),
521+
self.infcx.ty_to_str(e),
522+
self.infcx.ty_to_str(a),
526523
ty::type_err_to_str(self.ccx.tcx, err)]);
527524
}
528525

@@ -589,13 +586,6 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
589586
};
590587
}
591588

592-
fn resolve_type_vars_if_possible(fcx: @fn_ctxt, typ: ty::t) -> ty::t {
593-
alt infer::resolve_deep(fcx.infcx, typ, false) {
594-
result::ok(new_type) { ret new_type; }
595-
result::err(_) { ret typ; }
596-
}
597-
}
598-
599589
// Returns true if the two types unify and false if they don't.
600590
fn are_compatible(fcx: @fn_ctxt, expected: ty::t, actual: ty::t) -> bool {
601591
alt fcx.mk_eqty(expected, actual) {
@@ -723,7 +713,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
723713
// type with fresh region variables.
724714

725715
#debug["check_call_or_bind: before universal quant., fty=%s",
726-
fcx.ty_to_str(fty)];
716+
fcx.infcx.ty_to_str(fty)];
727717

728718
// This is subtle: we expect `fty` to be a function type, which
729719
// normally introduce a level of binding. In this case, we want to
@@ -745,7 +735,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
745735
};
746736

747737
#debug["check_call_or_bind: after universal quant., fty=%s",
748-
fcx.ty_to_str(fty)];
738+
fcx.infcx.ty_to_str(fty)];
749739

750740
let supplied_arg_count = vec::len(args);
751741

@@ -780,7 +770,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
780770
fcx.ccx.tcx.sess.span_fatal(sp, "mismatched types: \
781771
expected function or native \
782772
function but found "
783-
+ fcx.ty_to_str(fty));
773+
+ fcx.infcx.ty_to_str(fty));
784774
}
785775
};
786776

@@ -1002,7 +992,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1002992
tcx.sess.span_err(
1003993
ex.span, "binary operation " + ast_util::binop_to_str(op) +
1004994
" cannot be applied to type `" +
1005-
fcx.ty_to_str(lhs_resolved_t) +
995+
fcx.infcx.ty_to_str(lhs_resolved_t) +
1006996
"`");
1007997
(lhs_resolved_t, false)
1008998
}
@@ -1013,7 +1003,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
10131003
_ {
10141004
fcx.ccx.tcx.sess.span_err(
10151005
ex.span, #fmt["cannot apply unary operator `%s` to type `%s`",
1016-
op_str, fcx.ty_to_str(rhs_t)]);
1006+
op_str, fcx.infcx.ty_to_str(rhs_t)]);
10171007
rhs_t
10181008
}
10191009
}
@@ -1060,7 +1050,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
10601050
expected_tys));
10611051

10621052
#debug("check_expr_fn_with_unifier %s fty=%s",
1063-
expr_to_str(expr), fcx.ty_to_str(fty));
1053+
expr_to_str(expr), fcx.infcx.ty_to_str(fty));
10641054

10651055
fcx.write_ty(expr.id, fty);
10661056

@@ -1185,7 +1175,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
11851175
tcx.sess.span_fatal(
11861176
expr.span,
11871177
#fmt["type %s cannot be dereferenced",
1188-
fcx.ty_to_str(oper_t)]);
1178+
fcx.infcx.ty_to_str(oper_t)]);
11891179
}
11901180
}
11911181
}
@@ -1428,8 +1418,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
14281418
let t_1 = fcx.to_ty(t);
14291419
let t_e = fcx.expr_ty(e);
14301420

1431-
#debug["t_1=%s", fcx.ty_to_str(t_1)];
1432-
#debug["t_e=%s", fcx.ty_to_str(t_e)];
1421+
#debug["t_1=%s", fcx.infcx.ty_to_str(t_1)];
1422+
#debug["t_e=%s", fcx.infcx.ty_to_str(t_e)];
14331423

14341424
alt ty::get(t_1).struct {
14351425
// This will be looked up later on
@@ -1600,7 +1590,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
16001590
fcx.ccx.method_map.insert(id, origin);
16011591
}
16021592
none {
1603-
let t_err = resolve_type_vars_if_possible(fcx, expr_t);
1593+
let t_err = fcx.infcx.resolve_type_vars_if_possible(expr_t);
16041594
let msg = #fmt["attempted access of field %s on type %s, but \
16051595
no public field or method with that name was found",
16061596
field, ty_to_str(tcx, t_err)];
@@ -1674,7 +1664,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
16741664
}
16751665

16761666
none {
1677-
let t_err = resolve_type_vars_if_possible(fcx, p_ty);
1667+
let t_err = fcx.infcx.resolve_type_vars_if_possible(p_ty);
16781668
let msg = #fmt["no `alloc()` method found for type `%s`",
16791669
ty_to_str(tcx, t_err)];
16801670
tcx.sess.span_err(expr.span, msg);
@@ -1710,7 +1700,7 @@ fn require_integral(fcx: @fn_ctxt, sp: span, t: ty::t) {
17101700
if !type_is_integral(fcx, sp, t) {
17111701
fcx.ccx.tcx.sess.span_err(sp, "mismatched types: expected \
17121702
integral type but found `"
1713-
+ fcx.ty_to_str(t) + "`");
1703+
+ fcx.infcx.ty_to_str(t) + "`");
17141704
}
17151705
}
17161706

branches/try/src/rustc/middle/typeck/check/alt.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import middle::typeck::infer::{ty_and_region_var_methods};
1+
import middle::typeck::infer::methods; // next_ty_var,
2+
// resolve_type_vars_if_possible
23

34
fn check_alt(fcx: @fn_ctxt,
45
expr: @ast::expr,
@@ -113,7 +114,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
113114
tcx.sess.span_fatal
114115
(pat.span,
115116
#fmt["mismatched types: expected enum but found `%s`",
116-
fcx.ty_to_str(expected)]);
117+
fcx.infcx.ty_to_str(expected)]);
117118
}
118119
}
119120
}
@@ -134,12 +135,11 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
134135
ast::pat_range(begin, end) {
135136
check_expr_with(fcx, begin, expected);
136137
check_expr_with(fcx, end, expected);
137-
let b_ty = resolve_type_vars_if_possible(fcx,
138-
fcx.expr_ty(begin));
138+
let b_ty =
139+
fcx.infcx.resolve_type_vars_if_possible(fcx.expr_ty(begin));
139140
if !require_same_types(
140141
tcx, pat.span, b_ty,
141-
resolve_type_vars_if_possible(
142-
fcx, fcx.expr_ty(end)),
142+
fcx.infcx.resolve_type_vars_if_possible(fcx.expr_ty(end)),
143143
{|| "mismatched types in range" }) {
144144
// no-op
145145
} else if !ty::type_is_numeric(b_ty) {
@@ -179,7 +179,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
179179
tcx.sess.span_fatal
180180
(pat.span,
181181
#fmt["mismatched types: expected `%s` but found record",
182-
fcx.ty_to_str(expected)]);
182+
fcx.infcx.ty_to_str(expected)]);
183183
}
184184
};
185185
let f_count = vec::len(fields);
@@ -216,7 +216,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
216216
tcx.sess.span_fatal
217217
(pat.span,
218218
#fmt["mismatched types: expected `%s`, found tuple",
219-
fcx.ty_to_str(expected)]);
219+
fcx.infcx.ty_to_str(expected)]);
220220
}
221221
};
222222
let e_count = vec::len(elts);
@@ -244,7 +244,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
244244
tcx.sess.span_fatal(
245245
pat.span,
246246
"mismatched types: expected `" +
247-
fcx.ty_to_str(expected) +
247+
fcx.infcx.ty_to_str(expected) +
248248
"` found box");
249249
}
250250
}
@@ -259,7 +259,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
259259
tcx.sess.span_fatal(
260260
pat.span,
261261
"mismatched types: expected `" +
262-
fcx.ty_to_str(expected) +
262+
fcx.infcx.ty_to_str(expected) +
263263
"` found uniq");
264264
}
265265
}

branches/try/src/rustc/middle/typeck/check/method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import syntax::ast_map;
44
import regionmanip::universally_quantify_from_sty;
5-
import middle::typeck::infer::{ty_and_region_var_methods};
5+
import middle::typeck::infer::methods; // next_ty_vars
66

77
enum lookup = {
88
fcx: @fn_ctxt,

branches/try/src/rustc/middle/typeck/check/regionmanip.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn universally_quantify_from_sty(fcx: @fn_ctxt,
1212
sty: ty::sty) -> ty::t {
1313

1414
#debug["universally_quantify_from_sty(bound_tys=%?)",
15-
bound_tys.map {|x| fcx.ty_to_str(x) }];
15+
bound_tys.map {|x| fcx.infcx.ty_to_str(x) }];
1616
indent {||
1717
let tcx = fcx.tcx();
1818
let isr = collect_bound_regions_in_tys(tcx, @nil, bound_tys) { |br|
@@ -25,7 +25,8 @@ fn universally_quantify_from_sty(fcx: @fn_ctxt,
2525
let t_res = ty::fold_sty_to_ty(fcx.ccx.tcx, sty) { |t|
2626
replace_bound_regions(tcx, span, isr, t)
2727
};
28-
#debug["Result of universal quant. is %s", fcx.ty_to_str(t_res)];
28+
#debug["Result of universal quant. is %s",
29+
fcx.infcx.ty_to_str(t_res)];
2930
t_res
3031
}
3132
}

branches/try/src/rustc/middle/typeck/check/vtable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span,
5454
-> vtable_origin {
5555

5656
#debug["lookup_vtable(ty=%s, iface_ty=%s)",
57-
fcx.ty_to_str(ty), fcx.ty_to_str(iface_ty)];
57+
fcx.infcx.ty_to_str(ty), fcx.infcx.ty_to_str(iface_ty)];
5858
let _i = indenter();
5959

6060
let tcx = fcx.ccx.tcx;

branches/try/src/rustc/middle/typeck/check/writeback.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn visit_pat(p: @ast::pat, wbcx: wb_ctxt, v: wb_vt) {
123123
resolve_type_vars_for_node(wbcx, p.span, p.id);
124124
#debug["Type for pattern binding %s (id %d) resolved to %s",
125125
pat_to_str(p), p.id,
126-
wbcx.fcx.ty_to_str(
126+
wbcx.fcx.infcx.ty_to_str(
127127
ty::node_id_to_type(wbcx.fcx.ccx.tcx,
128128
p.id))];
129129
visit::visit_pat(p, wbcx, v);
@@ -135,7 +135,7 @@ fn visit_local(l: @ast::local, wbcx: wb_ctxt, v: wb_vt) {
135135
result::ok(lty) {
136136
#debug["Type for local %s (id %d) resolved to %s",
137137
pat_to_str(l.node.pat), l.node.id,
138-
wbcx.fcx.ty_to_str(lty)];
138+
wbcx.fcx.infcx.ty_to_str(lty)];
139139
write_ty_to_tcx(wbcx.fcx.ccx.tcx, l.node.id, lty);
140140
}
141141
result::err(e) {

branches/try/src/rustc/middle/typeck/infer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export mk_assignty;
167167
export resolve_shallow;
168168
export resolve_deep;
169169
export resolve_deep_var;
170-
export ty_and_region_var_methods;
170+
export methods; // for infer_ctxt
171171
export compare_tys;
172172
export fixup_err, fixup_err_to_str;
173173

@@ -388,7 +388,7 @@ fn uok() -> ures {
388388
ok(())
389389
}
390390

391-
impl methods for infer_ctxt {
391+
impl transaction_methods for infer_ctxt {
392392
fn commit<T,E>(f: fn() -> result<T,E>) -> result<T,E> {
393393

394394
assert self.vb.bindings.len() == 0u;
@@ -431,7 +431,7 @@ impl methods for infer_ctxt {
431431
}
432432
}
433433

434-
impl ty_and_region_var_methods for infer_ctxt {
434+
impl methods for infer_ctxt {
435435
fn next_ty_var_id() -> ty_vid {
436436
let id = *self.ty_var_counter;
437437
*self.ty_var_counter += 1u;

0 commit comments

Comments
 (0)