Uh oh!
There was an error while loading. Please reload this page.
Relax termination_trait's error bound - #47544
Conversation
rust-highfive
commented
Jan 18, 2018
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @shepmaster (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
bkchr
commented
Jan 18, 2018
@U007D could you add a test with the following main: |
Done, for the positive ( fnmain() -> Result<(),Box<Error>>{Ok(())}I'd also like to test the negative ( fnmain() -> Result<(),Box<Error>>{Err(Box::new(Error::new(ErrorKind::Other,"returned Box<Error> from main()")))}but after looking at spending some time with both Let me know if you know a way to include the negative test--with just the positive case, at least we know it compiles... :) |
bkchr
commented
Jan 19, 2018
@U007D Please add the negative case also :) Add the test to |
@bkchr I tried, and it didn't. Near as I can tell, it was expecting a panic, not a non-zero status code. I also tried:
All failed for me. :( |
bkchr
commented
Jan 19, 2018
@U007D Look at |
U007D
commented
Jan 19, 2018
Sweet. I'll try that. |
bkchr
commented
Jan 19, 2018
Ahh, I think that is wrong :( Are you somewhere on irc or so? |
// error-pattern:nonzero#![feature(termination_trait)]use std::io::{Error,ErrorKind};fnmain() -> Result<(),Box<Error>>{Err(Box::new(Error::new(ErrorKind::Other,"returned Box<Error> from main()")))}gives: Any ideas? |
@bkchr I am--U007D on irc.mozilla.org. ( |
@bkchr Well, it's past midnight here--I think I'll call it a night. You can leave any ideas you may have here or |
bkchr
commented
Jan 19, 2018
@U007D I would propose the following patch for And as test just: |
Thanks, @bkchr, that was helpful. I ended up having to do a couple of hours of poking around to make it work: In Once I figured out which way was was up ;), your patch worked like a charm and the solution ended up being simple--it was a good learning process for me :). TL;DR: There is now a negative test and it passes. :) |
I also have the change ready for index dc7fa53aab..f2ae7e99df 100644
--- a/src/libstd/termination.rs
+++ b/src/libstd/termination.rs
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed// except according to those terms.
-use fmt::Debug;
+use fmt::Display;#[cfg(target_arch = "wasm32")]mod exit {pubconstSUCCESS:i32 = 0;
@@ -45,12 +45,12 @@ implTerminationfor(){}#[unstable(feature = "termination_trait", issue = "43301")]
-impl<T:Termination,E:Debug> TerminationforResult<T,E>{
+impl<T:Termination,E:Display> TerminationforResult<T,E>{fn report(self) -> i32{matchself{Ok(val) => val.report(),Err(err) => {
- eprintln!("Error: {:?}", err);
+ eprintln!("Error: {}", err);
exit::FAILURE}}But I don't know the process well enough (i.e. does feature gating let us try different implementations on for size to see how we like them, or for stability's sake, do we make the decision before pushing the change?, How much consensus is needed first? etc.) to push it until someone gives me the go-ahead. |
| if proc_res.status.success() { | ||
| self.fatal_proc_rec( | ||
| &format!("failure produced the wrong error: {}", proc_res.status), | ||
| &format!("failure must not return success exit status! Returned status: {}", |
There was a problem hiding this comment.
If the branch is taken, the error code is always 0, so printing it is not required ;)
withoutboats
commented
Jan 19, 2018
The PR won't be merged until we reach a preliminary decision, its not particularly important what is pushed to your branch (you just might have to revert it). |
U007D
commented
Jan 19, 2018
@withoutboats Ah, great. I'll just go ahead and push my preferred impl, and will wait to hear back from folks re: feedback. And thanks for that information! |
scottmcm
commented
Jan 26, 2018
Another thought, here -- if part of the goal here is to let people turn |
withoutboats
commented
Jan 31, 2018
Nominated to talk about |
withoutboats
commented
Feb 8, 2018
Lang team met today and discussed this. We agreed that this should use the We're also open to PRs to improve the readability of Debug impls on error types in std :) |
U007D
commented
Feb 8, 2018
Ok, I'll roll back the last commit and will re-submit with Haha--I'm not sure I'm up for a PR just yet! ;) But I'll definitely continue to look for areas I can contribute. Thanks for all your guidance! |
…est header command and appropriate tests
nikomatsakis
commented
Feb 13, 2018
@bors r+ |
bors
commented
Feb 13, 2018
📌 Commit 7948afd has been approved by |
bors
commented
Feb 16, 2018
⌛ Testing commit 7948afd with merge d5cf0de2663003c2b9e3a42b95c1e1f846fc7f69... |
bors
commented
Feb 16, 2018
💔 Test failed - status-travis |
kennytm
commented
Feb 17, 2018
@bors retry |
bors
commented
Feb 17, 2018
⌛ Testing commit 7948afd with merge fc30141e836b571eaca4976f2f771e6cf81543ad... |
bors
commented
Feb 18, 2018
💔 Test failed - status-appveyor |
kennytm
commented
Feb 18, 2018
@bors retry 3 hour timeout |
bors
commented
Feb 18, 2018
Relax termination_trait's error bound As per [this conversation](https://github.com/withoutboats/failure/issues/130#issuecomment-358572413) with @withoutboats and @bkchr
bors
commented
Feb 18, 2018
☀️ Test successful - status-appveyor, status-travis |
Thanks, @kennytm, for getting this landed! :) FYI, I tried using the feature on Playground but it Update: fixed link to demo panic. Playground reports: The same code running on my machine compiles and runs successfully. |
shepmaster
commented
Feb 19, 2018
Seems to work for me. What kind of panic are you seeing? |
Running the code from the run-pass test was enough to get it to panic for me. I've fixed the link to reproduce the panic. |
kennytm
commented
Feb 20, 2018
@U007D please file an issue |
U007D
commented
Feb 20, 2018
Took my best guess and filed it here. |
As per this conversation with @withoutboats and @bkchr