Skip to content

Commit 13ae187

Browse files
committed
Auto merge of #44822 - frewsxcv:frewsxcv-eprintln, r=Kimundi
Migrate to eprint/eprintln macros where appropriate. None
2 parents 692b94a + 8ef5447 commit 13ae187

18 files changed

+30
-64
lines changed

src/bootstrap/bin/rustc.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ extern crate bootstrap;
3131

3232
use std::env;
3333
use std::ffi::OsString;
34-
use std::io;
35-
use std::io::prelude::*;
3634
use std::str::FromStr;
3735
use std::path::PathBuf;
3836
use std::process::{Command, ExitStatus};
@@ -270,7 +268,7 @@ fn main() {
270268
}
271269

272270
if verbose > 1 {
273-
writeln!(&mut io::stderr(), "rustc command: {:?}", cmd).unwrap();
271+
eprintln!("rustc command: {:?}", cmd);
274272
}
275273

276274
// Actually run the compiler!

src/librustc_driver/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
12381238
errors::Level::Note);
12391239
}
12401240

1241-
writeln!(io::stderr(), "{}", str::from_utf8(&data.lock().unwrap()).unwrap()).unwrap();
1241+
eprintln!("{}", str::from_utf8(&data.lock().unwrap()).unwrap());
12421242
}
12431243

12441244
exit_on_err();

src/librustdoc/externalfiles.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use std::fs::File;
1212
use std::io::prelude::*;
13-
use std::io;
1413
use std::path::Path;
1514
use std::str;
1615
use html::markdown::{Markdown, RenderType};
@@ -70,17 +69,13 @@ pub fn load_string<P: AsRef<Path>>(file_path: P) -> Result<String, LoadStringErr
7069
let result = File::open(file_path)
7170
.and_then(|mut f| f.read_to_end(&mut contents));
7271
if let Err(e) = result {
73-
let _ = writeln!(&mut io::stderr(),
74-
"error reading `{}`: {}",
75-
file_path.display(), e);
72+
eprintln!("error reading `{}`: {}", file_path.display(), e);
7673
return Err(LoadStringError::ReadFail);
7774
}
7875
match str::from_utf8(&contents) {
7976
Ok(s) => Ok(s.to_string()),
8077
Err(_) => {
81-
let _ = writeln!(&mut io::stderr(),
82-
"error reading `{}`: not UTF-8",
83-
file_path.display());
78+
eprintln!("error reading `{}`: not UTF-8", file_path.display());
8479
Err(LoadStringError::BadUtf8)
8580
}
8681
}

src/librustdoc/markdown.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use std::default::Default;
1212
use std::fs::File;
1313
use std::io::prelude::*;
14-
use std::io;
1514
use std::path::{PathBuf, Path};
1615

1716
use getopts;
@@ -75,20 +74,15 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
7574

7675
let mut out = match File::create(&output) {
7776
Err(e) => {
78-
let _ = writeln!(&mut io::stderr(),
79-
"rustdoc: {}: {}",
80-
output.display(), e);
77+
eprintln!("rustdoc: {}: {}", output.display(), e);
8178
return 4;
8279
}
8380
Ok(f) => f
8481
};
8582

8683
let (metadata, text) = extract_leading_metadata(&input_str);
8784
if metadata.is_empty() {
88-
let _ = writeln!(
89-
&mut io::stderr(),
90-
"rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`"
91-
);
85+
eprintln!("rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`");
9286
return 5;
9387
}
9488
let title = metadata[0];
@@ -138,9 +132,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
138132

139133
match err {
140134
Err(e) => {
141-
let _ = writeln!(&mut io::stderr(),
142-
"rustdoc: cannot write to `{}`: {}",
143-
output.display(), e);
135+
eprintln!("rustdoc: cannot write to `{}`: {}", output.display(), e);
144136
6
145137
}
146138
Ok(_) => 0

src/librustdoc/test.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,10 @@ impl Collector {
495495
found = entry.remove_item(&test).is_some();
496496
}
497497
if !found {
498-
let _ = writeln!(&mut io::stderr(),
499-
"WARNING: {} Code block is not currently run as a test, but will \
500-
in future versions of rustdoc. Please ensure this code block is \
501-
a runnable test, or use the `ignore` directive.",
502-
name);
498+
eprintln!("WARNING: {} Code block is not currently run as a test, but will \
499+
in future versions of rustdoc. Please ensure this code block is \
500+
a runnable test, or use the `ignore` directive.",
501+
name);
503502
return
504503
}
505504
}

