77
88#![ deny( clippy:: cast_possible_truncation) ]
99
10- use crate :: ir:: BlockIdx ;
1110use crate :: {
1211 error:: { CodegenError , CodegenErrorType } ,
1312 ir,
@@ -18,13 +17,14 @@ use itertools::Itertools;
1817use num_complex:: Complex64 ;
1918use num_traits:: ToPrimitive ;
2019use rustpython_ast:: located:: { self as located_ast, Located } ;
21- use rustpython_ast:: { Pattern , PatternMatchAs , PatternMatchValue } ;
22- use rustpython_compiler_core:: bytecode:: ComparisonOperator ;
2320use rustpython_compiler_core:: {
24- bytecode:: { self , Arg as OpArgMarker , CodeObject , ConstantData , Instruction , OpArg , OpArgType } ,
21+ bytecode:: {
22+ self , Arg as OpArgMarker , CodeObject , ComparisonOperator , ConstantData , Instruction , OpArg ,
23+ OpArgType ,
24+ } ,
2525 Mode ,
2626} ;
27- use rustpython_parser_core:: source_code:: { LineNumber , SourceLocation , SourceRange } ;
27+ use rustpython_parser_core:: source_code:: { LineNumber , SourceLocation } ;
2828use std:: borrow:: Cow ;
2929
3030type CompileResult < T > = Result < T , CodegenError > ;
@@ -216,7 +216,7 @@ macro_rules! emit {
216216
217217struct PatternContext {
218218 current_block : usize ,
219- blocks : Vec < BlockIdx > ,
219+ blocks : Vec < ir :: BlockIdx > ,
220220 allow_irrefutable : bool ,
221221}
222222
@@ -1766,7 +1766,7 @@ impl Compiler {
17661766
17671767 fn compile_pattern_value (
17681768 & mut self ,
1769- value : & PatternMatchValue < SourceRange > ,
1769+ value : & located_ast :: PatternMatchValue ,
17701770 _pattern_context : & mut PatternContext ,
17711771 ) -> CompileResult < ( ) > {
17721772 self . compile_expression ( & value. value ) ?;
@@ -1781,7 +1781,7 @@ impl Compiler {
17811781
17821782 fn compile_pattern_as (
17831783 & mut self ,
1784- as_pattern : & PatternMatchAs < SourceRange > ,
1784+ as_pattern : & located_ast :: PatternMatchAs ,
17851785 pattern_context : & mut PatternContext ,
17861786 ) -> CompileResult < ( ) > {
17871787 if as_pattern. pattern . is_none ( ) && !pattern_context. allow_irrefutable {
@@ -1808,19 +1808,23 @@ impl Compiler {
18081808
18091809 fn compile_pattern_inner (
18101810 & mut self ,
1811- pattern_type : & Pattern < SourceRange > ,
1811+ pattern_type : & located_ast :: Pattern ,
18121812 pattern_context : & mut PatternContext ,
18131813 ) -> CompileResult < ( ) > {
18141814 match & pattern_type {
1815- Pattern :: MatchValue ( value) => self . compile_pattern_value ( value, pattern_context) ,
1816- Pattern :: MatchAs ( as_pattern) => self . compile_pattern_as ( as_pattern, pattern_context) ,
1815+ located_ast:: Pattern :: MatchValue ( value) => {
1816+ self . compile_pattern_value ( value, pattern_context)
1817+ }
1818+ located_ast:: Pattern :: MatchAs ( as_pattern) => {
1819+ self . compile_pattern_as ( as_pattern, pattern_context)
1820+ }
18171821 _ => Err ( self . error ( CodegenErrorType :: NotImplementedYet ) ) ,
18181822 }
18191823 }
18201824
18211825 fn compile_pattern (
18221826 & mut self ,
1823- pattern_type : & Pattern < SourceRange > ,
1827+ pattern_type : & located_ast :: Pattern ,
18241828 pattern_context : & mut PatternContext ,
18251829 ) -> CompileResult < ( ) > {
18261830 self . compile_pattern_inner ( pattern_type, pattern_context) ?;
@@ -1873,7 +1877,7 @@ impl Compiler {
18731877 emit ! ( self , Instruction :: Pop ) ;
18741878 } else {
18751879 // Show line coverage for default case (it doesn't create bytecode)
1876- emit ! ( self , Instruction :: Noop ) ;
1880+ emit ! ( self , Instruction :: Nop ) ;
18771881 }
18781882 self . compile_statements ( & m. body ) ?;
18791883 }
0 commit comments