From 1a39247d8dce70554964368046abcae9722675b6 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Sun, 15 Sep 2024 11:10:16 +0800 Subject: [PATCH] Add duplicate lowering check --- compiler/rustc_ast_lowering/src/block.rs | 9 ----- compiler/rustc_ast_lowering/src/delegation.rs | 2 +- compiler/rustc_ast_lowering/src/expr.rs | 14 ++++---- compiler/rustc_ast_lowering/src/item.rs | 12 +++---- compiler/rustc_ast_lowering/src/lib.rs | 35 ++++++++++++------- compiler/rustc_ast_lowering/src/pat.rs | 4 +-- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/block.rs b/compiler/rustc_ast_lowering/src/block.rs index 8e02cbfd2ca..20d3ce65fac 100644 --- a/compiler/rustc_ast_lowering/src/block.rs +++ b/compiler/rustc_ast_lowering/src/block.rs @@ -14,15 +14,6 @@ pub(super) fn lower_block( self.arena.alloc(self.lower_block_noalloc(hir_id, b, targeted_by_break)) } - pub(super) fn lower_block_with_hir_id( - &mut self, - b: &Block, - hir_id: hir::HirId, - targeted_by_break: bool, - ) -> &'hir hir::Block<'hir> { - self.arena.alloc(self.lower_block_noalloc(hir_id, b, targeted_by_break)) - } - pub(super) fn lower_block_noalloc( &mut self, hir_id: hir::HirId, diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 37eea707929..70c94f4019a 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -260,7 +260,7 @@ fn lower_delegation_body( }; self_resolver.visit_block(block); // Target expr needs to lower `self` path. - this.ident_to_local_id.insert(pat_node_id, param.pat.hir_id.local_id); + this.ident_and_label_to_local_id.insert(pat_node_id, param.pat.hir_id.local_id); this.lower_target_expr(&block) } else { this.generate_arg(param.pat.hir_id, span) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 3df945a18e8..d986c4b412f 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -261,10 +261,12 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> { // expr node id. let block_hir_id = self.lower_node_id(blk.id); let opt_label = self.lower_label(*opt_label, blk.id, block_hir_id); - hir::ExprKind::Block( - self.lower_block_with_hir_id(blk, block_hir_id, opt_label.is_some()), - opt_label, - ) + let hir_block = self.arena.alloc(self.lower_block_noalloc( + block_hir_id, + blk, + opt_label.is_some(), + )); + hir::ExprKind::Block(hir_block, opt_label) } ExprKind::Assign(el, er, span) => self.lower_expr_assign(el, er, *span, e.span), ExprKind::AssignOp(op, el, er) => hir::ExprKind::AssignOp( @@ -1486,7 +1488,7 @@ fn lower_label( dest_hir_id: hir::HirId, ) -> Option