src/libstd/process.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,6 @@ impl Child {
10831083
/// function and compute the exit code from its return value:
10841084
///
10851085
/// ```
1086-
/// use std::io::{self, Write};
1087-
///
10881086
/// fn run_app() -> Result<(), ()> {
10891087
/// // Application logic here
10901088
/// Ok(())
@@ -1094,7 +1092,7 @@ impl Child {
10941092
/// ::std::process::exit(match run_app() {
10951093
/// Ok(_) => 0,
10961094
/// Err(err) => {
1097-
/// writeln!(io::stderr(), "error: {:?}", err).unwrap();
1095+
/// eprintln!("error: {:?}", err);
10981096
/// 1
10991097
/// }
11001098
/// });

src/test/run-fail/mir_drop_panics.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010

1111
// error-pattern:panic 1
1212
// error-pattern:drop 2
13-
use std::io::{self, Write};
1413

1514
struct Droppable(u32);
1615
impl Drop for Droppable {
1716
fn drop(&mut self) {
1817
if self.0 == 1 {
1918
panic!("panic 1");
2019
} else {
21-
write!(io::stderr(), "drop {}", self.0);
20+
eprint!("drop {}", self.0);
2221
}
2322
}
2423
}

src/test/run-fail/mir_dynamic_drops_1.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@
99
// except according to those terms.
1010
// error-pattern:drop 1
1111
// error-pattern:drop 2
12-
use std::io::{self, Write};
1312

1413

1514
/// Structure which will not allow to be dropped twice.
1615
struct Droppable<'a>(&'a mut bool, u32);
1716
impl<'a> Drop for Droppable<'a> {
1817
fn drop(&mut self) {
1918
if *self.0 {
20-
writeln!(io::stderr(), "{} dropped twice", self.1);
19+
eprintln!("{} dropped twice", self.1);
2120
::std::process::exit(1);
2221
}
23-
writeln!(io::stderr(), "drop {}", self.1);
22+
eprintln!("drop {}", self.1);
2423
*self.0 = true;
2524
}
2625
}

src/test/run-fail/mir_dynamic_drops_2.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@
99
// except according to those terms.
1010

1111
// error-pattern:drop 1
12-
use std::io::{self, Write};
1312

1413

1514
/// Structure which will not allow to be dropped twice.
1615
struct Droppable<'a>(&'a mut bool, u32);
1716
impl<'a> Drop for Droppable<'a> {
1817
fn drop(&mut self) {
1918
if *self.0 {
20-
writeln!(io::stderr(), "{} dropped twice", self.1);
19+
eprintln!("{} dropped twice", self.1);
2120
::std::process::exit(1);
2221
}
23-
writeln!(io::stderr(), "drop {}", self.1);
22+
eprintln!("drop {}", self.1);
2423
*self.0 = true;
2524
}
2625
}

src/test/run-fail/mir_dynamic_drops_3.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@
1212
// error-pattern:drop 3
1313
// error-pattern:drop 2
1414
// error-pattern:drop 1
15-
use std::io::{self, Write};
1615

1716

1817
/// Structure which will not allow to be dropped twice.
1918
struct Droppable<'a>(&'a mut bool, u32);
2019
impl<'a> Drop for Droppable<'a> {
2120
fn drop(&mut self) {
2221
if *self.0 {
23-
writeln!(io::stderr(), "{} dropped twice", self.1);
22+
eprintln!("{} dropped twice", self.1);
2423
::std::process::exit(1);
2524
}
26-
writeln!(io::stderr(), "drop {}", self.1);
25+
eprintln!("drop {}", self.1);
2726
*self.0 = true;
2827
}
2928
}

src/test/run-fail/mir_trans_calls_converging_drops.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
// error-pattern:0 dropped
1313
// error-pattern:exit
1414

