Skip to content
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

implement #[panic_implementation] #50338

Merged
merged 12 commits into from Jun 3, 2018

Conversation

@japaric
Copy link
Member

japaric commented Apr 30, 2018

This implements the #[panic_implementation] attribute as instructed in #44489 (comment)

I haven't run the full test suite yet but at least all the compile-fail tests pass.

r? @nagisa


#[cfg(not(stage0))]
#[allow(improper_ctypes)] // PanicInfo contains a trait object which is not FFI safe
extern "C" {

This comment has been minimized.

@SimonSapin

SimonSapin Apr 30, 2018

Contributor

Why not extern "Rust"? Would that solve the improper_ctypes warning?

This comment has been minimized.

@japaric

japaric Apr 30, 2018

Author Member

The lint seems to apply regardless of the ABI ("C" or "Rust").

This comment has been minimized.

@nagisa

nagisa Apr 30, 2018

Contributor

The comment should indicate why it is fine to pass such an object anyway (it never actually passes a FFI boundary and is a Rust-to-Rust call)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Apr 30, 2018

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:47:12] .................................i..................................................................
[00:47:24] ..................................................................i.................................
[00:47:37] .....................................................i..............................................
[00:47:54] ....................................................................................................
[00:48:12] ........................................................F...........................................
[00:48:50] ...............i....................................................................................
[00:49:18] .............i......................................................................................
[00:49:25] ..............test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:49:49] ......................................................................................
---
[00:52:55] failures:
[00:52:55] 
[00:52:55] ---- [run-pass] run-pass/macro-comma-behavior.rs stdout ----
[00:52:55]  
[00:52:55] error in revision `core`: test run failed!
[00:52:55] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/macro-comma-behavior.stage2-x86_64-unknown-linux-gnu"
[00:52:55] stdout:
[00:52:55] ------------------------------------------
[00:52:55] 
[00:52:55] 
[00:52:55] running 3 tests
[00:52:55] test debug_assert_1arg ... FAILED
[00:52:55] test to_format_or_not_to_format ... ok
[00:52:55] test assert_1arg ... FAILED
[00:52:55] failures:
[00:52:55] failures:
[00:52:55n-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-pass" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:52:55] 
[00:52:55] 
[00:52:55] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:52:55] Build completed unsuccessfully in 0:13:18
[00:52:55] Build completed unsuccessfully in 0:13:18
[00:52:55] Makefile:58: recipe for target 'check' failed
[00:52:55] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/incremental
111308 ./obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu
111308 ./obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu
111304 ./obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release
107420 ./obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps
102820 ./obj/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends
102808 ./obj/build/bootstrap/debug/incremental/bootstrap-2wettvttcntnm
102804 ./obj/build/bootstrap/debug/incremental/bootstrap-2wettvttcntnm/s-f0lgpm65kh-1jc4cti-v7hez0f2m5v0
90744 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/incremental/core-31lccp6wy7orz
90744 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/incremental/core-31lccp6wy7orz
90740 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/incremental/core-31lccp6wy7orz/s-f0lgn98ibl-4n1z2x-q6snowoabdxz
89896 ./obj/build/x86_64-unknown-linux-gnu/stage1/lib
89684 ./src/llvm/test/CodeGen
86672 ./obj/build/x86_64-unknown-linux-gnu/doc/core
84688 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nagisa
Copy link
Contributor

nagisa left a comment

The travis failure has to be fixed as well. The failure seems pretty weird for the changes in this PR.


