Skip to content

Commit 8fff3f4

Browse files
committed
auto merge of #8561 : kballard/rust/do-block-internal-err-msg, 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
2 parents b26e11d + 0450cde commit 8fff3f4

File tree

3 files changed

+1
-50
lines changed

3 files changed

+1
-50
lines changed

src/librustc/middle/typeck/check/mod.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -942,15 +942,7 @@ impl FnCtxt {
942942
if ty::type_is_error(e) || ty::type_is_error(a) {
943943
return;
944944
}
945-
match self.fn_kind {
946-
DoBlock if ty::type_is_bool(e) && ty::type_is_nil(a) =>
947-
// If we expected bool and got ()...
948-
self.tcx().sess.span_err(sp, fmt!("Do-block body must \
949-
return %s, but returns () here. Perhaps you meant \
950-
to write a `for`-loop?",
951-
ppaux::ty_to_str(self.tcx(), e))),
952-
_ => self.infcx().report_mismatched_types(sp, e, a, err)
953-
}
945+
self.infcx().report_mismatched_types(sp, e, a, err)
954946
}
955947

956948
pub fn report_mismatched_types(&self,

src/test/compile-fail/issue-2817.rs

-27
This file was deleted.

src/test/compile-fail/issue-3651-2.rs

-14
This file was deleted.

0 commit comments

Comments
 (0)