Skip to content

Commit 56856ad

Browse files
committed
---
yaml --- r: 5067 b: refs/heads/master c: 722fa00 h: refs/heads/master i: 5065: 76369fb 5063: c779c37 v: v3
1 parent edc3df7 commit 56856ad

File tree

6 files changed

+16
-31
lines changed

6 files changed

+16
-31
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 498e38b705348333df9ab02059d07f114baccc45
2+
refs/heads/master: 722fa00681fe1d9538cb904e9a9489ac79bf7b5e

trunk/src/comp/middle/trans.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5271,8 +5271,7 @@ fn trans_closure(bcx_maybe: &option::t<@block_ctxt>,
52715271
// trans_mod, trans_item, trans_obj, et cetera) and those that do
52725272
// (trans_block, trans_expr, et cetera).
52735273
let rslt =
5274-
if !ty::type_is_nil(cx.ccx.tcx, block_ty) &&
5275-
!ty::type_is_bot(cx.ccx.tcx, block_ty) &&
5274+
if !ty::type_is_bot(cx.ccx.tcx, block_ty) &&
52765275
f.proto != ast::proto_iter {
52775276
trans_block(bcx, f.body, save_in(fcx.llretptr))
52785277
} else { trans_block(bcx, f.body, return) };

trunk/src/comp/middle/tstate/states.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,6 @@ fn find_pre_post_state_block(fcx: &fn_ctxt, pres0: &prestate, b: &blk) ->
716716
}
717717

718718
fn find_pre_post_state_fn(fcx: &fn_ctxt, f: &_fn) -> bool {
719-
720719
let num_constrs = num_constraints(fcx.enclosing);
721720
// All constraints are considered false until proven otherwise.
722721
// This ensures that intersect works correctly.
@@ -729,25 +728,20 @@ fn find_pre_post_state_fn(fcx: &fn_ctxt, f: &_fn) -> bool {
729728
}
730729

731730
// Instantiate any constraints on the arguments so we can use them
732-
let tsc;
733731
for c: @constr in f.decl.constraints {
734-
tsc = ast_constr_to_ts_constr(fcx.ccx.tcx, f.decl.inputs, c);
732+
let tsc = ast_constr_to_ts_constr(fcx.ccx.tcx, f.decl.inputs, c);
735733
set_in_prestate_constr(fcx, tsc, block_pre);
736734
}
737735

738736
let changed = find_pre_post_state_block(fcx, block_pre, f.body);
739-
// Treat the tail expression as a return statement
740737

738+
// Treat the tail expression as a return statement
741739
alt f.body.node.expr {
742740
some(tailexpr) {
743-
let tailty = expr_ty(fcx.ccx.tcx, tailexpr);
744-
745-
// Since blocks and alts and ifs that don't have results
746-
// implicitly result in nil, we have to be careful to not
747-
// interpret nil-typed block results as the result of a
748-
// function with some other return type
749-
if !type_is_nil(fcx.ccx.tcx, tailty) &&
750-
!type_is_bot(fcx.ccx.tcx, tailty) {
741+
// We don't want to clear the diverges bit for bottom typed things,
742+
// which really do diverge. I feel like there is a cleaner way
743+
// to do this than checking the type.
744+
if !type_is_bot(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, tailexpr)) {
751745
let post = false_postcond(num_constrs);
752746
// except for the "diverges" bit...
753747
kill_poststate_(fcx, fcx.enclosing.i_diverge, post);

trunk/src/comp/middle/typeck.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,22 +2692,14 @@ fn check_fn(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
26922692
// function result type, if there is a tail expr.
26932693
// We don't do this check for an iterator, as the tail expr doesn't
26942694
// have to have the result type of the iterator.
2695-
if option::is_some(body.node.expr) && f.proto != ast::proto_iter {
2696-
let tail_expr = option::get(body.node.expr);
2697-
// The use of resolve_type_vars_if_possible makes me very
2698-
// afraid :-(
2699-
let tail_expr_ty =
2700-
resolve_type_vars_if_possible(fcx, expr_ty(ccx.tcx, tail_expr));
2701-
2702-
// Hacky compromise: use eq and not are_compatible
2703-
// This allows things like while loops and ifs with no
2704-
// else to appear in tail position without a trailing
2705-
// semicolon when the return type is non-nil, while
2706-
// making sure to unify the tailexpr-type with the result
2707-
// type when the tailexpr-type is just a type variable.
2708-
if !ty::eq_ty(tail_expr_ty, ty::mk_nil(ccx.tcx)) {
2695+
alt (body.node.expr) {
2696+
some(tail_expr) {
2697+
if f.proto != ast::proto_iter {
2698+
let tail_expr_ty = expr_ty(ccx.tcx, tail_expr);
27092699
demand::simple(fcx, tail_expr.span, fcx.ret_ty, tail_expr_ty);
27102700
}
2701+
}
2702+
none. {}
27112703
}
27122704

27132705
// If we don't have any enclosing function scope, it is time to

trunk/src/test/compile-fail/forgot-ret.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// -*- rust -*-
2-
// error-pattern: not all control paths return
2+
// error-pattern: mismatched types
33

44
fn god_exists(a: int) -> bool { be god_exists(a); }
55

trunk/src/test/compile-fail/missing-return2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern: return
1+
// error-pattern: mismatched types
22

33
fn f() -> int {
44

0 commit comments

Comments
 (0)