]> git.lizzy.rs Git - rust.git/commitdiff
Migrate to eprint/eprintln macros where appropriate.
authorCorey Farwell <coreyf@rwell.org>
Mon, 25 Sep 2017 04:14:56 +0000 (00:14 -0400)
committerCorey Farwell <coreyf@rwell.org>
Thu, 28 Sep 2017 15:38:35 +0000 (11:38 -0400)
18 files changed:
src/bootstrap/bin/rustc.rs
src/librustc_driver/lib.rs
src/librustdoc/externalfiles.rs
src/librustdoc/markdown.rs
src/librustdoc/test.rs
src/libstd/process.rs
src/test/run-fail/mir_drop_panics.rs
src/test/run-fail/mir_dynamic_drops_1.rs
src/test/run-fail/mir_dynamic_drops_2.rs
src/test/run-fail/mir_dynamic_drops_3.rs
src/test/run-fail/mir_trans_calls_converging_drops.rs
src/test/run-fail/mir_trans_calls_converging_drops_2.rs
src/test/run-fail/mir_trans_calls_diverging_drops.rs
src/test/run-fail/panic-set-handler.rs
src/test/run-fail/panic-set-unset-handler.rs
src/test/run-pass/backtrace-debuginfo.rs
src/tools/tidy/src/lib.rs
src/tools/tidy/src/main.rs

index 848b10d312cea476c8352d22690f3b63424fa399..54a3dbafe272aac09a7e8a0af2c84d143b4be412 100644 (file)
@@ -31,8 +31,6 @@
 
 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!
index 044f4a5eaf512bec0ff28ccb98aa4e3ef190a943..29d1518850024f82ca92b8b2950143bf682f6fb3 100644 (file)
@@ -1307,7 +1307,7 @@ fn flush(&mut self) -> io::Result<()> {
                              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();
index 111ae4ede277a9fb820dd64bb9db956b898180db..2f7bd5e39a14927aad28c8988b82ae497e66680f 100644 (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)
         }
     }
index 57e8e88cd13dd7795944d2a44c6d12f1ab594db0..484285e91f6e9093564c7b85b06f1fa1d3a225c1 100644 (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
index f9cb4b84545dd6b05cba6a08c446fa9bd86509e1..5f6ccb8a75ee2c9522edb05d9081b50339b42b70 100644 (file)
@@ -479,11 +479,10 @@ pub fn add_test(&mut self, test: String,
                 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
             }
         }
index 1869ad3ed707a088260c6bdf80ce7e45431d6a82..015f859b5cc384e2c7404566de1b44ab1085298f 100644 (file)
@@ -1083,8 +1083,6 @@ pub fn wait_with_output(mut self) -> io::Result<Output> {
 /// 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 @@ pub fn wait_with_output(mut self) -> io::Result<Output> {
 ///     ::std::process::exit(match run_app() {
 ///        Ok(_) => 0,
 ///        Err(err) => {
-///            writeln!(io::stderr(), "error: {:?}", err).unwrap();
+///            eprintln!("error: {:?}", err);
 ///            1
 ///        }
 ///     });
index 98311525ad0f26b77a61c473654fdd7996b82bb3..51191dd7087e483e3f9ae7eabdfe067bbfc83a72 100644 (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 @@ fn drop(&mut self) {
         if self.0 == 1 {
             panic!("panic 1");
         } else {
-            write!(io::stderr(), "drop {}", self.0);
+            eprint!("drop {}", self.0);
         }
     }
 }
index 6cf2851d93d472b664a1e6999e74b9c963252cdd..69f934272b75cd72a8ffe701ddbdc324ae6b7a98 100644 (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.
 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;
     }
 }
index 7a90298e4225323ab81633d0796bb61b68db9fc1..d2fe50401ab8de4a6da8dc44169f13dac44fe103 100644 (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.
 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;
     }
 }
index 79ecbbb35bc56cc7f2082bc73759d9577c5c2cbf..ecc35ee9b2409545c814ab498e730ab9b03556be 100644 (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.
 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;
     }
 }
index 7a7526c5fc1d37d220ab8c8d6aa98cbd8602b03e..9c851eb7346bb295bedfc10fc41fb88980d52cfd 100644 (file)
 // 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) {
index 1301630cc85ea64b52ff3653fd8256e4d792c792..6f10521155648a8e83fe5f34caa721d34e9191ed 100644 (file)
 // 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
 }
 
index c191870492969628b96bcc86bf39c1254b6bbdd1..f8fbe8f79cc622bd8068a4c00d2e056354019898 100644 (file)
 // 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);
     }
 }
 
index b589544ae156359eb62e260d9f232856090ebf89..68f1c4ed0bceddc17d52ac9b413d64c95fb1bc96 100644 (file)
 #![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");
 }
index 6741c2d9c2c2028d40bf1c252e6e22f0738e9e15..072139a8c9b802c8fe653c82ef1a0f06cade2537 100644 (file)
 #![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");
index f81352e177322ea1a3a26853735aebfd0078ac1a..f9233026a1e6e2628a841faf01aec2f14c5607ce 100644 (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 {
index 90bf7a5e0a6877ba72c20bbbe2abf5805c76522a..c316ec467620a468d138785d74faf5108c8cabd7 100644 (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)*);
     });
 }
 
index 433192a21ec9caa45a7514742828d3e3ef928b61..f6640c902bcb47e798debf9e23518d4256669514 100644 (file)
@@ -22,7 +22,6 @@
 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);
     }
 }