@@ -51,7 +51,22 @@ const _: () = assert!(cfg!(panic = "abort"), "panic_immediate_abort requires -C
51
51
#[ rustc_do_not_const_check] // hooked by const-eval
52
52
#[ rustc_const_unstable( feature = "core_panic" , issue = "none" ) ]
53
53
pub const fn panic_fmt ( fmt : fmt:: Arguments < ' _ > ) -> ! {
54
- panic_source ( fmt, None )
54
+ //panic_source(fmt, None)
55
+ if cfg ! ( feature = "panic_immediate_abort" ) {
56
+ super :: intrinsics:: abort ( )
57
+ }
58
+
59
+ // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
60
+ // that gets resolved to the `#[panic_handler]` function.
61
+ extern "Rust" {
62
+ #[ lang = "panic_impl" ]
63
+ fn panic_impl ( pi : & PanicInfo < ' _ > ) -> !;
64
+ }
65
+
66
+ let pi = PanicInfo :: internal_constructor ( Some ( & fmt) , Location :: caller ( ) , None , true ) ;
67
+
68
+ // SAFETY: `panic_impl` is defined in safe Rust code and thus is safe to call.
69
+ unsafe { panic_impl ( & pi) }
55
70
}
56
71
57
72
#[ cold]
@@ -62,7 +77,7 @@ pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
62
77
#[ track_caller]
63
78
#[ rustc_do_not_const_check] // hooked by const-eval
64
79
#[ rustc_const_unstable( feature = "core_panic" , issue = "none" ) ]
65
- pub const fn panic_source ( fmt : fmt:: Arguments < ' _ > , source : Option < & ( dyn Error + ' static ) > ) -> ! {
80
+ pub const fn panic_source ( fmt : fmt:: Arguments < ' _ > , source : & ( dyn Error + ' static ) ) -> ! {
66
81
if cfg ! ( feature = "panic_immediate_abort" ) {
67
82
super :: intrinsics:: abort ( )
68
83
}
@@ -74,7 +89,7 @@ pub const fn panic_source(fmt: fmt::Arguments<'_>, source: Option<&(dyn Error +
74
89
fn panic_impl ( pi : & PanicInfo < ' _ > ) -> !;
75
90
}
76
91
77
- let pi = PanicInfo :: internal_constructor ( Some ( & fmt) , Location :: caller ( ) , source, true ) ;
92
+ let pi = PanicInfo :: internal_constructor ( Some ( & fmt) , Location :: caller ( ) , Some ( source) , true ) ;
78
93
79
94
// SAFETY: `panic_impl` is defined in safe Rust code and thus is safe to call.
80
95
unsafe { panic_impl ( & pi) }
0 commit comments