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 `()`
This commit is contained in:
parent
680eb71564
commit
0450cde37b
@ -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,
|
||||
|
@ -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"
|
||||
};
|
||||
}
|
@ -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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user