Skip to content

Commit 4c40882

Browse files
committed
---
yaml --- r: 15610 b: refs/heads/try c: 2782cfb h: refs/heads/master v: v3
1 parent 2f019c1 commit 4c40882

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
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: 9053f54498373c8ca799e777d8a979c0d32fbb07
5+
refs/heads/try: 2782cfb783129c1bf271cf31ac51f3a02d55c335
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,9 +3305,20 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
33053305
let rty = structurally_resolved_type(fcx, expr.span, expected);
33063306
let (inner_ty, proto) = alt check ty::get(rty).struct {
33073307
ty::ty_fn(fty) {
3308-
demand::suptype(fcx, expr.span, fty.output, ty::mk_bool(tcx));
3309-
(ty::mk_fn(tcx, {output: ty::mk_nil(tcx) with fty}),
3310-
fty.proto)
3308+
alt infer::mk_subty(fcx.infcx, fty.output, ty::mk_bool(tcx)) {
3309+
result::ok(_) {}
3310+
result::err(err) {
3311+
tcx.sess.span_fatal(
3312+
expr.span, #fmt("a loop function's last argument should \
3313+
return `bool`, not `%s`",
3314+
ty_to_str(tcx, fty.output)));
3315+
}
3316+
}
3317+
(ty::mk_fn(tcx, {output: ty::mk_nil(tcx) with fty}), fty.proto)
3318+
}
3319+
_ {
3320+
tcx.sess.span_fatal(expr.span, "a loop function's last argument \
3321+
should be of function type");
33113322
}
33123323
};
33133324
alt check b.node {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
fn baz(_x: fn() -> int) {}
3+
for baz {|_e| } //! ERROR should return `bool`
4+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// error-pattern:mismatched types: expected `()` but found `bool`
22

33
fn main() {
4-
for vec::iter([0]) {|_i|
4+
for vec::each([0]) {|_i|
55
true
66
}
77
}

0 commit comments

Comments
 (0)