Rollup merge of #97223 - cjgillot:linear-hir-tree, r=jackh726

Remove quadratic behaviour from -Zunpretty=hir-tree.

Closes https://github.com/rust-lang/rust/issues/97115
This commit is contained in:
Guillaume Gomez 2022-05-21 11:39:51 +02:00 committed by GitHub
commit 54e36ef1b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -796,7 +796,6 @@ pub fn get(&self, id: ItemLocalId) -> &'tcx [Attribute] {
/// Map of all HIR nodes inside the current owner.
/// These nodes are mapped by `ItemLocalId` alongside the index of their parent node.
/// The HIR tree, including bodies, is pre-hashed.
#[derive(Debug)]
pub struct OwnerNodes<'tcx> {
/// Pre-computed hash of the full HIR.
pub hash_including_bodies: Fingerprint,
@ -822,6 +821,18 @@ pub fn node(&self) -> OwnerNode<'tcx> {
}
}
impl fmt::Debug for OwnerNodes<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("OwnerNodes")
.field("node", &self.nodes[ItemLocalId::from_u32(0)])
.field("bodies", &self.bodies)
.field("local_id_to_def_id", &self.local_id_to_def_id)
.field("hash_without_bodies", &self.hash_without_bodies)
.field("hash_including_bodies", &self.hash_including_bodies)
.finish()
}
}
/// Full information resulting from lowering an AST node.
#[derive(Debug, HashStable_Generic)]
pub struct OwnerInfo<'hir> {