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(
|
||||
"parents",
|
||||
&self
|
||||
.nodes
|
||||
.iter_enumerated()
|
||||
.map(|(id, parented_node)| {
|
||||
debug_fn(move |f| write!(f, "({id:?}, {:?})", parented_node.parent))
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
&fmt::from_fn(|f| {
|
||||
f.debug_list()
|
||||
.entries(self.nodes.iter_enumerated().map(|(id, parented_node)| {
|
||||
fmt::from_fn(move |f| write!(f, "({id:?}, {:?})", parented_node.parent))
|
||||
}))
|
||||
.finish()
|
||||
}),
|
||||
)
|
||||
.field("bodies", &self.bodies)
|
||||
.field("opt_hash_including_bodies", &self.opt_hash_including_bodies)
|
||||
|
@ -4638,15 +4638,5 @@ mod size_asserts {
|
|||
// 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)]
|
||||
mod tests;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#![allow(internal_features)]
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(closure_track_caller)]
|
||||
#![feature(debug_closure_helpers)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(never_type)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue