From 0450cde37b70e7c32a2d5d359836b737c5fdc657 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Fri, 16 Aug 2013 13:55:26 -0700 Subject: [PATCH] Remove obsolete error message regarding do-blocks with internal iters 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 `()` --- src/librustc/middle/typeck/check/mod.rs | 10 +-------- src/test/compile-fail/issue-2817.rs | 27 ------------------------- src/test/compile-fail/issue-3651-2.rs | 14 ------------- 3 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 src/test/compile-fail/issue-2817.rs delete mode 100644 src/test/compile-fail/issue-3651-2.rs diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index a46ee330a857..e6d54879181d 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -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, diff --git a/src/test/compile-fail/issue-2817.rs b/src/test/compile-fail/issue-2817.rs deleted file mode 100644 index 384b2cc843b0..000000000000 --- a/src/test/compile-fail/issue-2817.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::uint; - -fn uuid() -> uint { fail!(); } - -fn from_str(s: ~str) -> uint { fail!(); } -fn to_str(u: uint) -> ~str { fail!(); } -fn uuid_random() -> uint { fail!(); } - -fn main() { - do range(0u, 100000).advance |_i| { //~ ERROR Do-block body must return bool, but - }; - // should get a more general message if the callback - // doesn't return nil - do range(0u, 100000).advance |_i| { //~ ERROR mismatched types - ~"str" - }; -} diff --git a/src/test/compile-fail/issue-3651-2.rs b/src/test/compile-fail/issue-3651-2.rs deleted file mode 100644 index bcd8e86d1d3b..000000000000 --- a/src/test/compile-fail/issue-3651-2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - fn take_block(f: &fn() -> bool) -> bool { f() } - do take_block {}; //~ ERROR Do-block body must return bool, but returns () here. Perhaps -}