#[cfg(not(stage0))]
#[allow(improper_ctypes)] // PanicInfo contains a trait object which is not FFI safe
extern "C" {

This comment has been minimized.

@nagisa

nagisa Apr 30, 2018

Contributor

The comment should indicate why it is fine to pass such an object anyway (it never actually passes a FFI boundary and is a Rust-to-Rust call)

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Apr 30, 2018

The changes look good otherwise.

#[cfg(not(stage0))]
#[cold] #[inline(never)]
pub fn panic_fmt(fmt: fmt::Arguments, file_line_col: &(&'static str, u32, u32)) -> ! {
struct NoPayload;

This comment has been minimized.

@fbstj

fbstj Apr 30, 2018

Contributor

is this "null" payload used?

@japaric

This comment has been minimized.

Copy link
Member Author

japaric commented May 1, 2018

The travis failure has to be fixed as well.

I fixed those.


I seem to have broken a bit the panicking (/ unwinding?) stuff; I'm seeing some proc-macro related tests fail. I won't have time to dig further any time soon but here's the list of failing tests if someone wants to investigate:

  • ui-fulldeps/proc-macro/load-panic.rs -- there's some extra test in the stderr output:
    "thread .. panicked .."

  • run-pass-fulldeps/compiler-calls.rs -- "cannot access a scoped thread local variable without
    calling set first', /home/japaric/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.1/src/lib.rs:186:9"

  • run-pass-fulldeps/proc-macro/modify-ast.rs -- "proc_macro::__internal::with_sess() called before
    set_parse_sess()!"

  • run-pass-fulldeps/proc-macro/span-api-tests.rs -- "proc_macro::__internal::with_sess() called
    before set_parse_sess()!"


#[cfg(not(stage0))]
#[cold] #[inline(never)]
pub fn panic_payload<M>(msg: M, file_line_col: &(&'static str, u32, u32)) -> !

This comment has been minimized.

@alexcrichton

alexcrichton May 1, 2018

Member

I forget, but is this something we want to enable for libcore? I thought that we didn't have a path to actually supporting this yet?

(support in the sense of transmitting the value all the way to the caught value of thread::spawn)

This comment has been minimized.

@japaric

japaric May 16, 2018

Author Member

I forget, but is this something we want to enable for libcore?

Well, this (adding payload support to core::panic!) is in the accepted RFC. Though we don't have to add it right now; we can stabilize #[panic_implementation] w/o payload support and add payload support later on in a backwards compatible fashion (or at least I think it's possible).

@@ -1148,6 +1148,48 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
}
}

// Check that a function marked as `#[panic_implementation]` has signature `fn(&PanicInfo) -> !`

This comment has been minimized.

@alexcrichton

alexcrichton May 1, 2018

Member

I'm personally more of a fan of generating AST nodes which correspond to the structure we want which avoids reaching into the internals of the typechecker where possible. For example I don't think this disallows something like this:

#[panic_implementation]
fn foo<T>(a: &PanicInfo) -> ! {
}

right?

I was thinking that we'd basically expand #[panic_implementation] to #[lang = "panic_impl"] where the lang item internally dispatches to #[panic_implementation] (automatically typechecking it along the way). That may be slightly more difficult to architect, though, but I'm curious what you think

This comment has been minimized.

@nagisa

nagisa May 1, 2018

Contributor

The language items are not type-checked at all at the moment, so there is nothing to hand the type-checking over to.

panic_fmt has no benefits over the new language item and IIRC (from when I wrote the instructions) complicates the implementation of this feature unnecessarily.

This comment has been minimized.

@alexcrichton

alexcrichton May 1, 2018

Member

Right yeah, my point is that we generate a language item which internally dispatches to the function annotated #[panic_implementation], which by construction will typecheck the panic implementation and not require typechekcing of lang ites.

This comment has been minimized.

@japaric

japaric May 16, 2018

Author Member

@alexcrichton you mean something like this?

// this
// (signature is totally wrong)
#[panic_implementation]
fn foo<T>(pi: &i32) {
    // body
}

// expands into
#[lang = "panic_impl"]
fn __secret_name_maybe(pi: &PanicInfo) -> ! {
    // user input
    fn foo<T>(pi: &i32) {
        // body
    }

    let f: fn(&PanicInfo) -> ! = foo;
    f()
}

That would work typechecking wise, but will it report error messages with meaningful spans? (My experience with proc macros says that most errors will wrongly report the whole #[panic_implementation] item as their span)

This comment has been minimized.

@japaric

japaric May 16, 2018

Author Member

I don't think this disallows something like this:
fn foo(a: &PanicInfo) -> ! {

I can add a check and test to reject that.

This comment has been minimized.

@alexcrichton

alexcrichton May 17, 2018

Member

@japaric yeah that latter idea is what I was thinking, where basically the compiler manufactures the actual lang item which is hooked up to call the #[panic_implementation]. That way the compiler has full control over ABI and whatnot

This comment has been minimized.

@nagisa

nagisa May 28, 2018

Contributor

Sadly in many cases this approach results in kind-of suboptimal errors.

For example

fn foo() {
    fn bar<T>(i: i32) -> ! { loop {} }
    let foo: fn(i32) -> ! = bar;
}

gives

error[E0282]: type annotations needed
 --> src/main.rs:3:29
  |
3 |     let foo: fn(i32) -> ! = bar;
  |                             ^^^ cannot infer type for `T`

but if expanded within a macro it would be something like this instead:

error[E0282]: type annotations needed
 --> src/main.rs:3:29
  |
3 |     #[panic_implementation]
  |     fn panic<T>(...) -> ! { loop {} }
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `T`

which is just… incomprehensible.

That being said, I have a long time wish to eventually implement universal checking of the language item signatures (similar to one we do for intrinsics), which would resolve this issue universally. Thus, I’d recommend going for the simplest complete approach possible for now.

@@ -180,7 +180,7 @@ fn default_hook(info: &PanicInfo) {

let location = info.location().unwrap(); // The current implementation always returns Some

let msg = match info.payload().downcast_ref::<&'static str>() {
let msg = match info.payload().downcast_ref::<&str>() {

This comment has been minimized.

@alexcrichton

alexcrichton May 1, 2018

Member

How come this was necessary? I thought Any-style things could only be with 'static types?

@bors

This comment has been minimized.

Copy link
Contributor

bors commented May 1, 2018

☔️ The latest upstream changes (presumably #49789) made this pull request unmergeable. Please resolve the merge conflicts.

@shepmaster

This comment has been minimized.

Copy link
Member

shepmaster commented May 6, 2018

Ping from triage, @japaric ! You've got merge conflicts and some review comments pending.

@pietroalbini

This comment has been minimized.

Copy link
Member

pietroalbini commented May 14, 2018

Ping from triage @japaric! Will you have time to work on this soon?

@japaric japaric force-pushed the japaric:panic-impl branch 2 times, most recently from 6cbc8af to 5830bc2 May 16, 2018

@japaric

This comment has been minimized.

Copy link
Member Author

japaric commented May 16, 2018

I have reverted the payload in core::panic! stuff hoping that it makes this PR less controversial. See also #50338 (comment).

This has been rebased and passes the test suite when using stage 2. Turns out all the weird errors around proc-macros that I was seeing only occur when testing stage 1 (x.py test --stage 1) so I actually didn't break unwinding.

r? @alexcrichton

@rust-highfive rust-highfive assigned alexcrichton and unassigned nagisa May 16, 2018

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented May 17, 2018

Could some tests also be added for situations like:

  • Linking a #[panic_implementation] with libstd should be an error
  • Linking two #[panic_implementation] crates together should be an error
  • A transitive crate can come in and provide #[panic_implementation]
@bors

This comment has been minimized.

Copy link
Contributor

bors commented May 17, 2018

☔️ The latest upstream changes (presumably #50629) made this pull request unmergeable. Please resolve the merge conflicts.

@pietroalbini

This comment has been minimized.

Copy link
Member

pietroalbini commented May 28, 2018

Ping from triage @japaric! The reviewer provided some feedback, do you have time to address it?

@japaric japaric force-pushed the japaric:panic-impl branch from 5830bc2 to 5d0e2c2 May 29, 2018

@japaric

This comment has been minimized.

Copy link
Member Author

japaric commented May 29, 2018

@alexcrichton requested tests have been added. r?

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented May 29, 2018

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.

[00:05:15] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:05:15] tidy error: /checkout/src/librustc_typeck/check/mod.rs:1170: line longer than 100 chars
[00:05:16] some tidy checks failed
[00:05:16] 
[00:05:16] 
[00:05:16] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:05:16] 
[00:05:16] 
[00:05:16] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:16] Build completed unsuccessfully in 0:02:03
[00:05:16] Build completed unsuccessfully in 0:02:03
[00:05:16] make: *** [tidy] Error 1
[00:05:16] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0da0bebc
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jun 3, 2018

The job wasm32-unknown of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:55:10] status: exit code: 2
[00:55:10] command: "make"
[00:55:10] stdout:
[00:55:10] ------------------------------------------
[00:55:10] LD_LIBRARY_PATH="/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/panic-impl-transitive/panic-impl-transitive:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib:" '/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc' --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/panic-impl-transitive/panic-impl-transitive -L /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/panic-impl-transitive/panic-impl-transitive  panic-impl-provider.rs
[00:55:10] Makefile:6: recipe for target 'all' failed
[00:55:10] ------------------------------------------
[00:55:10] stderr:
[00:55:10] ------------------------------------------
[00:55:10] error[E0463]: can't find crate for `core`
[00:55:10] error[E0463]: can't find crate for `core`
[00:55:10] 
[00:55:10] error: aborting due to previous error
[00:55:10] 
[00:55:10] For more information about this error, try `rustc --explain E0463`.
[00:55:10] make: *** [all] Error 101
[00:55:10] ------------------------------------------
[00:55:10] 
[00:55:10] 
[00:55:10] thread '[run-make] run-make/panic-impl-transitive' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3096:9
[00:55:10] 
[00:55:10] 
[00:55:10] failures:
[00:55:10]     [run-make] run-make/panic-impl-transitive
[00:55:10]     [run-make] run-make/panic-impl-transitive
[00:55:10] 
[00:55:10] test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
[00:55:10] 
[00:55:10] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[00:55:10] 
[00:55:10] 
[00:55:10] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/wasm32-unknown-unknown/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-make" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make" "--stage-id" "stage2-wasm32-unknown-unknown" "--mode" "run-make" "--target" "wasm32-unknown-unknown" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--nodejs" "/node-v9.2.0-linux-x64/bin/node" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/wasm32-unknown-unknown/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "6.0.1\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:55:10] 
[00:55:10] 
[00:55:10] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --target wasm32-unknown-unknown src/test/run-make src/test/ui src/test/run-pass src/test/compile-fail src/test/parse-fail src/test/mir-opt src/test/codegen-units src/libcore
[00:55:10] Build completed unsuccessfully in 0:52:19

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@japaric

This comment has been minimized.

Copy link
Member Author

japaric commented Jun 3, 2018

@bors r=alexcrichton

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jun 3, 2018

📌 Commit 8ad15de has been approved by alexcrichton

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jun 3, 2018

⌛️ Testing commit 8ad15de with merge 29f48cc...

bors added a commit that referenced this pull request Jun 3, 2018

Auto merge of #50338 - japaric:panic-impl, r=alexcrichton
implement #[panic_implementation]

This implements the `#[panic_implementation]` attribute as instructed in #44489 (comment)

I haven't run the full test suite yet but at least all the compile-fail tests pass.

r? @nagisa
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jun 3, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 29f48cc to master...

@bors bors merged commit 8ad15de into rust-lang:master Jun 3, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

sdemos added a commit to sdemos/uefi-rs that referenced this pull request Jun 4, 2018

sdemos added a commit to sdemos/uefi-rs that referenced this pull request Jun 4, 2018

sdemos added a commit to sdemos/uefi-rs that referenced this pull request Jun 4, 2018

@japaric japaric deleted the japaric:panic-impl branch Jun 21, 2018

kennytm added a commit to kennytm/rust that referenced this pull request Sep 7, 2018

Rollup merge of rust-lang#51366 - japaric:stable-panic-impl, r=Mark-S…
…imulacrum

stabilize #[panic_handler]

closes rust-lang#44489

### Update(2018-09-07)

This was proposed for stabilization in rust-lang#44489 (comment) and its FCP with disposition to merge / accept is nearly over. The summary of what's being stabilized can be found in rust-lang#44489 (comment)

Documentation PRs:

- Reference. rust-lang-nursery/reference#362
- Nomicon. rust-lang-nursery/nomicon#75

---

`#[panic_implementation]` was implemented recently in rust-lang#50338. `#[panic_implementation]` is basically the old `panic_fmt` language item but in a less error prone (\*) shape. There are still some issues and questions to sort out around this feature (cf. rust-lang#44489) but this PR is meant to start a discussion about those issues / questions with the language team.

(\*) `panic_fmt` was not type checked; changes in its function signature caused serious, silent binary size regressions like the one observed in rust-lang#43054

Some unresolved questions from rust-lang#44489:

> Should the Display of PanicInfo format the panic information as "panicked at 'reason',
> src/main.rs:27:4", as "'reason', src/main.rs:27:4", or simply as "reason".

The current implementation formats `PanicInfo` as the first alternative, which is how panic messages are formatted by the `std` panic handler. The `Display` implementation is more than a convenience: `PanicInfo.message` is unstable so it's not possible to replicate the `Display` implementation on stable.

> Is this design compatible, or can it be extended to work, with unwinding implementations for
> no-std environments?

I believe @whitequark made more progress with unwinding in no-std since their last comment in rust-lang#44489. Perhaps they can give us an update?

---

Another unresolved question is where this feature should be documented. The feature currently doesn't have any documentation.

cc @rust-lang/lang
cc @jackpot51 @alevy @phil-opp

bors added a commit that referenced this pull request Sep 8, 2018

Auto merge of #51366 - japaric:stable-panic-impl, r=Mark-Simulacrum
stabilize #[panic_handler]

closes #44489

### Update(2018-09-07)

This was proposed for stabilization in #44489 (comment) and its FCP with disposition to merge / accept is nearly over. The summary of what's being stabilized can be found in #44489 (comment)

Documentation PRs:

- Reference. rust-lang-nursery/reference#362
- Nomicon. rust-lang-nursery/nomicon#75

---

`#[panic_implementation]` was implemented recently in #50338. `#[panic_implementation]` is basically the old `panic_fmt` language item but in a less error prone (\*) shape. There are still some issues and questions to sort out around this feature (cf. #44489) but this PR is meant to start a discussion about those issues / questions with the language team.

(\*) `panic_fmt` was not type checked; changes in its function signature caused serious, silent binary size regressions like the one observed in #43054

Some unresolved questions from #44489:

> Should the Display of PanicInfo format the panic information as "panicked at 'reason',
> src/main.rs:27:4", as "'reason', src/main.rs:27:4", or simply as "reason".

The current implementation formats `PanicInfo` as the first alternative, which is how panic messages are formatted by the `std` panic handler. The `Display` implementation is more than a convenience: `PanicInfo.message` is unstable so it's not possible to replicate the `Display` implementation on stable.

> Is this design compatible, or can it be extended to work, with unwinding implementations for
> no-std environments?

I believe @whitequark made more progress with unwinding in no-std since their last comment in #44489. Perhaps they can give us an update?

---

Another unresolved question is where this feature should be documented. The feature currently doesn't have any documentation.

cc @rust-lang/lang
cc @jackpot51 @alevy @phil-opp

kennytm added a commit to kennytm/rust that referenced this pull request Sep 8, 2018

Rollup merge of rust-lang#51366 - japaric:stable-panic-impl, r=Mark-S…
…imulacrum

stabilize #[panic_handler]

closes rust-lang#44489

### Update(2018-09-07)

This was proposed for stabilization in rust-lang#44489 (comment) and its FCP with disposition to merge / accept is nearly over. The summary of what's being stabilized can be found in rust-lang#44489 (comment)

Documentation PRs:

- Reference. rust-lang-nursery/reference#362
- Nomicon. rust-lang-nursery/nomicon#75

---

`#[panic_implementation]` was implemented recently in rust-lang#50338. `#[panic_implementation]` is basically the old `panic_fmt` language item but in a less error prone (\*) shape. There are still some issues and questions to sort out around this feature (cf. rust-lang#44489) but this PR is meant to start a discussion about those issues / questions with the language team.

(\*) `panic_fmt` was not type checked; changes in its function signature caused serious, silent binary size regressions like the one observed in rust-lang#43054

Some unresolved questions from rust-lang#44489:

> Should the Display of PanicInfo format the panic information as "panicked at 'reason',
> src/main.rs:27:4", as "'reason', src/main.rs:27:4", or simply as "reason".

The current implementation formats `PanicInfo` as the first alternative, which is how panic messages are formatted by the `std` panic handler. The `Display` implementation is more than a convenience: `PanicInfo.message` is unstable so it's not possible to replicate the `Display` implementation on stable.

> Is this design compatible, or can it be extended to work, with unwinding implementations for
> no-std environments?

I believe @whitequark made more progress with unwinding in no-std since their last comment in rust-lang#44489. Perhaps they can give us an update?

---

Another unresolved question is where this feature should be documented. The feature currently doesn't have any documentation.

cc @rust-lang/lang
cc @jackpot51 @alevy @phil-opp

bors added a commit that referenced this pull request Sep 8, 2018

Auto merge of #51366 - japaric:stable-panic-impl, r=Mark-Simulacrum
stabilize #[panic_handler]

closes #44489

### Update(2018-09-07)

This was proposed for stabilization in #44489 (comment) and its FCP with disposition to merge / accept is nearly over. The summary of what's being stabilized can be found in #44489 (comment)

Documentation PRs:

- Reference. rust-lang-nursery/reference#362
- Nomicon. rust-lang-nursery/nomicon#75

---

`#[panic_implementation]` was implemented recently in #50338. `#[panic_implementation]` is basically the old `panic_fmt` language item but in a less error prone (\*) shape. There are still some issues and questions to sort out around this feature (cf. #44489) but this PR is meant to start a discussion about those issues / questions with the language team.

(\*) `panic_fmt` was not type checked; changes in its function signature caused serious, silent binary size regressions like the one observed in #43054

Some unresolved questions from #44489:

> Should the Display of PanicInfo format the panic information as "panicked at 'reason',
> src/main.rs:27:4", as "'reason', src/main.rs:27:4", or simply as "reason".

The current implementation formats `PanicInfo` as the first alternative, which is how panic messages are formatted by the `std` panic handler. The `Display` implementation is more than a convenience: `PanicInfo.message` is unstable so it's not possible to replicate the `Display` implementation on stable.

> Is this design compatible, or can it be extended to work, with unwinding implementations for
> no-std environments?

I believe @whitequark made more progress with unwinding in no-std since their last comment in #44489. Perhaps they can give us an update?

---

Another unresolved question is where this feature should be documented. The feature currently doesn't have any documentation.

cc @rust-lang/lang
cc @jackpot51 @alevy @phil-opp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.