Skip to content

Commit

Permalink
Unrolled build for rust-lang#123454
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#123454 - petrochenkov:zeroindex2, r=fmease

hir: Use `ItemLocalId::ZERO` in a couple more places

Follow up to rust-lang#123415 and rust-lang#123419.
  • Loading branch information
rust-timer committed Apr 5, 2024
2 parents 9cbaa01 + 17475de commit b22f193
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions compiler/rustc_ast_lowering/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct NodeCollector<'a, 'hir> {
parenting: LocalDefIdMap<ItemLocalId>,

/// The parent of this node
parent_node: hir::ItemLocalId,
parent_node: ItemLocalId,

owner: OwnerId,
}
Expand All @@ -31,17 +31,16 @@ pub(super) fn index_hir<'hir>(
bodies: &SortedMap<ItemLocalId, &'hir Body<'hir>>,
num_nodes: usize,
) -> (IndexVec<ItemLocalId, ParentedNode<'hir>>, LocalDefIdMap<ItemLocalId>) {
let zero_id = ItemLocalId::ZERO;
let err_node = ParentedNode { parent: zero_id, node: Node::Err(item.span()) };
let err_node = ParentedNode { parent: ItemLocalId::ZERO, node: Node::Err(item.span()) };
let mut nodes = IndexVec::from_elem_n(err_node, num_nodes);
// This node's parent should never be accessed: the owner's parent is computed by the
// hir_owner_parent query. Make it invalid (= ItemLocalId::MAX) to force an ICE whenever it is
// used.
nodes[zero_id] = ParentedNode { parent: ItemLocalId::INVALID, node: item.into() };
nodes[ItemLocalId::ZERO] = ParentedNode { parent: ItemLocalId::INVALID, node: item.into() };
let mut collector = NodeCollector {
tcx,
owner: item.def_id(),
parent_node: zero_id,
parent_node: ItemLocalId::ZERO,
nodes,
bodies,
parenting: Default::default(),
Expand Down Expand Up @@ -112,7 +111,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
}

fn insert_nested(&mut self, item: LocalDefId) {
if self.parent_node.as_u32() != 0 {
if self.parent_node != ItemLocalId::ZERO {
self.parenting.insert(item, self.parent_node);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub fn provide(providers: &mut Providers) {
.parenting
.get(&owner_id.def_id)
.copied()
.unwrap_or(ItemLocalId::from_u32(0)),
.unwrap_or(ItemLocalId::ZERO),
}
})
};
Expand Down

0 comments on commit b22f193

Please sign in to comment.