about summary refs log tree commit diff
path: root/compiler/rustc_data_structures
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-01-02 15:39:17 -0800
committerGitHub <noreply@github.com>2023-01-02 15:39:17 -0800
commitfbffaa91ada6387cdea184dcd1d689762b3e8927 (patch)
tree432d143db3380e5afd9407effa2158987b01a6b9 /compiler/rustc_data_structures
parentda1ca5df6e0ce759d409ce853d836cb00542c44f (diff)
parente1787f557223245375571550000eb6441de17b6e (diff)
downloadrust-fbffaa91ada6387cdea184dcd1d689762b3e8927.tar.gz
rust-fbffaa91ada6387cdea184dcd1d689762b3e8927.zip
Rollup merge of #105558 - Nilstrieb:less-spam-hir-tree, r=cjgillot
Reduce HIR debug output

HIR debug output is currently very verbose, especially when used with the alternate (`#`) flag. This commit reduces the amount of noisy newlines by forcing a few small key types to stay on one line, which makes the output easier to read and scroll by.

```
$ rustc +after hello_world.rs -Zunpretty=hir-tree | wc -l
582
$ rustc +before hello_world.rs -Zunpretty=hir-tree | wc -l
932
```
Diffstat (limited to 'compiler/rustc_data_structures')
-rw-r--r--compiler/rustc_data_structures/src/sorted_map.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs
index 05f059c89d5..c63caa06818 100644
--- a/compiler/rustc_data_structures/src/sorted_map.rs
+++ b/compiler/rustc_data_structures/src/sorted_map.rs
@@ -1,6 +1,7 @@
 use crate::stable_hasher::{HashStable, StableHasher, StableOrd};
 use std::borrow::Borrow;
 use std::cmp::Ordering;
+use std::fmt::Debug;
 use std::mem;
 use std::ops::{Bound, Index, IndexMut, RangeBounds};
 
@@ -16,7 +17,7 @@ pub use index_map::SortedIndexMultiMap;
 /// stores data in a more compact way. It also supports accessing contiguous
 /// ranges of elements as a slice, and slices of already sorted elements can be
 /// inserted efficiently.
-#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)]
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
 pub struct SortedMap<K, V> {
     data: Vec<(K, V)>,
 }
@@ -314,5 +315,11 @@ impl<K: HashStable<CTX> + StableOrd, V: HashStable<CTX>, CTX> HashStable<CTX> fo
     }
 }
 
+impl<K: Debug, V: Debug> Debug for SortedMap<K, V> {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        f.debug_map().entries(self.data.iter().map(|(a, b)| (a, b))).finish()
+    }
+}
+
 #[cfg(test)]
 mod tests;