Skip to content

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

Merged
merged 1 commit into from
Oct 10, 2017

Conversation

frewsxcv
Copy link
Member

No description provided.

&mut io::stderr(),
"rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`"
);
eprintln("rustdoc: invalid markdown file: no initial lines starting with `# ` or `%`");
Copy link
Member

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!(...)`?

"error reading `{}`: not UTF-8",
file_path.display());
let _ = eprintln!("error reading `{}`: not UTF-8",
file_path.display());
Copy link
Member

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]    |

let _ = writeln!(&mut io::stderr(),
"rustdoc: {}: {}",
output.display(), e);
let _ = eprintln!("rustdoc: {}: {}", output.display(), e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove let _ = .

"rustdoc: cannot write to `{}`: {}",
output.display(), e);
let _ = eprintln!("rustdoc: cannot write to `{}`: {}",
output.display(), e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove let _ =

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 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove let _ =

@@ -10,8 +10,6 @@

use std::default::Default;
use std::fs::File;
use std::io::prelude::*;
use std::io;
Copy link
Member

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

@frewsxcv frewsxcv force-pushed the frewsxcv-eprintln branch 2 times, most recently from c201487 to f48c58e Compare September 25, 2017 11:13
@carols10cents
Copy link
Member

r? @nrc

@carols10cents carols10cents added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 25, 2017
@@ -9,8 +9,6 @@
// except according to those terms.

use std::fs::File;
use std::io::prelude::*;
use std::io;
Copy link
Member

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;`

@@ -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();
Copy link
Member

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

@arielb1 arielb1 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 26, 2017
@frewsxcv frewsxcv force-pushed the frewsxcv-eprintln branch 2 times, most recently from 00a378e to db5de84 Compare September 27, 2017 01:34
@frewsxcv
Copy link
Member Author

finally got a green checkmark here

*$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");
Copy link
Member

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"?

Copy link
Member Author

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

@carols10cents carols10cents added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 2, 2017
@shepmaster
Copy link
Member

Hey, @nrc, will you have a chance to get to this soon?

@shepmaster
Copy link
Member

A birdie told me that @nrc is on leave for a bit, so let's pick someone from the libs team... r? @Kimundi

@rust-highfive rust-highfive assigned Kimundi and unassigned nrc Oct 6, 2017
@Kimundi
Copy link
Member

Kimundi commented Oct 9, 2017

@bors: r+

@bors
Copy link
Collaborator

bors commented Oct 9, 2017

📌 Commit 8ef5447 has been approved by Kimundi

@michaelwoerister
Copy link
Member

@frewsxcv Did you test if the instances that end up in rustc actually print something? I never had any luck with that. I suspect that libterm somehow interferes with stderr. Then again, looking at the changes, it probably didn't work before either in those cases.

@bors
Copy link
Collaborator

bors commented Oct 10, 2017

⌛ Testing commit 8ef5447 with merge 13ae187...

bors added a commit that referenced this pull request Oct 10, 2017
Migrate to eprint/eprintln macros where appropriate.

None
@bors
Copy link
Collaborator

bors commented Oct 10, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: Kimundi
Pushing 13ae187 to master...

@bors bors merged commit 8ef5447 into rust-lang:master Oct 10, 2017
@frewsxcv frewsxcv deleted the frewsxcv-eprintln branch October 10, 2017 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants