File tree 3 files changed +11
-5
lines changed
3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -98,13 +98,12 @@ use crate::intrinsics;
98
98
#[ rustc_const_stable( feature = "const_unreachable_unchecked" , since = "1.57.0" ) ]
99
99
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
100
100
pub const unsafe fn unreachable_unchecked ( ) -> ! {
101
- crate :: panic:: debug_assert_nounwind!(
102
- false ,
103
- "hint::unreachable_unchecked must never be reached"
104
- ) ;
105
101
// SAFETY: the safety contract for `intrinsics::unreachable` must
106
102
// be upheld by the caller.
107
- unsafe { intrinsics:: unreachable ( ) }
103
+ unsafe {
104
+ intrinsics:: assert_unsafe_precondition!( "hint::unreachable_unchecked must never be reached" , ( ) => false ) ;
105
+ intrinsics:: unreachable ( )
106
+ }
108
107
}
109
108
110
109
/// Emits a machine instruction to signal the processor that it is running in
Original file line number Diff line number Diff line change @@ -90,6 +90,11 @@ pub macro unreachable_2021 {
90
90
) ,
91
91
}
92
92
93
+ /// Asserts that a boolean expression is `true`, and perform a non-unwinding panic otherwise.
94
+ ///
95
+ /// This macro is similar to `debug_assert!`, but is intended to be used in code that should not
96
+ /// unwind. For example , checks in `_unchecked` functions that are intended for debugging but should
97
+ /// not compromise unwind safety.
93
98
#[ doc( hidden) ]
94
99
#[ unstable( feature = "core_panic" , issue = "none" ) ]
95
100
#[ allow_internal_unstable( core_panic, const_format_args) ]
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
79
79
#[ rustc_nounwind]
80
80
#[ rustc_const_unstable( feature = "core_panic" , issue = "none" ) ]
81
81
pub const fn panic_nounwind_fmt ( fmt : fmt:: Arguments < ' _ > ) -> ! {
82
+ #[ track_caller]
82
83
fn runtime ( fmt : fmt:: Arguments < ' _ > ) -> ! {
83
84
if cfg ! ( feature = "panic_immediate_abort" ) {
84
85
super :: intrinsics:: abort ( )
@@ -99,6 +100,7 @@ pub const fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>) -> ! {
99
100
}
100
101
101
102
#[ inline]
103
+ #[ track_caller]
102
104
const fn comptime ( fmt : fmt:: Arguments < ' _ > ) -> ! {
103
105
panic_fmt ( fmt) ;
104
106
}
You can’t perform that action at this time.
0 commit comments