Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7c75fe4

Browse files
committedNov 17, 2022
Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-dead
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (#96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is #103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
2 parents 9340e5c + df5c11a commit 7c75fe4

File tree

63 files changed

+449
-549
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+449
-549
lines changed
 

‎compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
643643
// `static |_task_context| -> <ret_ty> { body }`:
644644
let generator_kind = {
645645
let c = self.arena.alloc(hir::Closure {
646+
def_id: self.local_def_id(closure_node_id),
646647
binder: hir::ClosureBinder::Default,
647648
capture_clause,
648649
bound_generic_params: &[],
@@ -895,6 +896,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
895896
let fn_decl = self.lower_fn_decl(decl, None, fn_decl_span, FnDeclKind::Closure, None);
896897

897898
let c = self.arena.alloc(hir::Closure {
899+
def_id: self.local_def_id(closure_id),
898900
binder: binder_clause,
899901
capture_clause,
900902
bound_generic_params,
@@ -999,6 +1001,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
9991001
self.lower_fn_decl(&outer_decl, None, fn_decl_span, FnDeclKind::Closure, None);
10001002

10011003
let c = self.arena.alloc(hir::Closure {
1004+
def_id: self.local_def_id(closure_id),
10021005
binder: binder_clause,
10031006
capture_clause,
10041007
bound_generic_params,

‎compiler/rustc_ast_lowering/src/index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
307307
}
308308

309309
fn visit_variant(&mut self, v: &'hir Variant<'hir>) {
310-
self.insert(v.span, v.id, Node::Variant(v));
311-
self.with_parent(v.id, |this| {
310+
self.insert(v.span, v.hir_id, Node::Variant(v));
311+
self.with_parent(v.hir_id, |this| {
312312
// Register the constructor of this variant.
313313
if let Some(ctor_hir_id) = v.data.ctor_hir_id() {
314314
this.insert(v.span, ctor_hir_id, Node::Ctor(&v.data));

0 commit comments

Comments
 (0)
Please sign in to comment.