@@ -179,6 +179,8 @@ fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! {
179179
180180/// Panic because we cannot unwind out of a function.
181181///
182+ /// This is a separate function to avoid the codesize impact of each crate containing the string to
183+ /// pass to `panic_nounwind`.
182184/// This function is called directly by the codegen backend, and must not have
183185/// any extra arguments (including those synthesized by track_caller).
184186#[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) , cold) ]
@@ -189,6 +191,21 @@ fn panic_cannot_unwind() -> ! {
189191 panic_nounwind ( "panic in a function that cannot unwind" )
190192}
191193
194+ /// Panic because we are unwinding out of a destructor during cleanup.
195+ ///
196+ /// This is a separate function to avoid the codesize impact of each crate containing the string to
197+ /// pass to `panic_nounwind`.
198+ /// This function is called directly by the codegen backend, and must not have
199+ /// any extra arguments (including those synthesized by track_caller).
200+ #[ cfg( not( bootstrap) ) ]
201+ #[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) , cold) ]
202+ #[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
203+ #[ lang = "panic_in_cleanup" ] // needed by codegen for panic in nounwind function
204+ #[ rustc_nounwind]
205+ fn panic_in_cleanup ( ) -> ! {
206+ panic_nounwind ( "panic in a destructor during cleanup" )
207+ }
208+
192209/// This function is used instead of panic_fmt in const eval.
193210#[ lang = "const_panic_fmt" ]
194211#[ rustc_const_unstable( feature = "core_panic" , issue = "none" ) ]
0 commit comments