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
This commit is contained in:
commit
8fff3f40f2
3 changed files with 1 additions and 50 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue