Skip to content

Commit

Permalink
Do not create a new NodeId when not used.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Apr 30, 2022
1 parent 2341f21 commit 9d6214f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,13 @@ impl<'hir> LoweringContext<'hir> {
}
}

/// Generate a new `HirId` without a backing `NodeId`.
fn next_id(&mut self) -> hir::HirId {
let node_id = self.next_node_id();
self.lower_node_id(node_id)
let owner = self.current_hir_id_owner;
let local_id = self.item_local_id_counter;
assert_ne!(local_id, hir::ItemLocalId::new(0));
self.item_local_id_counter.increment_by(1);
hir::HirId { owner, local_id }
}

fn lower_res(&mut self, res: Res<NodeId>) -> Res {
Expand Down

0 comments on commit 9d6214f

Please sign in to comment.