Auto merge of #31911 - Manishearth:rollup, r=Manishearth
- Successful merges: #31878, #31880, #31883, #31893, #31894, #31896, #31901, #31904 - Failed merges: #31897
This commit is contained in:
commit
ee8b257d2e
@ -100,6 +100,10 @@
|
||||
# // Having trouble figuring out which test is failing? Turn off parallel tests
|
||||
# make check-stage1-std RUST_TEST_THREADS=1
|
||||
#
|
||||
# // To make debug!() and other logging calls visible, reconfigure:
|
||||
# ./configure --enable-debug-assertions
|
||||
# make ....
|
||||
#
|
||||
# If you really feel like getting your hands dirty, then:
|
||||
#
|
||||
# run `make nitty-gritty`
|
||||
|
@ -236,6 +236,8 @@ following forms:
|
||||
* A _whitespace escape_ is one of the characters `U+006E` (`n`), `U+0072`
|
||||
(`r`), or `U+0074` (`t`), denoting the Unicode values `U+000A` (LF),
|
||||
`U+000D` (CR) or `U+0009` (HT) respectively.
|
||||
* The _null escape_ is the character `U+0030` (`0`) and denotes the Unicode
|
||||
value `U+0000` (NUL).
|
||||
* The _backslash escape_ is the character `U+005C` (`\`) which must be
|
||||
escaped in order to denote *itself*.
|
||||
|
||||
@ -297,6 +299,8 @@ following forms:
|
||||
* A _whitespace escape_ is one of the characters `U+006E` (`n`), `U+0072`
|
||||
(`r`), or `U+0074` (`t`), denoting the bytes values `0x0A` (ASCII LF),
|
||||
`0x0D` (ASCII CR) or `0x09` (ASCII HT) respectively.
|
||||
* The _null escape_ is the character `U+0030` (`0`) and denotes the byte
|
||||
value `0x00` (ASCII NUL).
|
||||
* The _backslash escape_ is the character `U+005C` (`\`) which must be
|
||||
escaped in order to denote its ASCII encoding `0x5C`.
|
||||
|
||||
|
@ -271,7 +271,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
|
||||
for (i, trait_did) in candidates.iter().enumerate() {
|
||||
err.fileline_help(span,
|
||||
&format!("candidate #{}: use `{}`",
|
||||
&format!("candidate #{}: `use {}`",
|
||||
i + 1,
|
||||
fcx.tcx().item_path_str(*trait_did)));
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ impl Error for JoinPathsError {
|
||||
///
|
||||
/// match env::home_dir() {
|
||||
/// Some(ref p) => println!("{}", p.display()),
|
||||
/// None => println!("Impossible to get your home dir!")
|
||||
/// None => println!("Impossible to get your home dir!"),
|
||||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
@ -482,8 +482,7 @@ pub fn temp_dir() -> PathBuf {
|
||||
os_imp::temp_dir()
|
||||
}
|
||||
|
||||
/// Returns the filesystem path to the current executable which is running but
|
||||
/// with the executable name.
|
||||
/// Returns the full filesystem path to the current running executable.
|
||||
///
|
||||
/// The path returned is not necessarily a "real path" to the executable as
|
||||
/// there may be intermediate symlinks.
|
||||
@ -492,7 +491,7 @@ pub fn temp_dir() -> PathBuf {
|
||||
///
|
||||
/// Acquiring the path to the current executable is a platform-specific operation
|
||||
/// that can fail for a good number of reasons. Some errors can include, but not
|
||||
/// be limited to filesystem operations failing or general syscall failures.
|
||||
/// be limited to, filesystem operations failing or general syscall failures.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1055,7 +1055,14 @@ pub trait Write {
|
||||
let mut output = Adaptor { inner: self, error: Ok(()) };
|
||||
match fmt::write(&mut output, fmt) {
|
||||
Ok(()) => Ok(()),
|
||||
Err(..) => output.error
|
||||
Err(..) => {
|
||||
// check if the error came from the underlying `Write` or not
|
||||
if output.error.is_err() {
|
||||
output.error
|
||||
} else {
|
||||
Err(Error::new(ErrorKind::Other, "formatter error"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ mod platform {
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
} else if path.len() > 1 && path[1] == b':' {
|
||||
} else if path.get(1) == Some(& b':') {
|
||||
// C:
|
||||
let c = path[0];
|
||||
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>
|
||||
loop {
|
||||
let mut iter_next = iter.clone();
|
||||
match (iter_next.next(), prefix.next()) {
|
||||
(Some(x), Some(y)) => {
|
||||
if x != y {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
(Some(ref x), Some(ref y)) if x == y => (),
|
||||
(Some(_), Some(_)) => return None,
|
||||
(Some(_), None) => return Some(iter),
|
||||
(None, None) => return Some(iter),
|
||||
(None, Some(_)) => return None,
|
||||
|
@ -34,31 +34,31 @@ fn main() {
|
||||
1u32.method();
|
||||
//~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
|
||||
//~^^ ERROR no method named
|
||||
//~^^^ HELP `foo::Bar`
|
||||
//~^^^^ HELP `no_method_suggested_traits::foo::PubPub`
|
||||
//~^^^ HELP `use foo::Bar`
|
||||
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub`
|
||||
std::rc::Rc::new(&mut Box::new(&1u32)).method();
|
||||
//~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
|
||||
//~^^ ERROR no method named
|
||||
//~^^^ HELP `foo::Bar`
|
||||
//~^^^^ HELP `no_method_suggested_traits::foo::PubPub`
|
||||
//~^^^ HELP `use foo::Bar`
|
||||
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub`
|
||||
|
||||
'a'.method();
|
||||
//~^ ERROR no method named
|
||||
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
|
||||
//~^^^ HELP `foo::Bar`
|
||||
//~^^^ HELP `use foo::Bar`
|
||||
std::rc::Rc::new(&mut Box::new(&'a')).method();
|
||||
//~^ ERROR no method named
|
||||
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
|
||||
//~^^^ HELP `foo::Bar`
|
||||
//~^^^ HELP `use foo::Bar`
|
||||
|
||||
1i32.method();
|
||||
//~^ ERROR no method named
|
||||
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
|
||||
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
|
||||
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub`
|
||||
std::rc::Rc::new(&mut Box::new(&1i32)).method();
|
||||
//~^ ERROR no method named
|
||||
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
|
||||
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
|
||||
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub`
|
||||
|
||||
Foo.method();
|
||||
//~^ ERROR no method named
|
||||
|
54
src/test/run-pass/write-fmt-errors.rs
Normal file
54
src/test/run-pass/write-fmt-errors.rs
Normal file
@ -0,0 +1,54 @@
|
||||
// Copyright 2016 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::fmt;
|
||||
use std::io::{self, Error, Write, sink};
|
||||
|
||||
struct ErrorDisplay;
|
||||
|
||||
impl fmt::Display for ErrorDisplay {
|
||||
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
|
||||
Err(fmt::Error)
|
||||
}
|
||||
}
|
||||
|
||||
struct ErrorWriter;
|
||||
|
||||
const FORMAT_ERROR: io::ErrorKind = io::ErrorKind::Other;
|
||||
const WRITER_ERROR: io::ErrorKind = io::ErrorKind::NotConnected;
|
||||
|
||||
impl Write for ErrorWriter {
|
||||
fn write(&mut self, _buf: &[u8]) -> io::Result<usize> {
|
||||
Err(Error::new(WRITER_ERROR, "not connected"))
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()> { Ok(()) }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Test that the error from the formatter is propagated.
|
||||
let res = write!(sink(), "{} {} {}", 1, ErrorDisplay, "bar");
|
||||
assert!(res.is_err(), "formatter error did not propagate");
|
||||
assert_eq!(res.unwrap_err().kind(), FORMAT_ERROR);
|
||||
|
||||
// Test that an underlying error is propagated
|
||||
let res = write!(ErrorWriter, "abc");
|
||||
assert!(res.is_err(), "writer error did not propagate");
|
||||
|
||||
// Writer error
|
||||
let res = write!(ErrorWriter, "abc {}", ErrorDisplay);
|
||||
assert!(res.is_err(), "writer error did not propagate");
|
||||
assert_eq!(res.unwrap_err().kind(), WRITER_ERROR);
|
||||
|
||||
// Formatter error
|
||||
let res = write!(ErrorWriter, "{} abc", ErrorDisplay);
|
||||
assert!(res.is_err(), "formatter error did not propagate");
|
||||
assert_eq!(res.unwrap_err().kind(), FORMAT_ERROR);
|
||||
}
|
Loading…
Reference in New Issue
Block a user