15-
use std::io::{self, Write};
16-
1715
struct Droppable(u8);
1816
impl Drop for Droppable {
1917
fn drop(&mut self) {
20-
write!(io::stderr(), "{} dropped\n", self.0);
18+
eprintln!("{} dropped", self.0);
2119
}
2220
}
2321

2422
fn converging_fn() {
25-
write!(io::stderr(), "converging_fn called\n");
23+
eprintln!("converging_fn called");
2624
}
2725

2826
fn mir(d: Droppable) {

src/test/run-fail/mir_trans_calls_converging_drops_2.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212
// error-pattern:dropped
1313
// error-pattern:exit
1414

15-
use std::io::{self, Write};
16-
1715
struct Droppable;
1816
impl Drop for Droppable {
1917
fn drop(&mut self) {
20-
write!(io::stderr(), "dropped\n");
18+
eprintln!("dropped");
2119
}
2220
}
2321

2422
// return value of this function is copied into the return slot
2523
fn complex() -> u64 {
26-
write!(io::stderr(), "complex called\n");
24+
eprintln!("complex called");
2725
42
2826
}
2927

src/test/run-fail/mir_trans_calls_diverging_drops.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
// error-pattern:diverging_fn called
1212
// error-pattern:0 dropped
1313

14-
use std::io::{self, Write};
15-
1614
struct Droppable(u8);
1715
impl Drop for Droppable {
1816
fn drop(&mut self) {
19-
write!(io::stderr(), "{} dropped", self.0);
17+
eprintln!("{} dropped", self.0);
2018
}
2119
}
2220

src/test/run-fail/panic-set-handler.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
#![feature(panic_handler)]
1414

1515
use std::panic;
16-
use std::io::{self, Write};
1716

1817
fn main() {
1918
panic::set_hook(Box::new(|i| {
20-
write!(io::stderr(), "greetings from the panic handler");
19+
eprint!("greetings from the panic handler");
2120
}));
2221
panic!("foobar");
2322
}

src/test/run-fail/panic-set-unset-handler.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
#![feature(panic_handler)]
1414

1515
use std::panic;
16-
use std::io::{self, Write};
1716

1817
fn main() {
1918
panic::set_hook(Box::new(|i| {
20-
write!(io::stderr(), "greetings from the panic handler");
19+
eprint!("greetings from the panic handler");
2120
}));
2221
panic::take_hook();
2322
panic!("foobar");

src/test/run-pass/backtrace-debuginfo.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
// ignore-pretty issue #37195
2020
// ignore-emscripten spawning processes is not supported
2121

22-
use std::io;
23-
use std::io::prelude::*;
2422
use std::env;
2523

2624
#[path = "backtrace-debuginfo-aux.rs"] mod aux;
@@ -163,7 +161,7 @@ fn main() {
163161
let args: Vec<String> = env::args().collect();
164162
if args.len() >= 2 {
165163
let case = args[1].parse().unwrap();
166-
writeln!(&mut io::stderr(), "test case {}", case).unwrap();
164+
eprintln!("test case {}", case);
167165
outer(case, pos!());
168166
println!("done.");
169167
} else {

src/tools/tidy/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ macro_rules! t {
3333

3434
macro_rules! tidy_error {
3535
($bad:expr, $fmt:expr, $($arg:tt)*) => ({
36-
use std::io::Write;
3736
*$bad = true;
38-
write!(::std::io::stderr(), "tidy error: ").expect("could not write to stderr");
39-
writeln!(::std::io::stderr(), $fmt, $($arg)*).expect("could not write to stderr");
37+
eprint!("tidy error: ");
38+
eprintln!($fmt, $($arg)*);
4039
});
4140
}
4241

src/tools/tidy/src/main.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use tidy::*;
2222
use std::process;
2323
use std::path::PathBuf;
2424
use std::env;
25-
use std::io::{self, Write};
2625

2726
fn main() {
2827
let path = env::args_os().skip(1).next().expect("need an argument");
@@ -44,7 +43,7 @@ fn main() {
4443
}
4544

4645
if bad {
47-
writeln!(io::stderr(), "some tidy checks failed").expect("could not write to stderr");
46+
eprintln!("some tidy checks failed");
4847
process::exit(1);
4948
}
5049
}

0 commit comments

Comments
 (0)