@@ -8,8 +8,8 @@ use hir_def::{
88 data:: adt:: { StructKind , VariantData } ,
99 expr_store:: { Body , HygieneId } ,
1010 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 ,
1313 } ,
1414 lang_item:: { LangItem , LangItemTarget } ,
1515 path:: Path ,
@@ -1358,28 +1358,18 @@ impl<'ctx> MirLowerCtx<'ctx> {
13581358 Ok ( ( ) )
13591359 }
13601360
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) => {
13751365 let edition = self . edition ( ) ;
13761366 let unresolved_name =
13771367 || MirLowerError :: unresolved_path ( self . db , c, edition, & self . body . types ) ;
13781368 let pr = self
13791369 . resolver
13801370 . resolve_path_in_value_ns ( self . db . upcast ( ) , c, HygieneId :: ROOT )
13811371 . ok_or_else ( unresolved_name) ?;
1382- match pr {
1372+ dbg ! ( match dbg! ( pr ) {
13831373 ResolveValueResult :: ValueNs ( v, _) => {
13841374 if let ValueNs :: ConstId ( c) = v {
13851375 self . lower_const_to_operand( Substitution :: empty( Interner ) , c. into( ) , ty)
@@ -1390,7 +1380,10 @@ impl<'ctx> MirLowerCtx<'ctx> {
13901380 ResolveValueResult :: Partial ( _, _, _) => {
13911381 not_supported!( "associated constants in range pattern" )
13921382 }
1393- }
1383+ } )
1384+ }
1385+ _ => {
1386+ not_supported ! ( "only `char` and numeric types are allowed in range patterns" ) ;
13941387 }
13951388 }
13961389 }
0 commit comments