Skip to content

Commit 997dba0

Browse files
committed
---
yaml --- r: 85463 b: refs/heads/dist-snap c: 1092744 h: refs/heads/master i: 85461: 51600f6 85459: f0e8e57 85455: b140dfc v: v3
1 parent 9936c0e commit 997dba0

File tree

6 files changed

+56
-5
lines changed

6 files changed

+56
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 0983ebe5310d4eb6d289f636f7ed0536c08bbc0e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 0450cde37b70e7c32a2d5d359836b737c5fdc657
9+
refs/heads/dist-snap: 109274426a7cd676b9aa1bb06afd9f86b44f6e9b
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/typeck/check/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,15 @@ impl FnCtxt {
942942
if ty::type_is_error(e) || ty::type_is_error(a) {
943943
return;
944944
}
945-
self.infcx().report_mismatched_types(sp, e, a, err)
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+
}
946954
}
947955

948956
pub fn report_mismatched_types(&self,

branches/dist-snap/src/libstd/fmt/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,9 @@ impl Bool for bool {
726726
}
727727
}
728728

729-
impl<'self> String for &'self str {
730-
fn fmt(s: & &'self str, f: &mut Formatter) {
731-
f.pad(*s);
729+
impl<'self, T: str::Str> String for T {
730+
fn fmt(s: &T, f: &mut Formatter) {
731+
f.pad(s.as_slice());
732732
}
733733
}
734734

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::uint;
12+
13+
fn uuid() -> uint { fail!(); }
14+
15+
fn from_str(s: ~str) -> uint { fail!(); }
16+
fn to_str(u: uint) -> ~str { fail!(); }
17+
fn uuid_random() -> uint { fail!(); }
18+
19+
fn main() {
20+
do range(0u, 100000).advance |_i| { //~ ERROR Do-block body must return bool, but
21+
};
22+
// should get a more general message if the callback
23+
// doesn't return nil
24+
do range(0u, 100000).advance |_i| { //~ ERROR mismatched types
25+
~"str"
26+
};
27+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
fn take_block(f: &fn() -> bool) -> bool { f() }
13+
do take_block {}; //~ ERROR Do-block body must return bool, but returns () here. Perhaps
14+
}

branches/dist-snap/src/test/run-pass/ifmt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ pub fn main() {
4545
t!(ifmt!("{:x}", 10u), "a");
4646
t!(ifmt!("{:X}", 10u), "A");
4747
t!(ifmt!("{:s}", "foo"), "foo");
48+
t!(ifmt!("{:s}", ~"foo"), "foo");
49+
t!(ifmt!("{:s}", @"foo"), "foo");
4850
t!(ifmt!("{:p}", 0x1234 as *int), "0x1234");
4951
t!(ifmt!("{:p}", 0x1234 as *mut int), "0x1234");
5052
t!(ifmt!("{:d}", A), "aloha");

0 commit comments

Comments
 (0)