Skip to content

Commit 7f52215

Browse files
committed
lowering: move {lower_arm,arm} -> expr.rs
1 parent 93570b0 commit 7f52215

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

src/librustc/hir/lowering.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,20 +1316,6 @@ impl<'a> LoweringContext<'a> {
13161316
}
13171317
}
13181318

1319-
fn lower_arm(&mut self, arm: &Arm) -> hir::Arm {
1320-
hir::Arm {
1321-
hir_id: self.next_id(),
1322-
attrs: self.lower_attrs(&arm.attrs),
1323-
pats: arm.pats.iter().map(|x| self.lower_pat(x)).collect(),
1324-
guard: match arm.guard {
1325-
Some(ref x) => Some(hir::Guard::If(P(self.lower_expr(x)))),
1326-
_ => None,
1327-
},
1328-
body: P(self.lower_expr(&arm.body)),
1329-
span: arm.span,
1330-
}
1331-
}
1332-
13331319
/// Given an associated type constraint like one of these:
13341320
///
13351321
/// ```
@@ -4472,17 +4458,6 @@ impl<'a> LoweringContext<'a> {
44724458

44734459
// Helper methods for building HIR.
44744460

4475-
fn arm(&mut self, pats: hir::HirVec<P<hir::Pat>>, expr: P<hir::Expr>) -> hir::Arm {
4476-
hir::Arm {
4477-
hir_id: self.next_id(),
4478-
attrs: hir_vec![],
4479-
pats,
4480-
guard: None,
4481-
span: expr.span,
4482-
body: expr,
4483-
}
4484-
}
4485-
44864461
fn stmt(&mut self, span: Span, node: hir::StmtKind) -> hir::Stmt {
44874462
hir::Stmt { span, node, hir_id: self.next_id() }
44884463
}

src/librustc/hir/lowering/expr.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,20 @@ impl LoweringContext<'_> {
436436
P(self.expr_call(e.span, from_err, hir_vec![e]))
437437
}
438438

439+
fn lower_arm(&mut self, arm: &Arm) -> hir::Arm {
440+
hir::Arm {
441+
hir_id: self.next_id(),
442+
attrs: self.lower_attrs(&arm.attrs),
443+
pats: arm.pats.iter().map(|x| self.lower_pat(x)).collect(),
444+
guard: match arm.guard {
445+
Some(ref x) => Some(hir::Guard::If(P(self.lower_expr(x)))),
446+
_ => None,
447+
},
448+
body: P(self.lower_expr(&arm.body)),
449+
span: arm.span,
450+
}
451+
}
452+
439453
pub(super) fn make_async_expr(
440454
&mut self,
441455
capture_clause: CaptureBy,
@@ -1180,6 +1194,10 @@ impl LoweringContext<'_> {
11801194
)
11811195
}
11821196

1197+
// =========================================================================
1198+
// Helper methods for building HIR.
1199+
// =========================================================================
1200+
11831201
/// Constructs a `true` or `false` literal expression.
11841202
pub(super) fn expr_bool(&mut self, span: Span, val: bool) -> hir::Expr {
11851203
let lit = Spanned { span, node: LitKind::Bool(val) };
@@ -1360,4 +1378,15 @@ impl LoweringContext<'_> {
13601378
is_shorthand: false,
13611379
}
13621380
}
1381+
1382+
fn arm(&mut self, pats: hir::HirVec<P<hir::Pat>>, expr: P<hir::Expr>) -> hir::Arm {
1383+
hir::Arm {
1384+
hir_id: self.next_id(),
1385+
attrs: hir_vec![],
1386+
pats,
1387+
guard: None,
1388+
span: expr.span,
1389+
body: expr,
1390+
}
1391+
}
13631392
}

0 commit comments

Comments
 (0)