Skip to content

Commit aad563c

Browse files
committed
---
yaml --- r: 13567 b: refs/heads/master c: 26bd186 h: refs/heads/master i: 13565: bbff109 13563: e7e651b 13559: bdb38d7 13551: b7ed888 13535: 74ef21d 13503: cb66784 13439: accb9a9 13311: b93da12 v: v3
1 parent 64fa716 commit aad563c

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3e281439a0d9fd67f3ad08976d0b60535112b303
2+
refs/heads/master: 26bd186726124e76714b98d1e28afe477bd99353
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/typeck.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,23 @@ fn require_same_types(
203203
}
204204
}
205205

206+
fn require_same_types_in_infcx(
207+
infcx: infer::infer_ctxt,
208+
span: span,
209+
t1: ty::t,
210+
t2: ty::t,
211+
msg: fn() -> str) -> bool {
212+
213+
alt infer::compare_tys_in_infcx(infcx, t1, t2) {
214+
result::ok(()) { true }
215+
result::err(terr) {
216+
infcx.tcx.sess.span_err(span, msg() + ": " +
217+
ty::type_err_to_str(infcx.tcx, terr));
218+
false
219+
}
220+
}
221+
}
222+
206223
fn arg_is_argv_ty(_tcx: ty::ctxt, a: ty::arg) -> bool {
207224
alt ty::get(a.ty).struct {
208225
ty::ty_vec(mt) {

trunk/src/rustc/middle/typeck/check/alt.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,12 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
137137
check_expr_with(fcx, end, expected);
138138
let b_ty =
139139
fcx.infcx.resolve_type_vars_if_possible(fcx.expr_ty(begin));
140-
if !require_same_types(
141-
tcx, pat.span, b_ty,
142-
fcx.infcx.resolve_type_vars_if_possible(fcx.expr_ty(end)),
140+
let e_ty =
141+
fcx.infcx.resolve_type_vars_if_possible(fcx.expr_ty(end));
142+
#debug["pat_range beginning type: %?", b_ty];
143+
#debug["pat_range ending type: %?", e_ty];
144+
if !require_same_types_in_infcx(
145+
fcx.infcx, pat.span, b_ty, e_ty,
143146
{|| "mismatched types in range" }) {
144147
// no-op
145148
} else if !ty::type_is_numeric(b_ty) {

trunk/src/rustc/middle/typeck/infer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export resolve_deep_var;
172172
export methods; // for infer_ctxt
173173
export unify_methods; // for infer_ctxt
174174
export compare_tys;
175+
export compare_tys_in_infcx;
175176
export fixup_err, fixup_err_to_str;
176177
export assignment;
177178
export root, to_str;
@@ -381,6 +382,10 @@ fn compare_tys(tcx: ty::ctxt, a: ty::t, b: ty::t) -> ures {
381382
mk_eqty(infcx, a, b)
382383
}
383384

385+
fn compare_tys_in_infcx(infcx: infer_ctxt, a: ty::t, b: ty::t) -> ures {
386+
mk_eqty(infcx, a, b)
387+
}
388+
384389
// See comment on the type `resolve_state` below
385390
fn resolve_shallow(cx: infer_ctxt, a: ty::t,
386391
force_vars: force_level) -> fres<ty::t> {

0 commit comments

Comments
 (0)