@@ -179,6 +179,8 @@ fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! {
179
179
180
180
/// Panic because we cannot unwind out of a function.
181
181
///
182
+ /// This is a separate function to avoid the codesize impact of each crate containing the string to
183
+ /// pass to `panic_nounwind`.
182
184
/// This function is called directly by the codegen backend, and must not have
183
185
/// any extra arguments (including those synthesized by track_caller).
184
186
#[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) , cold) ]
@@ -189,6 +191,21 @@ fn panic_cannot_unwind() -> ! {
189
191
panic_nounwind ( "panic in a function that cannot unwind" )
190
192
}
191
193
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
+
192
209
/// This function is used instead of panic_fmt in const eval.
193
210
#[ lang = "const_panic_fmt" ]
194
211
#[ rustc_const_unstable( feature = "core_panic" , issue = "none" ) ]
0 commit comments