Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #31911

Merged
merged 18 commits into from
Feb 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 4 additions & 0 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*.

Expand Down Expand Up @@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
Expand Down
7 changes: 3 additions & 4 deletions src/libstd/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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.
Expand All @@ -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
///
Expand Down
9 changes: 8 additions & 1 deletion src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
}
}
}

Expand Down
9 changes: 3 additions & 6 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions src/test/compile-fail/no-method-suggested-traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 54 additions & 0 deletions src/test/run-pass/write-fmt-errors.rs
Original file line number Diff line number Diff line change
@@ -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);
}