|
9 | 9 | use std::borrow::Cow; |
10 | 10 | use std::collections::VecDeque; |
11 | 11 | use std::convert::TryFrom; |
| 12 | +use std::fmt; |
12 | 13 | use std::ptr; |
13 | 14 |
|
14 | 15 | use rustc_ast::ast::Mutability; |
@@ -46,6 +47,17 @@ impl<T: MayLeak> MayLeak for MemoryKind<T> { |
46 | 47 | } |
47 | 48 | } |
48 | 49 |
|
| 50 | +impl<T: fmt::Display> fmt::Display for MemoryKind<T> { |
| 51 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 52 | + match self { |
| 53 | + MemoryKind::Stack => write!(f, "stack variable"), |
| 54 | + MemoryKind::Vtable => write!(f, "vtable"), |
| 55 | + MemoryKind::CallerLocation => write!(f, "caller location"), |
| 56 | + MemoryKind::Machine(m) => write!(f, "{}", m), |
| 57 | + } |
| 58 | + } |
| 59 | +} |
| 60 | + |
49 | 61 | /// Used by `get_size_and_align` to indicate whether the allocation needs to be live. |
50 | 62 | #[derive(Debug, Copy, Clone)] |
51 | 63 | pub enum AllocCheck { |
@@ -259,7 +271,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { |
259 | 271 |
|
260 | 272 | if alloc_kind != kind { |
261 | 273 | throw_ub_format!( |
262 | | - "deallocating `{:?}` memory using `{:?}` deallocation operation", |
| 274 | + "deallocating {} memory using {} deallocation operation", |
263 | 275 | alloc_kind, |
264 | 276 | kind |
265 | 277 | ); |
@@ -677,22 +689,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { |
677 | 689 | match self.alloc_map.get(id) { |
678 | 690 | Some(&(kind, ref alloc)) => { |
679 | 691 | // normal alloc |
680 | | - match kind { |
681 | | - MemoryKind::Stack => eprint!(" (stack variable, "), |
682 | | - MemoryKind::Vtable => eprint!(" (vtable, "), |
683 | | - MemoryKind::CallerLocation => eprint!(" (caller_location, "), |
684 | | - MemoryKind::Machine(m) if Some(m) == M::GLOBAL_KIND => { |
685 | | - eprint!(" (global, ") |
686 | | - } |
687 | | - MemoryKind::Machine(m) => eprint!(" ({:?}, ", m), |
688 | | - }; |
| 692 | + eprint!(" ({}, ", kind); |
689 | 693 | write_allocation_track_relocs(self.tcx, &mut allocs_to_print, alloc); |
690 | 694 | } |
691 | 695 | None => { |
692 | 696 | // global alloc |
693 | 697 | match self.tcx.alloc_map.lock().get(id) { |
694 | 698 | Some(GlobalAlloc::Memory(alloc)) => { |
695 | | - eprint!(" (global, "); |
| 699 | + eprint!(" (unchanged global, "); |
696 | 700 | write_allocation_track_relocs(self.tcx, &mut allocs_to_print, alloc); |
697 | 701 | } |
698 | 702 | Some(GlobalAlloc::Function(func)) => { |
|
0 commit comments