rustc_hir: replace debug_fn
with unstable fmt::from_fn
This commit is contained in:
parent
8231e8599e
commit
815be937ab
2 changed files with 8 additions and 17 deletions
|
@ -1285,13 +1285,13 @@ impl fmt::Debug for OwnerNodes<'_> {
|
||||||
.field("node", &self.nodes[ItemLocalId::ZERO])
|
.field("node", &self.nodes[ItemLocalId::ZERO])
|
||||||
.field(
|
.field(
|
||||||
"parents",
|
"parents",
|
||||||
&self
|
&fmt::from_fn(|f| {
|
||||||
.nodes
|
f.debug_list()
|
||||||
.iter_enumerated()
|
.entries(self.nodes.iter_enumerated().map(|(id, parented_node)| {
|
||||||
.map(|(id, parented_node)| {
|
fmt::from_fn(move |f| write!(f, "({id:?}, {:?})", parented_node.parent))
|
||||||
debug_fn(move |f| write!(f, "({id:?}, {:?})", parented_node.parent))
|
}))
|
||||||
})
|
.finish()
|
||||||
.collect::<Vec<_>>(),
|
}),
|
||||||
)
|
)
|
||||||
.field("bodies", &self.bodies)
|
.field("bodies", &self.bodies)
|
||||||
.field("opt_hash_including_bodies", &self.opt_hash_including_bodies)
|
.field("opt_hash_including_bodies", &self.opt_hash_including_bodies)
|
||||||
|
@ -4638,15 +4638,5 @@ mod size_asserts {
|
||||||
// tidy-alphabetical-end
|
// 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
#![feature(associated_type_defaults)]
|
#![feature(associated_type_defaults)]
|
||||||
#![feature(closure_track_caller)]
|
#![feature(closure_track_caller)]
|
||||||
|
#![feature(debug_closure_helpers)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue