about summary refs log tree commit diff
path: root/src/librustc_mir/interpret
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-07-28 19:16:09 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-07-28 19:16:09 +0200
commit7d67a1b871c41fb498eeffcadfa33f1fa4c35774 (patch)
treeaec23b60b25c497d74a9f677acb5447a7d276a43 /src/librustc_mir/interpret
parent5e96bb459377896a85be4a192e16feca4c1d4aaf (diff)
downloadrust-7d67a1b871c41fb498eeffcadfa33f1fa4c35774.tar.gz
rust-7d67a1b871c41fb498eeffcadfa33f1fa4c35774.zip
Replace write-to-vec hack by introducing a display renderer for allocations
Diffstat (limited to 'src/librustc_mir/interpret')
-rw-r--r--src/librustc_mir/interpret/memory.rs8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs
index 0194c273f22..a9e6e324eb2 100644
--- a/src/librustc_mir/interpret/memory.rs
+++ b/src/librustc_mir/interpret/memory.rs
@@ -741,13 +741,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> std::fmt::Debug for DumpAllocs<'a,
             for &(_, target_id) in alloc.relocations().values() {
                 allocs_to_print.push_back(target_id);
             }
-            // This vec dance is necessary, because there is no trait
-            // that supports writing to files and to `std::fmt::Formatter` at the
-            // same time.
-            let mut v = Vec::new();
-            pretty::write_allocation(tcx, alloc, &mut v).unwrap();
-            let s = String::from_utf8(v).unwrap();
-            fmt.write_str(&s)
+            write!(fmt, "{}", pretty::display_allocation(tcx, alloc))
         }
 
         let mut allocs_to_print: VecDeque<_> = self.allocs.iter().copied().collect();