@@ -285,9 +285,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
285
285
None => {
286
286
// Deallocating global memory -- always an error
287
287
return Err ( match self . tcx . get_global_alloc ( ptr. alloc_id ) {
288
- Some ( GlobalAlloc :: Function ( ..) ) => err_ub_format ! ( "deallocating a function" ) ,
288
+ Some ( GlobalAlloc :: Function ( ..) ) => {
289
+ err_ub_format ! ( "deallocating {}, which is a function" , ptr. alloc_id)
290
+ }
289
291
Some ( GlobalAlloc :: Static ( ..) | GlobalAlloc :: Memory ( ..) ) => {
290
- err_ub_format ! ( "deallocating static memory" )
292
+ err_ub_format ! ( "deallocating {}, which is static memory" , ptr . alloc_id )
291
293
}
292
294
None => err_ub ! ( PointerUseAfterFree ( ptr. alloc_id) ) ,
293
295
}
@@ -297,15 +299,17 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
297
299
298
300
if alloc_kind != kind {
299
301
throw_ub_format ! (
300
- "deallocating {} memory using {} deallocation operation" ,
302
+ "deallocating {}, which is {} memory, using {} deallocation operation" ,
303
+ ptr. alloc_id,
301
304
alloc_kind,
302
305
kind
303
306
) ;
304
307
}
305
308
if let Some ( ( size, align) ) = old_size_and_align {
306
309
if size != alloc. size || align != alloc. align {
307
310
throw_ub_format ! (
308
- "incorrect layout on deallocation: allocation has size {} and alignment {}, but gave size {} and alignment {}" ,
311
+ "incorrect layout on deallocation: {} has size {} and alignment {}, but gave size {} and alignment {}" ,
312
+ ptr. alloc_id,
309
313
alloc. size. bytes( ) ,
310
314
alloc. align. bytes( ) ,
311
315
size. bytes( ) ,
0 commit comments