about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-18 17:12:02 -0700
committerbors <bors@rust-lang.org>2013-08-18 17:12:02 -0700
commit8fff3f40f290df5bcd25bcefdc0e19f74d0af0a5 (patch)
tree8b0869e42997037fc6ad863315b248bc308d3145
parentb26e11db862a9f06556d2871b1b71e09f652e395 (diff)
parent0450cde37b70e7c32a2d5d359836b737c5fdc657 (diff)
downloadrust-8fff3f40f290df5bcd25bcefdc0e19f74d0af0a5.tar.gz
rust-8fff3f40f290df5bcd25bcefdc0e19f74d0af0a5.zip
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
-rw-r--r--src/librustc/middle/typeck/check/mod.rs10
-rw-r--r--src/test/compile-fail/issue-2817.rs27
-rw-r--r--src/test/compile-fail/issue-3651-2.rs14
3 files changed, 1 insertions, 50 deletions
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index a46ee330a85..e6d54879181 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 384b2cc843b..00000000000
--- 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 bcd8e86d1d3..00000000000
--- 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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
-}