Skip to content

Commit

Permalink
auto merge of rust-lang#8561 : kballard/rust/do-block-internal-err-ms…
Browse files Browse the repository at this point in the history
…g, r=thestinger

When using a `do` block to call an internal iterator, if you forgot to
return a value from the body, it would tell you

    error: Do-block body must return bool, but returns () here. Perhaps
    you meant to write a `for`-loop?

This advice no longer applies as `for` loops are now for external
iterators. Delete this message outright and let it use the default error
message

    error: mismatched types: expected `bool` but found `()`

r? @thestinger
  • Loading branch information
bors committed Aug 19, 2013
2 parents b26e11d + 0450cde commit 8fff3f4
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 50 deletions.
10 changes: 1 addition & 9 deletions src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,15 +942,7 @@ impl FnCtxt {
if ty::type_is_error(e) || ty::type_is_error(a) {
return;
}
match self.fn_kind {
DoBlock if ty::type_is_bool(e) && ty::type_is_nil(a) =>
// If we expected bool and got ()...
self.tcx().sess.span_err(sp, fmt!("Do-block body must \
return %s, but returns () here. Perhaps you meant \
to write a `for`-loop?",
ppaux::ty_to_str(self.tcx(), e))),
_ => self.infcx().report_mismatched_types(sp, e, a, err)
}
self.infcx().report_mismatched_types(sp, e, a, err)
}

pub fn report_mismatched_types(&self,
Expand Down
27 changes: 0 additions & 27 deletions src/test/compile-fail/issue-2817.rs

This file was deleted.

14 changes: 0 additions & 14 deletions src/test/compile-fail/issue-3651-2.rs

This file was deleted.

0 comments on commit 8fff3f4

Please sign in to comment.