Skip to content

Commit 7d7edc9

Browse files
authored
Rollup merge of rust-lang#51366 - japaric:stable-panic-impl, r=Mark-Simulacrum
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/reference#362 - Nomicon. rust-lang/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
2 parents 06da917 + 358fc5b commit 7d7edc9

25 files changed

+17
-67
lines changed

src/libstd/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@
312312
#![feature(doc_keyword)]
313313
#![feature(panic_info_message)]
314314
#![cfg_attr(stage0, feature(panic_implementation))]
315-
#![cfg_attr(not(stage0), feature(panic_handler))]
316315
#![feature(non_exhaustive)]
317316

318317
#![default_lib_allocator]

src/libsyntax/feature_gate.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ declare_features! (
487487

488488
// RFC 2070: #[panic_implementation] / #[panic_handler]
489489
(active, panic_implementation, "1.28.0", Some(44489), None),
490-
(active, panic_handler, "1.30.0", Some(44489), None),
491490

492491
// #[doc(keyword = "...")]
493492
(active, doc_keyword, "1.28.0", Some(51315), None),
@@ -674,6 +673,7 @@ declare_features! (
674673
(accepted, proc_macro_path_invoc, "1.30.0", Some(38356), None),
675674
// Allows all literals in attribute lists and values of key-value pairs.
676675
(accepted, attr_literals, "1.30.0", Some(34981), None),
676+
(accepted, panic_handler, "1.30.0", Some(44489), None),
677677
);
678678

679679
// 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
11431143
cfg_fn!(panic_implementation))),
11441144

11451145
// RFC 2070
1146-
("panic_handler", Normal, Gated(Stability::Unstable,
1147-
"panic_handler",
1148-
"#[panic_handler] is an unstable feature",
1149-
cfg_fn!(panic_handler))),
1146+
("panic_handler", Normal, Ungated),
11501147

