Skip to content

Commit 70eca99

Browse files
committed
nix lower_label identity function.
1 parent 52179c5 commit 70eca99

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

src/librustc_ast_lowering/expr.rs

+7-21
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
8282
this.lower_expr_while_in_loop_scope(e.span, cond, body, opt_label)
8383
}),
8484
ExprKind::Loop(ref body, opt_label) => self.with_loop_scope(e.id, |this| {
85-
hir::ExprKind::Loop(
86-
this.lower_block(body, false),
87-
this.lower_label(opt_label),
88-
hir::LoopSource::Loop,
89-
)
85+
hir::ExprKind::Loop(this.lower_block(body, false), opt_label, hir::LoopSource::Loop)
9086
}),
9187
ExprKind::TryBlock(ref body) => self.lower_expr_try_block(body),
9288
ExprKind::Match(ref expr, ref arms) => hir::ExprKind::Match(
@@ -123,10 +119,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
123119
self.lower_expr_closure(capture_clause, movability, decl, body, fn_decl_span)
124120
}
125121
}
126-
ExprKind::Block(ref blk, opt_label) => hir::ExprKind::Block(
127-
self.lower_block(blk, opt_label.is_some()),
128-
self.lower_label(opt_label),
129-
),
122+
ExprKind::Block(ref blk, opt_label) => {
123+
hir::ExprKind::Block(self.lower_block(blk, opt_label.is_some()), opt_label)
124+
}
130125
ExprKind::Assign(ref el, ref er, span) => {
131126
hir::ExprKind::Assign(self.lower_expr(el), self.lower_expr(er), span)
132127
}
@@ -407,11 +402,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
407402
);
408403

409404
// `[opt_ident]: loop { ... }`
410-
hir::ExprKind::Loop(
411-
self.block_expr(self.arena.alloc(match_expr)),
412-
self.lower_label(opt_label),
413-
source,
414-
)
405+
hir::ExprKind::Loop(self.block_expr(self.arena.alloc(match_expr)), opt_label, source)
415406
}
416407

417408
/// Desugar `try { <stmts>; <expr> }` into `{ <stmts>; ::std::ops::Try::from_ok(<expr>) }`,
@@ -836,10 +827,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
836827
}
837828
}
838829

839-
fn lower_label(&mut self, label: Option<Label>) -> Option<Label> {
840-
label.map(|label| Label { ident: label.ident })
841-
}
842-
843830
fn lower_loop_destination(&mut self, destination: Option<(NodeId, Label)>) -> hir::Destination {
844831
let target_id = match destination {
845832
Some((id, _)) => {
@@ -857,7 +844,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
857844
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope))
858845
.into(),
859846
};
860-
hir::Destination { label: self.lower_label(destination.map(|(_, label)| label)), target_id }
847+
hir::Destination { label: destination.map(|(_, label)| label), target_id }
861848
}
862849

863850
fn lower_jump_destination(&mut self, id: NodeId, opt_label: Option<Label>) -> hir::Destination {
@@ -1100,8 +1087,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11001087
);
11011088

11021089
// `[opt_ident]: loop { ... }`
1103-
let kind =
1104-
hir::ExprKind::Loop(loop_block, self.lower_label(opt_label), hir::LoopSource::ForLoop);
1090+
let kind = hir::ExprKind::Loop(loop_block, opt_label, hir::LoopSource::ForLoop);
11051091
let loop_expr = self.arena.alloc(hir::Expr {
11061092
hir_id: self.lower_node_id(e.id),
11071093
kind,

0 commit comments

Comments
 (0)