Migrate to eprint/eprintln macros where appropriate.

This commit is contained in:
Corey Farwell 2017-09-25 00:14:56 -04:00
parent 48c1c548e1
commit 8ef5447815
18 changed files with 30 additions and 64 deletions

View File

@ -31,8 +31,6 @@ extern crate bootstrap;
use std::env;
use std::ffi::OsString;
use std::io;
use std::io::prelude::*;
use std::str::FromStr;
use std::path::PathBuf;
use std::process::{Command, ExitStatus};
@ -270,7 +268,7 @@ fn main() {
}
if verbose > 1 {
writeln!(&mut io::stderr(), "rustc command: {:?}", cmd).unwrap();
eprintln!("rustc command: {:?}", cmd);
}
// Actually run the compiler!

View File

@ -1307,7 +1307,7 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
errors::Level::Note);
}
writeln!(io::stderr(), "{}", str::from_utf8(&data.lock().unwrap()).unwrap()).unwrap();
eprintln!("{}", str::from_utf8(&data.lock().unwrap()).unwrap());
}
exit_on_err();

View File

@ -10,7 +10,6 @@
use std::fs::File;
use std::io::prelude::*;
use std::io;
use std::path::Path;
use std::str;
use html::markdown::{Markdown, RenderType};
@ -70,17 +69,13 @@ pub fn load_string<P: AsRef<Path>>(file_path: P) -> Result<String, LoadStringErr
let result = File::open(file_path)
.and_then(|mut f| f.read_to_end(&mut contents));
if let Err(e) = result {
let _ = writeln!(&mut io::stderr(),
"error reading `{}`: {}",
file_path.display(), e);
eprintln!("error reading `{}`: {}", file_path.display(), e);
return Err(LoadStringError::ReadFail);
}
match str::from_utf8(&contents) {
Ok(s) => Ok(s.to_string()),
Err(_) => {
let _ = writeln!(&mut io::stderr(),
"error reading `{}`: not UTF-8",
file_path.display());
eprintln!("error reading `{}`: not UTF-8", file_path.display());
Err(LoadStringError::BadUtf8)
}
}

View File

@ -11,7 +11,6 @@
use std::default::Default;
use std::fs::File;
use std::io::prelude::*;
use std::io;
use std::path::{PathBuf, Path};
use getopts;
@ -75,9 +74,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
let mut out = match File::create(&output) {
Err(e) => {
let _ = writeln!(&mut io::stderr(),
"rustdoc: {}: {}",
output.display(), e);
eprintln!("rustdoc: {}: {}", output.display(), e);
return 4;
}
Ok(f) => f
@ -85,10 +82,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
let (metadata, text) = extract_leading_metadata(&input_str);
if metadata.is_empty() {
let _ = writeln!(
&mut io::stderr(),
"rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`"
);
eprintln!("rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`");
return 5;
}
let title = metadata[0];
@ -138,9 +132,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
match err {
Err(e) => {
let _ = writeln!(&mut io::stderr(),
"rustdoc: cannot write to `{}`: {}",
output.display(), e);
eprintln!("rustdoc: cannot write to `{}`: {}", output.display(), e);
6
}
Ok(_) => 0

View File

@ -479,11 +479,10 @@ impl Collector {
found = entry.remove_item(&test).is_some();
}
if !found {
let _ = writeln!(&mut io::stderr(),
"WARNING: {} Code block is not currently run as a test, but will \
in future versions of rustdoc. Please ensure this code block is \
a runnable test, or use the `ignore` directive.",
name);
eprintln!("WARNING: {} Code block is not currently run as a test, but will \
in future versions of rustdoc. Please ensure this code block is \
a runnable test, or use the `ignore` directive.",
name);
return
}
}

View File

@ -1083,8 +1083,6 @@ impl Child {
/// function and compute the exit code from its return value:
///
/// ```
/// use std::io::{self, Write};
///
/// fn run_app() -> Result<(), ()> {
/// // Application logic here
/// Ok(())
@ -1094,7 +1092,7 @@ impl Child {
/// ::std::process::exit(match run_app() {
/// Ok(_) => 0,
/// Err(err) => {
/// writeln!(io::stderr(), "error: {:?}", err).unwrap();
/// eprintln!("error: {:?}", err);
/// 1
/// }
/// });

View File

@ -10,7 +10,6 @@
// error-pattern:panic 1
// error-pattern:drop 2
use std::io::{self, Write};
struct Droppable(u32);
impl Drop for Droppable {
@ -18,7 +17,7 @@ impl Drop for Droppable {
if self.0 == 1 {
panic!("panic 1");
} else {
write!(io::stderr(), "drop {}", self.0);
eprint!("drop {}", self.0);
}
}
}

View File

@ -9,7 +9,6 @@
// except according to those terms.
// error-pattern:drop 1
// error-pattern:drop 2
use std::io::{self, Write};
/// Structure which will not allow to be dropped twice.
@ -17,10 +16,10 @@ struct Droppable<'a>(&'a mut bool, u32);
impl<'a> Drop for Droppable<'a> {
fn drop(&mut self) {
if *self.0 {
writeln!(io::stderr(), "{} dropped twice", self.1);
eprintln!("{} dropped twice", self.1);
::std::process::exit(1);
}
writeln!(io::stderr(), "drop {}", self.1);
eprintln!("drop {}", self.1);
*self.0 = true;
}
}

View File

@ -9,7 +9,6 @@
// except according to those terms.
// error-pattern:drop 1
use std::io::{self, Write};
/// Structure which will not allow to be dropped twice.
@ -17,10 +16,10 @@ struct Droppable<'a>(&'a mut bool, u32);
impl<'a> Drop for Droppable<'a> {
fn drop(&mut self) {
if *self.0 {
writeln!(io::stderr(), "{} dropped twice", self.1);
eprintln!("{} dropped twice", self.1);
::std::process::exit(1);
}
writeln!(io::stderr(), "drop {}", self.1);
eprintln!("drop {}", self.1);
*self.0 = true;
}
}

View File

@ -12,7 +12,6 @@
// error-pattern:drop 3
// error-pattern:drop 2
// error-pattern:drop 1
use std::io::{self, Write};
/// Structure which will not allow to be dropped twice.
@ -20,10 +19,10 @@ struct Droppable<'a>(&'a mut bool, u32);
impl<'a> Drop for Droppable<'a> {
fn drop(&mut self) {
if *self.0 {
writeln!(io::stderr(), "{} dropped twice", self.1);
eprintln!("{} dropped twice", self.1);
::std::process::exit(1);
}
writeln!(io::stderr(), "drop {}", self.1);
eprintln!("drop {}", self.1);
*self.0 = true;
}
}

