diff options
Diffstat (limited to 'compiler/rustc_hir/src/hir.rs')
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 91825c29258..bc897ed8112 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -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) @@ -2431,7 +2435,7 @@ impl<'hir> Ty<'hir> { pub fn peel_refs(&self) -> &Self { let mut final_ty = self; - while let TyKind::Rptr(_, MutTy { ty, .. }) = &final_ty.kind { + while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind { final_ty = ty; } final_ty @@ -2588,7 +2592,7 @@ pub enum TyKind<'hir> { /// A raw pointer (i.e., `*const T` or `*mut T`). Ptr(MutTy<'hir>), /// A reference (i.e., `&'a T` or `&'a mut T`). - Rptr(&'hir Lifetime, MutTy<'hir>), + Ref(&'hir Lifetime, MutTy<'hir>), /// A bare function (e.g., `fn(usize) -> bool`). BareFn(&'hir BareFnTy<'hir>), /// The never type (`!`). @@ -3456,7 +3460,7 @@ impl<'hir> Node<'hir> { /// ```ignore (illustrative) /// ctor /// .ctor_hir_id() - /// .and_then(|ctor_id| tcx.hir().find(tcx.hir().get_parent_node(ctor_id))) + /// .and_then(|ctor_id| tcx.hir().find_parent(ctor_id)) /// .and_then(|parent| parent.ident()) /// ``` pub fn ident(&self) -> Option<Ident> { @@ -3609,16 +3613,19 @@ mod size_asserts { static_assert_size!(Res, 12); static_assert_size!(Stmt<'_>, 32); static_assert_size!(StmtKind<'_>, 16); - // tidy-alphabetical-end - // FIXME: move the tidy directive to the end after the next bootstrap bump - #[cfg(bootstrap)] - static_assert_size!(TraitItem<'_>, 88); - #[cfg(not(bootstrap))] static_assert_size!(TraitItem<'_>, 80); - #[cfg(bootstrap)] - static_assert_size!(TraitItemKind<'_>, 48); - #[cfg(not(bootstrap))] static_assert_size!(TraitItemKind<'_>, 40); static_assert_size!(Ty<'_>, 48); 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) } |
