Skip to content

Commit ee8b257

Browse files
committed
Auto merge of #31911 - Manishearth:rollup, r=Manishearth
- Successful merges: #31878, #31880, #31883, #31893, #31894, #31896, #31901, #31904 - Failed merges: #31897
2 parents 0913004 + 3c9a268 commit ee8b257

File tree

8 files changed

+85
-20
lines changed

8 files changed

+85
-20
lines changed

Makefile.in

+4
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@
100100
# // Having trouble figuring out which test is failing? Turn off parallel tests
101101
# make check-stage1-std RUST_TEST_THREADS=1
102102
#
103+
# // To make debug!() and other logging calls visible, reconfigure:
104+
# ./configure --enable-debug-assertions
105+
# make ....
106+
#
103107
# If you really feel like getting your hands dirty, then:
104108
#
105109
# run `make nitty-gritty`

src/doc/reference.md

+4
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ following forms:
236236
* A _whitespace escape_ is one of the characters `U+006E` (`n`), `U+0072`
237237
(`r`), or `U+0074` (`t`), denoting the Unicode values `U+000A` (LF),
238238
`U+000D` (CR) or `U+0009` (HT) respectively.
239+
* The _null escape_ is the character `U+0030` (`0`) and denotes the Unicode
240+
value `U+0000` (NUL).
239241
* The _backslash escape_ is the character `U+005C` (`\`) which must be
240242
escaped in order to denote *itself*.
241243

@@ -297,6 +299,8 @@ following forms:
297299
* A _whitespace escape_ is one of the characters `U+006E` (`n`), `U+0072`
298300
(`r`), or `U+0074` (`t`), denoting the bytes values `0x0A` (ASCII LF),
299301
`0x0D` (ASCII CR) or `0x09` (ASCII HT) respectively.
302+
* The _null escape_ is the character `U+0030` (`0`) and denotes the byte
303+
value `0x00` (ASCII NUL).
300304
* The _backslash escape_ is the character `U+005C` (`\`) which must be
301305
escaped in order to denote its ASCII encoding `0x5C`.
302306

src/librustc_typeck/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
271271

272272
for (i, trait_did) in candidates.iter().enumerate() {
273273
err.fileline_help(span,
274-
&format!("candidate #{}: use `{}`",
274+
&format!("candidate #{}: `use {}`",
275275
i + 1,
276276
fcx.tcx().item_path_str(*trait_did)));
277277
}

src/libstd/env.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ impl Error for JoinPathsError {
442442
///
443443
/// match env::home_dir() {
444444
/// Some(ref p) => println!("{}", p.display()),
445-
/// None => println!("Impossible to get your home dir!")
445+
/// None => println!("Impossible to get your home dir!"),
446446
/// }
447447
/// ```
448448
#[stable(feature = "env", since = "1.0.0")]
@@ -482,8 +482,7 @@ pub fn temp_dir() -> PathBuf {
482482
os_imp::temp_dir()
483483
}
484484

485-
/// Returns the filesystem path to the current executable which is running but
486-
/// with the executable name.
485+
/// Returns the full filesystem path to the current running executable.
487486
///
488487
/// The path returned is not necessarily a "real path" to the executable as
489488
/// there may be intermediate symlinks.
@@ -492,7 +491,7 @@ pub fn temp_dir() -> PathBuf {
492491
///
493492
/// Acquiring the path to the current executable is a platform-specific operation
494493
/// that can fail for a good number of reasons. Some errors can include, but not
495-
/// be limited to filesystem operations failing or general syscall failures.
494+
/// be limited to, filesystem operations failing or general syscall failures.
496495
///
497496
/// # Examples
498497
///

src/libstd/io/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,14 @@ pub trait Write {
10551055
let mut output = Adaptor { inner: self, error: Ok(()) };
10561056
match fmt::write(&mut output, fmt) {
10571057
Ok(()) => Ok(()),
1058-
Err(..) => output.error
1058+
Err(..) => {
1059+
// check if the error came from the underlying `Write` or not
1060+
if output.error.is_err() {
1061+
output.error
1062+
} else {
1063+
Err(Error::new(ErrorKind::Other, "formatter error"))
1064+
}
1065+
}
10591066
}
10601067
}
10611068

src/libstd/path.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ mod platform {
226226
}
227227
_ => (),
228228
}
229-
} else if path.len() > 1 && path[1] == b':' {
229+
} else if path.get(1) == Some(& b':') {
230230
// C:
231231
let c = path[0];
232232
if c.is_ascii() && (c as char).is_alphabetic() {
@@ -393,11 +393,8 @@ fn iter_after<A, I, J>(mut iter: I, mut prefix: J) -> Option<I>
393393
loop {
394394
let mut iter_next = iter.clone();
395395
match (iter_next.next(), prefix.next()) {
396-
(Some(x), Some(y)) => {
397-
if x != y {
398-
return None;
399-
}
400-
}
396+
(Some(ref x), Some(ref y)) if x == y => (),
397+
(Some(_), Some(_)) => return None,
401398
(Some(_), None) => return Some(iter),
402399
(None, None) => return Some(iter),
403400
(None, Some(_)) => return None,

src/test/compile-fail/no-method-suggested-traits.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,31 @@ fn main() {
3434
1u32.method();
3535
//~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
3636
//~^^ ERROR no method named
37-
//~^^^ HELP `foo::Bar`
38-
//~^^^^ HELP `no_method_suggested_traits::foo::PubPub`
37+
//~^^^ HELP `use foo::Bar`
38+
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub`
3939
std::rc::Rc::new(&mut Box::new(&1u32)).method();
4040
//~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
4141
//~^^ ERROR no method named
42-
//~^^^ HELP `foo::Bar`
43-
//~^^^^ HELP `no_method_suggested_traits::foo::PubPub`
42+
//~^^^ HELP `use foo::Bar`
43+
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub`
4444

4545
'a'.method();
4646
//~^ ERROR no method named
4747
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
48-
//~^^^ HELP `foo::Bar`
48+
//~^^^ HELP `use foo::Bar`
4949
std::rc::Rc::new(&mut Box::new(&'a')).method();
5050
//~^ ERROR no method named
5151
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
52-
//~^^^ HELP `foo::Bar`
52+
//~^^^ HELP `use foo::Bar`
5353

5454
1i32.method();
5555
//~^ ERROR no method named
5656
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
57-
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
57+
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub`
5858
std::rc::Rc::new(&mut Box::new(&1i32)).method();
5959
//~^ ERROR no method named
6060
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
61-
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
61+
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub`
6262

6363
Foo.method();
6464
//~^ ERROR no method named

src/test/run-pass/write-fmt-errors.rs

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2016 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::fmt;
12+
use std::io::{self, Error, Write, sink};
13+
14+
struct ErrorDisplay;
15+
16+
impl fmt::Display for ErrorDisplay {
17+
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
18+
Err(fmt::Error)
19+
}
20+
}
21+
22+
struct ErrorWriter;
23+
24+
const FORMAT_ERROR: io::ErrorKind = io::ErrorKind::Other;
25+
const WRITER_ERROR: io::ErrorKind = io::ErrorKind::NotConnected;
26+
27+
impl Write for ErrorWriter {
28+
fn write(&mut self, _buf: &[u8]) -> io::Result<usize> {
29+
Err(Error::new(WRITER_ERROR, "not connected"))
30+
}
31+
32+
fn flush(&mut self) -> io::Result<()> { Ok(()) }
33+
}
34+
35+
fn main() {
36+
// Test that the error from the formatter is propagated.
37+
let res = write!(sink(), "{} {} {}", 1, ErrorDisplay, "bar");
38+
assert!(res.is_err(), "formatter error did not propagate");
39+
assert_eq!(res.unwrap_err().kind(), FORMAT_ERROR);
40+
41+
// Test that an underlying error is propagated
42+
let res = write!(ErrorWriter, "abc");
43+
assert!(res.is_err(), "writer error did not propagate");
44+
45+
// Writer error
46+
let res = write!(ErrorWriter, "abc {}", ErrorDisplay);
47+
assert!(res.is_err(), "writer error did not propagate");
48+
assert_eq!(res.unwrap_err().kind(), WRITER_ERROR);
49+
50+
// Formatter error
51+
let res = write!(ErrorWriter, "{} abc", ErrorDisplay);
52+
assert!(res.is_err(), "formatter error did not propagate");
53+
assert_eq!(res.unwrap_err().kind(), FORMAT_ERROR);
54+
}

0 commit comments

Comments
 (0)