Skip to content

Commit 1284765

Browse files
committed
Rename PatCtxt::lower_lit to lower_pat_expr
This matches the HIR changes in rust-lang#134228, which introduced `PatExpr` to hold the subset of "expressions" that can appear in a pattern.
1 parent 905b1bf commit 1284765

File tree

1 file changed

+7
-7
lines changed
  • compiler/rustc_mir_build/src/thir/pattern

1 file changed

+7
-7
lines changed

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
189189

190190
// Lower the endpoint into a temporary `PatKind` that will then be
191191
// deconstructed to obtain the constant value and other data.
192-
let mut kind: PatKind<'tcx> = self.lower_lit(expr);
192+
let mut kind: PatKind<'tcx> = self.lower_pat_expr(expr);
193193

194194
// Unpeel any ascription or inline-const wrapper nodes.
195195
loop {
@@ -353,7 +353,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
353353

354354
hir::PatKind::Never => PatKind::Never,
355355

356-
hir::PatKind::Expr(value) => self.lower_lit(value),
356+
hir::PatKind::Expr(value) => self.lower_pat_expr(value),
357357

358358
hir::PatKind::Range(ref lo_expr, ref hi_expr, end) => {
359359
let (lo_expr, hi_expr) = (lo_expr.as_deref(), hi_expr.as_deref());
@@ -708,11 +708,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
708708
PatKind::ExpandedConstant { subpattern, def_id: def_id.to_def_id(), is_inline: true }
709709
}
710710

711-
/// Converts literals, paths and negation of literals to patterns.
712-
/// The special case for negation exists to allow things like `-128_i8`
713-
/// which would overflow if we tried to evaluate `128_i8` and then negate
714-
/// afterwards.
715-
fn lower_lit(&mut self, expr: &'tcx hir::PatExpr<'tcx>) -> PatKind<'tcx> {
711+
/// Lowers the kinds of "expression" that can appear in a HIR pattern:
712+
/// - Paths (e.g. `FOO`, `foo::BAR`, `Option::None`)
713+
/// - Inline const blocks (e.g. `const { 1 + 1 }`)
714+
/// - Literals, possibly negated (e.g. `-128u8`, `"hello"`)
715+
fn lower_pat_expr(&mut self, expr: &'tcx hir::PatExpr<'tcx>) -> PatKind<'tcx> {
716716
let (lit, neg) = match &expr.kind {
717717
hir::PatExprKind::Path(qpath) => {
718718
return self.lower_path(qpath, expr.hir_id, expr.span).kind;

0 commit comments

Comments
 (0)