-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Migrate to eprint/eprintln macros where appropriate. #44822
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
Conversation
aac119a
to
f64df80
Compare
src/librustdoc/markdown.rs
Outdated
&mut io::stderr(), | ||
"rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`" | ||
); | ||
eprintln("rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing !
.
[00:34:43] error[E0423]: expected function, found macro `eprintln`
[00:34:43] --> /checkout/src/librustdoc/markdown.rs:84:9
[00:34:43] |
[00:34:43] 84 | eprintln("rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`");
[00:34:43] | ^^^^^^^^ did you mean `eprintln!(...)`?
src/librustdoc/externalfiles.rs
Outdated
"error reading `{}`: not UTF-8", | ||
file_path.display()); | ||
let _ = eprintln!("error reading `{}`: not UTF-8", | ||
file_path.display()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the let _ =
. (Same for a few lines above)
Also, the use std::io;
is no longer needed.
[00:34:44] error: unused import: `std::io`
[00:34:44] --> /checkout/src/librustdoc/externalfiles.rs:13:5
[00:34:44] |
[00:34:44] 13 | use std::io;
[00:34:44] | ^^^^^^^
[00:34:44] |
src/librustdoc/markdown.rs
Outdated
let _ = writeln!(&mut io::stderr(), | ||
"rustdoc: {}: {}", | ||
output.display(), e); | ||
let _ = eprintln!("rustdoc: {}: {}", output.display(), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove let _ =
.
src/librustdoc/markdown.rs
Outdated
"rustdoc: cannot write to `{}`: {}", | ||
output.display(), e); | ||
let _ = eprintln!("rustdoc: cannot write to `{}`: {}", | ||
output.display(), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove let _ =
src/librustdoc/test.rs
Outdated
in future versions of rustdoc. Please ensure this code block is \ | ||
a runnable test, or use the `ignore` directive.", | ||
name); | ||
let _ = eprintln!("WARNING: {} Code block is not currently run as a test, but will \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove let _ =
src/librustdoc/markdown.rs
Outdated
@@ -10,8 +10,6 @@ | |||
|
|||
use std::default::Default; | |||
use std::fs::File; | |||
use std::io::prelude::*; | |||
use std::io; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The std::io::Write
trait is still needed somewhere.
[00:34:47] error[E0599]: no method named `write_fmt` found for type `&mut std::fs::File` in the current scope
[00:34:47] --> /checkout/src/librustdoc/markdown.rs:97:15
[00:34:47] |
[00:34:47] 97 | let err = write!(
[00:34:47] | _______________^
[00:34:47] 98 | | &mut out,
[00:34:47] 99 | | r#"<!DOCTYPE html>
[00:34:47] 100 | | <html lang="en">
[00:34:47] ... |
[00:34:47] 129 | | after_content = external_html.after_content,
[00:34:47] 130 | | );
[00:34:47] | |_________^
[00:34:47] |
[00:34:47] = help: items from traits can only be used if the trait is in scope
[00:34:47] = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
[00:34:47] candidate #1: `use std::io::Write;`
[00:34:47] = note: this error originates in a macro outside of the current crate
c201487
to
f48c58e
Compare
r? @nrc |
src/librustdoc/externalfiles.rs
Outdated
@@ -9,8 +9,6 @@ | |||
// except according to those terms. | |||
|
|||
use std::fs::File; | |||
use std::io::prelude::*; | |||
use std::io; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this needs std::io::Read
as well...
[00:33:33] error[E0599]: no method named `read_to_end` found for type `std::fs::File` in the current scope
[00:33:33] --> /checkout/src/librustdoc/externalfiles.rs:69:43
[00:33:33] |
[00:33:33] 69 | .and_then(|mut f| f.read_to_end(&mut contents));
[00:33:33] | ^^^^^^^^^^^
[00:33:33] |
[00:33:33] = help: items from traits can only be used if the trait is in scope
[00:33:33] = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
[00:33:33] candidate #1: `use std::io::Read;`
f48c58e
to
cb214c4
Compare
@@ -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).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary unwrap()
.
[00:47:00] ---- [run-pass] run-pass/backtrace-debuginfo.rs stdout ----
[00:47:00]
[00:47:00] error: compilation failed!
[00:47:00] status: exit code: 101
[00:47:00] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/backtrace-debuginfo.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--target=x86_64-unknown-linux-gnu" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/backtrace-debuginfo.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-g" "-Cllvm-args=-enable-tail-merge=0" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/backtrace-debuginfo.stage2-x86_64-unknown-linux-gnu.run-pass.libaux"
[00:47:00] stdout:
[00:47:00] ------------------------------------------
[00:47:00]
[00:47:00] ------------------------------------------
[00:47:00] stderr:
[00:47:00] ------------------------------------------
[00:47:00] error[E0599]: no method named `unwrap` found for type `()` in the current scope
[00:47:00] --> /checkout/src/test/run-pass/backtrace-debuginfo.rs:164:41
[00:47:00] |
[00:47:00] 164 | eprintln!("test case {}", case).unwrap();
[00:47:00] | ^^^^^^
[00:47:00]
[00:47:00] error: aborting due to previous error
[00:47:00]
[00:47:00]
[00:47:00] ------------------------------------------
[00:47:00]
[00:47:00] thread '[run-pass] run-pass/backtrace-debuginfo.rs' panicked at 'explicit panic', /checkout/src/tools/compiletest/src/runtest.rs:2433:8
[00:47:00] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:47:00]
[00:47:00]
[00:47:00] failures:
[00:47:00] [run-pass] run-pass/backtrace-debuginfo.rs
[00:47:00]
[00:47:00] test result: FAILED. 2761 passed; 1 failed; 8 ignored; 0 measured; 0 filtered out
00a378e
to
db5de84
Compare
finally got a green checkmark here |
src/tools/tidy/src/lib.rs
Outdated
*$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!("some tidy checks failed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intent to change this from "tidy error: "
to "some tidy checks failed"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, good catch! Fixed in the latest force push
db5de84
to
8ef5447
Compare
Hey, @nrc, will you have a chance to get to this soon? |
@bors: r+ |
📌 Commit 8ef5447 has been approved by |
@frewsxcv Did you test if the instances that end up in |
Migrate to eprint/eprintln macros where appropriate. None
☀️ Test successful - status-appveyor, status-travis |
No description provided.