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 ```
This commit is contained in:
parent
fb9dfa8cef
commit
e1787f5572
4 changed files with 42 additions and 11 deletions
|
@ -854,7 +854,11 @@ impl fmt::Debug for OwnerNodes<'_> {
|
|||
&self
|
||||
.nodes
|
||||
.iter_enumerated()
|
||||
.map(|(id, parented_node)| (id, parented_node.as_ref().map(|node| node.parent)))
|
||||
.map(|(id, parented_node)| {
|
||||
let parented_node = parented_node.as_ref().map(|node| node.parent);
|
||||
|
||||
debug_fn(move |f| write!(f, "({id:?}, {parented_node:?})"))
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.field("bodies", &self.bodies)
|
||||
|
@ -3615,3 +3619,13 @@ mod size_asserts {
|
|||
static_assert_size!(TyKind<'_>, 32);
|
||||
// tidy-alphabetical-end
|
||||
}
|
||||
|
||||
fn debug_fn(f: impl Fn(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Debug {
|
||||
struct DebugFn<F>(F);
|
||||
impl<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result> fmt::Debug for DebugFn<F> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
(self.0)(fmt)
|
||||
}
|
||||
}
|
||||
DebugFn(f)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue