about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-09-08 09:23:45 +0000
committerbors <bors@rust-lang.org>2018-09-08 09:23:45 +0000
commitff59ab127ac92885e4273bb73c8ac5a999c327bf (patch)
tree7ab9ed6191a28d292ff465cb9b76bf9b0def7fea /src/libsyntax
parent06da917b015a2eceac0e3cca22f9660edef25178 (diff)
parent358fc5b62126f997a1c38ba4c8be60ae16e4a2c4 (diff)
downloadrust-ff59ab127ac92885e4273bb73c8ac5a999c327bf.tar.gz
rust-ff59ab127ac92885e4273bb73c8ac5a999c327bf.zip
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 https://github.com/rust-lang/rust/issues/44489#issuecomment-398965881 and its FCP with disposition to merge / accept is nearly over. The summary of what's being stabilized can be found in https://github.com/rust-lang/rust/issues/44489#issuecomment-416645946

Documentation PRs:

- Reference. https://github.com/rust-lang-nursery/reference/pull/362
- Nomicon. https://github.com/rust-lang-nursery/nomicon/pull/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
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/feature_gate.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index e3ea3563d85..0270e36db11 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -487,7 +487,6 @@ declare_features! (
 
     // RFC 2070: #[panic_implementation] / #[panic_handler]
     (active, panic_implementation, "1.28.0", Some(44489), None),
-    (active, panic_handler, "1.30.0", Some(44489), None),
 
     // #[doc(keyword = "...")]
     (active, doc_keyword, "1.28.0", Some(51315), None),
@@ -674,6 +673,7 @@ declare_features! (
     (accepted, proc_macro_path_invoc, "1.30.0", Some(38356), None),
     // Allows all literals in attribute lists and values of key-value pairs.
     (accepted, attr_literals, "1.30.0", Some(34981), None),
+    (accepted, panic_handler, "1.30.0", Some(44489), None),
 );
 
 // If you change this, please modify src/doc/unstable-book as well. You must
@@ -1143,10 +1143,7 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
            cfg_fn!(panic_implementation))),
 
     // RFC 2070
-    ("panic_handler", Normal, Gated(Stability::Unstable,
-                                    "panic_handler",
-                                    "#[panic_handler] is an unstable feature",
-                                    cfg_fn!(panic_handler))),
+    ("panic_handler", Normal, Ungated),
 
     ("alloc_error_handler", Normal, Gated(Stability::Unstable,
                            "alloc_error_handler",