Uh oh!
There was an error while loading. Please reload this page.
Add hint about the return code of panic! - #42670
Conversation
rust-highfive
commented
Jun 15, 2017
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
sfackler
commented
Jun 15, 2017
cc @rust-lang/docs |
| /// The multi-argument form of this macro panics with a string and has the | ||
| /// `format!` syntax for building a string. | ||
| /// | ||
| /// If the main thread panics it will return with code `101`. |
There was a problem hiding this comment.
Is this something that is guaranteed to happen across all platforms?
There was a problem hiding this comment.
it's currently hard-coded; I don't know if we want to commit to this
@rust-lang/lang
steveklabnik
left a comment
There was a problem hiding this comment.
This seems fine but I'm not sure we want to lock into 101
| /// The multi-argument form of this macro panics with a string and has the | ||
| /// `format!` syntax for building a string. | ||
| /// | ||
| /// If the main thread panics it will return with code `101`. |
There was a problem hiding this comment.
it's currently hard-coded; I don't know if we want to commit to this
@rust-lang/lang
dns2utf8
commented
Jun 16, 2017
Is there a particular reason for this return code? |
frewsxcv
commented
Jun 16, 2017
Something also to consider: although unusual, it's possible to catch panics, in which case this error code mention doesn't really apply |
withoutboats
commented
Jun 16, 2017
Seems like we can't change the default, people may be relying on it. Someday maybe we could let you set the error code, no idea how though. |
alexcrichton
commented
Jun 22, 2017
This seems like a case where we want to document the current behavior but not commit to it. We've done this a few other places in libstd, can we say what happens today and then explicitly state that it may change in the future? |
steveklabnik
commented
Jun 22, 2017
@alexcrichton yeah we've done in the past, could do that here as well. See https://doc.rust-lang.org/stable/std/primitive.slice.html#current-implementation |
steveklabnik
commented
Jul 5, 2017
@dns2utf8 ping! Any chance to update this PR according to the most recent comments? |
dns2utf8
commented
Jul 5, 2017
Yes, I will make it according to "current implementation" |
I think setting the error code could be done with the macro. Maybe something like this: panic!("my {} panic","fancy" -> 23);Where 23 would be the returned error code. The |
dns2utf8
commented
Jul 5, 2017
I noticed something odd Using the following program but the return code is #include<stdlib.h>intmain() {
// this will make the programm return 134 on linux-amd64 platformabort();
return42;
} |
joshtriplett
commented
Jul 5, 2017
@dns2utf8 134 is the return code for a SIGABRT: |
dns2utf8
commented
Jul 5, 2017
Interesting, I did not know that. |
arielb1
commented
Jul 11, 2017
You have an overly-long line, please fix: I'll also ping @steveklabnik for a review. |
dns2utf8
commented
Jul 11, 2017
Cool, thank you. |
steveklabnik
commented
Jul 11, 2017
@bors: r+ rollup |
bors
commented
Jul 11, 2017
📌 Commit 133c1bc has been approved by |
…klabnik Add hint about the return code of panic! I hope the link works on all cases, since the `unreachable` doc is copied to `std::` as well.
I hope the link works on all cases, since the
unreachabledoc is copied tostd::as well.