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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 7 deletions
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

Lines changed: 3 additions & 11 deletions
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

Lines changed: 4 additions & 5 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 2 additions & 3 deletions
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
}

0 commit comments

Comments
 (0)