11511148
("alloc_error_handler", Normal, Gated(Stability::Unstable,
11521149
"alloc_error_handler",

src/test/compile-fail/auxiliary/some-panic-impl.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// no-prefer-dynamic
1212

1313
#![crate_type = "rlib"]
14-
#![feature(panic_handler)]
1514
#![no_std]
1615

1716
use core::panic::PanicInfo;

src/test/compile-fail/panic-handler-twice.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// aux-build:some-panic-impl.rs
1212

13-
#![feature(panic_handler)]
1413
#![feature(lang_items)]
1514
#![no_std]
1615
#![no_main]

src/test/run-make-fulldeps/issue-51671/app.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#![crate_type = "bin"]
1212
#![feature(lang_items)]
13-
#![feature(panic_handler)]
1413
#![no_main]
1514
#![no_std]
1615

src/test/run-make-fulldeps/panic-impl-transitive/panic-impl-provider.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
#![crate_type = "rlib"]
12-
#![feature(panic_handler)]
1312
#![no_std]
1413

1514
use core::panic::PanicInfo;

src/test/ui/consts/const-eval/const_panic_libcore_main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#![crate_type = "bin"]
1212
#![feature(lang_items)]
13-
#![feature(panic_handler)]
1413
#![feature(const_panic)]
1514
#![no_main]
1615
#![no_std]

src/test/ui/consts/const-eval/const_panic_libcore_main.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error: this constant cannot be used
2-
--> $DIR/const_panic_libcore_main.rs:20:1
2+
--> $DIR/const_panic_libcore_main.rs:19:1
33
|
44
LL | const Z: () = panic!("cheese");
55
| ^^^^^^^^^^^^^^----------------^
66
| |
7-
| the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_main.rs:20:15
7+
| the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_main.rs:19:15
88
|
99
= note: #[deny(const_err)] on by default
1010
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
1111

1212
error: this constant cannot be used
13-
--> $DIR/const_panic_libcore_main.rs:23:1
13+
--> $DIR/const_panic_libcore_main.rs:22:1
1414
|
1515
LL | const Y: () = unreachable!();
1616
| ^^^^^^^^^^^^^^--------------^
1717
| |
18-
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_main.rs:23:15
18+
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_main.rs:22:15
1919
|
2020
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
2121

2222
error: this constant cannot be used
23-
--> $DIR/const_panic_libcore_main.rs:26:1
23+
--> $DIR/const_panic_libcore_main.rs:25:1
2424
|
2525
LL | const X: () = unimplemented!();
2626
| ^^^^^^^^^^^^^^----------------^
2727
| |
28-
| the evaluated program panicked at 'not yet implemented', $DIR/const_panic_libcore_main.rs:26:15
28+
| the evaluated program panicked at 'not yet implemented', $DIR/const_panic_libcore_main.rs:25:15
2929
|
3030
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
3131

src/test/ui/feature-gates/feature-gate-panic-handler.rs

-21
This file was deleted.

src/test/ui/feature-gates/feature-gate-panic-handler.stderr

-11
This file was deleted.

src/test/ui/panic-handler/auxiliary/some-panic-impl.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// no-prefer-dynamic
1212

1313
#![crate_type = "rlib"]
14-
#![feature(panic_handler)]
1514
#![no_std]
1615

1716
use core::panic::PanicInfo;

src/test/ui/panic-handler/panic-handler-bad-signature-1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// compile-flags:-C panic=abort
1212

13-
#![feature(panic_handler)]
1413
#![no_std]
1514
#![no_main]
1615

src/test/ui/panic-handler/panic-handler-bad-signature-1.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: return type should be `!`
2-
--> $DIR/panic-handler-bad-signature-1.rs:22:6
2+
--> $DIR/panic-handler-bad-signature-1.rs:21:6
33
|
44
LL | ) -> () //~ ERROR return type should be `!`
55
| ^^
66

77
error: argument should be `&PanicInfo`
8-
--> $DIR/panic-handler-bad-signature-1.rs:21:11
8+
--> $DIR/panic-handler-bad-signature-1.rs:20:11
99
|
1010
LL | info: PanicInfo, //~ ERROR argument should be `&PanicInfo`
1111
| ^^^^^^^^^

src/test/ui/panic-handler/panic-handler-bad-signature-2.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// compile-flags:-C panic=abort
1212

13-
#![feature(panic_handler)]
1413
#![no_std]
1514
#![no_main]
1615

src/test/ui/panic-handler/panic-handler-bad-signature-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: argument should be `&PanicInfo`
2-
--> $DIR/panic-handler-bad-signature-2.rs:21:11
2+
--> $DIR/panic-handler-bad-signature-2.rs:20:11
33
|
44
LL | info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo`
55
| ^^^^^^^^^^^^^^^^^^

src/test/ui/panic-handler/panic-handler-bad-signature-3.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// compile-flags:-C panic=abort
1212

13-
#![feature(panic_handler)]
1413
#![no_std]
1514
#![no_main]
1615

src/test/ui/panic-handler/panic-handler-bad-signature-3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: function should have one argument
2-
--> $DIR/panic-handler-bad-signature-3.rs:20:1
2+
--> $DIR/panic-handler-bad-signature-3.rs:19:1
33
|
44
LL | fn panic() -> ! { //~ ERROR function should have one argument
55
| ^^^^^^^^^^^^^^^

src/test/ui/panic-handler/panic-handler-bad-signature-4.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// compile-flags:-C panic=abort
1212

13-
#![feature(panic_handler)]
1413
#![no_std]
1514
#![no_main]
1615

src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: should have no type parameters
2-
--> $DIR/panic-handler-bad-signature-4.rs:20:1
2+
--> $DIR/panic-handler-bad-signature-4.rs:19:1
33
|
44
LL | / fn panic<T>(pi: &PanicInfo) -> ! {
55
LL | | //~^ ERROR should have no type parameters

src/test/ui/panic-handler/panic-handler-duplicate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// compile-flags:-C panic=abort
1212

1313
#![feature(lang_items)]
14-
#![feature(panic_handler)]
1514
#![no_std]
1615
#![no_main]
1716

src/test/ui/panic-handler/panic-handler-duplicate.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0152]: duplicate lang item found: `panic_impl`.
2-
--> $DIR/panic-handler-duplicate.rs:26:1
2+
--> $DIR/panic-handler-duplicate.rs:25:1
33
|
44
LL | / fn panic2(info: &PanicInfo) -> ! { //~ ERROR duplicate lang item found: `panic_impl`.
55
LL | | loop {}
66
LL | | }
77
| |_^
88
|
99
note: first defined here.
10-
--> $DIR/panic-handler-duplicate.rs:21:1
10+
--> $DIR/panic-handler-duplicate.rs:20:1
1111
|
1212
LL | / fn panic(info: &PanicInfo) -> ! {
1313
LL | | loop {}

src/test/ui/panic-handler/panic-handler-requires-panic-info.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#![feature(lang_items)]
1515
#![feature(no_core)]
16-
#![feature(panic_handler)]
1716
#![no_core]
1817
#![no_main]
1918

src/test/ui/panic-handler/panic-handler-std.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// error-pattern: duplicate lang item found: `panic_impl`.
1212

13-
#![feature(panic_handler)]
1413

1514
use std::panic::PanicInfo;
1615

src/test/ui/panic-handler/panic-handler-std.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0152]: duplicate lang item found: `panic_impl`.
2-
--> $DIR/panic-handler-std.rs:18:1
2+
--> $DIR/panic-handler-std.rs:17:1
33
|
44
LL | / fn panic(info: PanicInfo) -> ! {
55
LL | | loop {}
@@ -9,7 +9,7 @@ LL | | }
99
= note: first defined in crate `std`.
1010

1111
error: argument should be `&PanicInfo`
12-
--> $DIR/panic-handler-std.rs:18:16
12+
--> $DIR/panic-handler-std.rs:17:16
1313
|
1414
LL | fn panic(info: PanicInfo) -> ! {
1515
| ^^^^^^^^^

src/test/ui/panic_implementation-closures.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#![crate_type = "rlib"]
1414
#![no_std]
15-
#![feature(panic_handler)]
1615

1716
#[panic_handler]
1817
pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! {

0 commit comments

Comments
 (0)