Skip to content

Commit 4a528f0

Browse files
committed
Tweak lower_pat_expr
1 parent 17a4229 commit 4a528f0

File tree

1 file changed

+10
-12
lines changed
  • compiler/rustc_mir_build/src/thir/pattern

1 file changed

+10
-12
lines changed

compiler/rustc_mir_build/src/thir/pattern/mod.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -613,19 +613,17 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
613613
/// - Inline const blocks (e.g. `const { 1 + 1 }`)
614614
/// - Literals, possibly negated (e.g. `-128u8`, `"hello"`)
615615
fn lower_pat_expr(&mut self, expr: &'tcx hir::PatExpr<'tcx>) -> PatKind<'tcx> {
616-
let (lit, neg) = match &expr.kind {
617-
hir::PatExprKind::Path(qpath) => {
618-
return self.lower_path(qpath, expr.hir_id, expr.span).kind;
619-
}
616+
match &expr.kind {
617+
hir::PatExprKind::Path(qpath) => self.lower_path(qpath, expr.hir_id, expr.span).kind,
620618
hir::PatExprKind::ConstBlock(anon_const) => {
621-
return self.lower_inline_const(anon_const, expr.hir_id, expr.span);
619+
self.lower_inline_const(anon_const, expr.hir_id, expr.span)
622620
}
623-
hir::PatExprKind::Lit { lit, negated } => (lit, *negated),
624-
};
625-
626-
let ct_ty = self.typeck_results.node_type(expr.hir_id);
627-
let lit_input = LitToConstInput { lit: &lit.node, ty: ct_ty, neg };
628-
let constant = self.tcx.at(expr.span).lit_to_const(lit_input);
629-
self.const_to_pat(constant, ct_ty, expr.hir_id, lit.span).kind
621+
hir::PatExprKind::Lit { lit, negated } => {
622+
let ct_ty = self.typeck_results.node_type(expr.hir_id);
623+
let lit_input = LitToConstInput { lit: &lit.node, ty: ct_ty, neg: *negated };
624+
let constant = self.tcx.at(expr.span).lit_to_const(lit_input);
625+
self.const_to_pat(constant, ct_ty, expr.hir_id, lit.span).kind
626+
}
627+
}
630628
}
631629
}

0 commit comments

Comments
 (0)