Uh oh!
There was an error while loading. Please reload this page.
Add pager support for rustc --explain EXXXX - #42732
Conversation
rust-highfive
commented
Jun 18, 2017
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
cengiz-io
commented
Jun 18, 2017
Oh and I had problems during switching |
There was a problem hiding this comment.
Since it's quite easy, could we use var_os here (and in the companion windows function)?
There was a problem hiding this comment.
hm, I think ideally we'd send this to stderr and (as in all other cases in this function) send the output to stdout. We shouldn't ever not show the output because a pager is missing.
carols10cents
commented
Jun 19, 2017
Looks like this isn't compiling? https://travis-ci.org/rust-lang/rust/jobs/244227954#L1476 |
There was a problem hiding this comment.
I think the reason this is failing on Windows is the use of output() here. output() captures stdout which we definitely don't want, it should go to the console so using status() might be better. However as more.com and less accept input over stdin you should be able to do something like the following and avoid creating a file:
letmut child = Command::new(pager).stdin(Stdio::piped()).spawn()?;
child.stdin.as_mut().unwrap().write_all(content.as_bytes())?;
child.wait()There was a problem hiding this comment.
@ollie27 I have tried to use pipes with Command but the 'less' output was corrupted in Linux bash shell. Maybe it was something that I missed. Will try this first thing in the morning.
Thanks a lot
cengiz-io
commented
Jun 22, 2017
@carols10cents thanks for the heads up |
cengiz-io
commented
Jun 22, 2017
It's been a very busy week. Sorry for the delay. A revision will be ready next morning |
bors
commented
Jun 23, 2017
☔ The latest upstream changes (presumably #42856) made this pull request unmergeable. Please resolve the merge conflicts. |
kennytm
commented
Jun 28, 2017
LLVM and Cargo updated by mistake? Also, tidy error. |
cengiz-io
commented
Jun 28, 2017
@kennytm sorry. I was trying to update my fork only. thanks for notifying. fix is coming |
kennytm
commented
Jun 29, 2017
@cengizio Thanks. LLVM and Cargo submodules are still modified in 14b28d0af5c970414f8a8bb681da13b36d5fb658 though. |
cengiz-io
commented
Jun 29, 2017
@kennytm now it should be clear 😌 |
There was a problem hiding this comment.
@Mark-Simulacrum I hope this is the right way of using OsStrings
There was a problem hiding this comment.
Yes, I believe so, but unwrap_or_else please.
There was a problem hiding this comment.
Why do we need a unwrap_or_else here?
There was a problem hiding this comment.
OsString is heap allocated, and with unwrap_or the heap allocation always happens even if not necessary.
There was a problem hiding this comment.
Makes sense now. Added!
There was a problem hiding this comment.
@Mark-Simulacrum as you suggested, now we're falling back to plain printing whenever something goes wrong. And not printing anything to stdout if there's an error.
There was a problem hiding this comment.
@carols10cents maybe this can be prettier. Suggestions?
There was a problem hiding this comment.
IMO It's ok to do that push(). Though you are doing it here and in like 375, so you are adding a carriage return regardless of the if statement, I would just put a single one between lines 376-377 instead, but that is totally a nitpick.
There was a problem hiding this comment.
UI test failure. Please either change this to print! or update src/test/ui/explain.stdout to include the new trailing \n.
afiune
commented
Jun 29, 2017
| text.push_str(line); | ||
| text.push('\n'); | ||
| } | ||
| text.push('\n'); |
cengiz-io
commented
Jun 29, 2017
@carols10cents I think we can remove the waiting tag and proceed to reviewing |
Mark-Simulacrum
commented
Jun 29, 2017
@bors r+ rollup |
bors
commented
Jun 29, 2017
📌 Commit d2a0ead has been approved by |
Add pager support for `rustc --explain EXXXX` Hello! This is my take on rust-lang#32665. Thanks! **EDIT:** _I've limited access to a Windows machine so this is taking longer than I've anticipated_. 🐢 cc @alexcrichton@nikomatsakis@Mark-Simulacrum@retep998@ollie27@afiune
Add pager support for `rustc --explain EXXXX` Hello! This is my take on rust-lang#32665. Thanks! **EDIT:** _I've limited access to a Windows machine so this is taking longer than I've anticipated_. 🐢 cc @alexcrichton@nikomatsakis@Mark-Simulacrum@retep998@ollie27@afiune
Add pager support for `rustc --explain EXXXX` Hello! This is my take on rust-lang#32665. Thanks! **EDIT:** _I've limited access to a Windows machine so this is taking longer than I've anticipated_. 🐢 cc @alexcrichton@nikomatsakis@Mark-Simulacrum@retep998@ollie27@afiune
Mark-Simulacrum
commented
Jun 30, 2017
ahh @bors r- |
Perhaps if rustc isn't outputting directly to terminal or console (if isatty returns false) then it shouldn't try to use a pager. I think that would fix the test. |
cengiz-io
commented
Jun 30, 2017
@ollie27@Mark-Simulacrum@kennytm I'll modify the test as soon as possible. Thanks |
There was a problem hiding this comment.
@Mark-Simulacrum I'm not 100% sure about the version here. Should I make it strict?
There was a problem hiding this comment.
Cargo.lock will handle that for you. I don't know if you need this dependency though, I believe you can find equivalent code in rustbuild (search for cfg(Windows)) and possibly in librustc_errors... I'd prefer not to depend on isatty since that means winapi which currently has long build times.
cengiz-io
commented
Jul 2, 2017
@kennytm@ollie27@Mark-Simulacrum I've added I've only tried it with Windows. *nix part needs to be tested. Please feel free to comment on anything. Thank you |
There was a problem hiding this comment.
Could you use a line comments here? Also, you'll need to remove isatty from Cargo.lock/Cargo.toml.
cengiz-io
commented
Jul 3, 2017
Ok, tty check is done with an embedded logic. |
cengiz-io
commented
Jul 4, 2017
@Mark-Simulacrum I've tested with *nix and it behaves correctly. We can review and proceed accordingly. |
Mark-Simulacrum
commented
Jul 4, 2017
Looks good to me. Thanks! @bors r+ rollup |
bors
commented
Jul 4, 2017
📌 Commit 06de114 has been approved by |
bors
commented
Jul 4, 2017
Add pager support for `rustc --explain EXXXX` Hello! Fixes#32665. Thanks! **EDIT:** _I've limited access to a Windows machine so this is taking longer than I've anticipated_. 🐢 cc @alexcrichton@nikomatsakis@Mark-Simulacrum@retep998@ollie27@afiune
bors
commented
Jul 5, 2017
☀️ Test successful - status-appveyor, status-travis |

Hello!
Fixes#32665.
Thanks!
EDIT:I've limited access to a Windows machine so this is taking longer than I've anticipated. 🐢
cc @alexcrichton@nikomatsakis@Mark-Simulacrum@retep998@ollie27@afiune