View File

@ -12,17 +12,15 @@
// error-pattern:0 dropped
// error-pattern:exit
use std::io::{self, Write};
struct Droppable(u8);
impl Drop for Droppable {
fn drop(&mut self) {
write!(io::stderr(), "{} dropped\n", self.0);
eprintln!("{} dropped", self.0);
}
}
fn converging_fn() {
write!(io::stderr(), "converging_fn called\n");
eprintln!("converging_fn called");
}
fn mir(d: Droppable) {

View File

@ -12,18 +12,16 @@
// error-pattern:dropped
// error-pattern:exit
use std::io::{self, Write};
struct Droppable;
impl Drop for Droppable {
fn drop(&mut self) {
write!(io::stderr(), "dropped\n");
eprintln!("dropped");
}
}
// return value of this function is copied into the return slot
fn complex() -> u64 {
write!(io::stderr(), "complex called\n");
eprintln!("complex called");
42
}

View File

@ -11,12 +11,10 @@
// error-pattern:diverging_fn called
// error-pattern:0 dropped
use std::io::{self, Write};
struct Droppable(u8);
impl Drop for Droppable {
fn drop(&mut self) {
write!(io::stderr(), "{} dropped", self.0);
eprintln!("{} dropped", self.0);
}
}

View File

@ -13,11 +13,10 @@
#![feature(panic_handler)]
use std::panic;
use std::io::{self, Write};
fn main() {
panic::set_hook(Box::new(|i| {
write!(io::stderr(), "greetings from the panic handler");
eprint!("greetings from the panic handler");
}));
panic!("foobar");
}

View File

@ -13,11 +13,10 @@
#![feature(panic_handler)]
use std::panic;
use std::io::{self, Write};
fn main() {
panic::set_hook(Box::new(|i| {
write!(io::stderr(), "greetings from the panic handler");
eprint!("greetings from the panic handler");
}));
panic::take_hook();
panic!("foobar");

View File

@ -19,8 +19,6 @@
// ignore-pretty issue #37195
// ignore-emscripten spawning processes is not supported
use std::io;
use std::io::prelude::*;
use std::env;
#[path = "backtrace-debuginfo-aux.rs"] mod aux;
@ -163,7 +161,7 @@ fn main() {
let args: Vec<String> = env::args().collect();
if args.len() >= 2 {
let case = args[1].parse().unwrap();
writeln!(&mut io::stderr(), "test case {}", case).unwrap();
eprintln!("test case {}", case);
outer(case, pos!());
println!("done.");
} else {

View File

@ -33,10 +33,9 @@ macro_rules! t {
macro_rules! tidy_error {
($bad:expr, $fmt:expr, $($arg:tt)*) => ({
use std::io::Write;
*$bad = true;
write!(::std::io::stderr(), "tidy error: ").expect("could not write to stderr");
writeln!(::std::io::stderr(), $fmt, $($arg)*).expect("could not write to stderr");
eprint!("tidy error: ");
eprintln!($fmt, $($arg)*);
});
}

View File

@ -22,7 +22,6 @@ use tidy::*;
use std::process;
use std::path::PathBuf;
use std::env;
use std::io::{self, Write};
fn main() {
let path = env::args_os().skip(1).next().expect("need an argument");
@ -44,7 +43,7 @@ fn main() {
}
if bad {
writeln!(io::stderr(), "some tidy checks failed").expect("could not write to stderr");
eprintln!("some tidy checks failed");
process::exit(1);
}
}