@@ -8,8 +8,8 @@ use hir_def::{
8
8
data:: adt:: { StructKind , VariantData } ,
9
9
expr_store:: { Body , HygieneId } ,
10
10
hir:: {
11
- ArithOp , Array , BinaryOp , BindingAnnotation , BindingId , ExprId , LabelId , Literal ,
12
- LiteralOrConst , MatchArm , Pat , PatId , RecordFieldPat , RecordLitField ,
11
+ ArithOp , Array , BinaryOp , BindingAnnotation , BindingId , ExprId , LabelId , Literal , MatchArm ,
12
+ Pat , PatId , RecordFieldPat , RecordLitField ,
13
13
} ,
14
14
lang_item:: { LangItem , LangItemTarget } ,
15
15
path:: Path ,
@@ -1358,28 +1358,18 @@ impl<'ctx> MirLowerCtx<'ctx> {
1358
1358
Ok ( ( ) )
1359
1359
}
1360
1360
1361
- fn lower_literal_or_const_to_operand (
1362
- & mut self ,
1363
- ty : Ty ,
1364
- loc : & LiteralOrConst ,
1365
- ) -> Result < Operand > {
1366
- match loc {
1367
- LiteralOrConst :: Literal ( l) => self . lower_literal_to_operand ( ty, l) ,
1368
- LiteralOrConst :: Const ( c) => {
1369
- let c = match & self . body . pats [ * c] {
1370
- Pat :: Path ( p) => p,
1371
- _ => not_supported ! (
1372
- "only `char` and numeric types are allowed in range patterns"
1373
- ) ,
1374
- } ;
1361
+ fn lower_literal_or_const_to_operand ( & mut self , ty : Ty , loc : & ExprId ) -> Result < Operand > {
1362
+ match dbg ! ( & self . body. exprs[ * loc] ) {
1363
+ Expr :: Literal ( l) => self . lower_literal_to_operand ( ty, l) ,
1364
+ Expr :: Path ( c) => {
1375
1365
let edition = self . edition ( ) ;
1376
1366
let unresolved_name =
1377
1367
|| MirLowerError :: unresolved_path ( self . db , c, edition, & self . body . types ) ;
1378
1368
let pr = self
1379
1369
. resolver
1380
1370
. resolve_path_in_value_ns ( self . db . upcast ( ) , c, HygieneId :: ROOT )
1381
1371
. ok_or_else ( unresolved_name) ?;
1382
- match pr {
1372
+ dbg ! ( match dbg! ( pr ) {
1383
1373
ResolveValueResult :: ValueNs ( v, _) => {
1384
1374
if let ValueNs :: ConstId ( c) = v {
1385
1375
self . lower_const_to_operand( Substitution :: empty( Interner ) , c. into( ) , ty)
@@ -1390,7 +1380,10 @@ impl<'ctx> MirLowerCtx<'ctx> {
1390
1380
ResolveValueResult :: Partial ( _, _, _) => {
1391
1381
not_supported!( "associated constants in range pattern" )
1392
1382
}
1393
- }
1383
+ } )
1384
+ }
1385
+ _ => {
1386
+ not_supported ! ( "only `char` and numeric types are allowed in range patterns" ) ;
1394
1387
}
1395
1388
}
1396
1389
}
0 commit comments