@@ -189,7 +189,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
189
189
190
190
// Lower the endpoint into a temporary `PatKind` that will then be
191
191
// 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) ;
193
193
194
194
// Unpeel any ascription or inline-const wrapper nodes.
195
195
loop {
@@ -353,7 +353,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
353
353
354
354
hir:: PatKind :: Never => PatKind :: Never ,
355
355
356
- hir:: PatKind :: Expr ( value) => self . lower_lit ( value) ,
356
+ hir:: PatKind :: Expr ( value) => self . lower_pat_expr ( value) ,
357
357
358
358
hir:: PatKind :: Range ( ref lo_expr, ref hi_expr, end) => {
359
359
let ( lo_expr, hi_expr) = ( lo_expr. as_deref ( ) , hi_expr. as_deref ( ) ) ;
@@ -708,11 +708,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
708
708
PatKind :: ExpandedConstant { subpattern, def_id : def_id. to_def_id ( ) , is_inline : true }
709
709
}
710
710
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 > {
716
716
let ( lit, neg) = match & expr. kind {
717
717
hir:: PatExprKind :: Path ( qpath) => {
718
718
return self . lower_path ( qpath, expr. hir_id , expr. span ) . kind ;
0 commit comments