File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ impl Default for TypeResolverImpl {
1717
1818fn char_to_alphabet_index ( ch : char ) -> usize {
1919 let upper = ch. to_ascii_uppercase ( ) ;
20- if ( 'A' ..= 'Z' ) . contains ( & upper ) {
20+ if upper . is_ascii_uppercase ( ) {
2121 ( ( upper as u8 ) - b'A' ) as usize
2222 } else {
2323 panic ! ( "Not a latin letter {}" , ch)
Original file line number Diff line number Diff line change @@ -176,9 +176,8 @@ impl PostConversionLinter for DotsLinter {
176176 self . ensure_no_dots ( & f. variable_name ) ?;
177177 self . visit_expression ( & f. lower_bound ) ?;
178178 self . visit_expression ( & f. upper_bound ) ?;
179- match & f. step {
180- Some ( s) => self . visit_expression ( s) ?,
181- None => ( ) ,
179+ if let Some ( s) = & f. step {
180+ self . visit_expression ( s) ?;
182181 }
183182 self . visit_statements ( & f. statements )
184183 }
Original file line number Diff line number Diff line change @@ -164,9 +164,8 @@ pub trait PostConversionLinter {
164164 fn visit_for_loop ( & mut self , f : & ForLoop ) -> Result < ( ) , LintErrorPos > {
165165 self . visit_expression ( & f. lower_bound ) ?;
166166 self . visit_expression ( & f. upper_bound ) ?;
167- match & f. step {
168- Some ( s) => self . visit_expression ( s) ?,
169- None => ( ) ,
167+ if let Some ( s) = & f. step {
168+ self . visit_expression ( s) ?;
170169 }
171170 self . visit_statements ( & f. statements )
172171 }
@@ -239,10 +238,9 @@ pub trait PostConversionLinter {
239238 }
240239
241240 fn visit_print ( & mut self , print : & Print ) -> Result < ( ) , LintErrorPos > {
242- match & print. format_string {
243- Some ( f) => self . visit_expression ( f) ?,
244- None => { }
245- } ;
241+ if let Some ( f) = & print. format_string {
242+ self . visit_expression ( f) ?;
243+ }
246244 for print_arg in & print. args {
247245 if let PrintArg :: Expression ( e) = print_arg {
248246 self . visit_expression ( e) ?;
Original file line number Diff line number Diff line change @@ -25,10 +25,10 @@ impl Visitor<Statement> for PrintLinter {
2525
2626impl Visitor < Print > for PrintLinter {
2727 fn visit ( & mut self , print : & Print ) -> VisitResult {
28- if let Some ( f) = & print. format_string {
29- if f. expression_type ( ) != ExpressionType :: BuiltIn ( TypeQualifier :: DollarString ) {
30- return Err ( LintError :: TypeMismatch . at ( f ) ) ;
31- }
28+ if let Some ( f) = & print. format_string
29+ && f. expression_type ( ) != ExpressionType :: BuiltIn ( TypeQualifier :: DollarString )
30+ {
31+ return Err ( LintError :: TypeMismatch . at ( f ) ) ;
3232 }
3333 for print_arg in & print. args {
3434 if let PrintArg :: Expression ( expr_pos) = print_arg {
Original file line number Diff line number Diff line change 1+ use std:: collections:: hash_map;
2+
13use rusty_common:: * ;
24use rusty_parser:: BareName ;
35
@@ -76,7 +78,6 @@ impl Declarations {
7678 if !exists {
7779 self . 0 . insert ( bare_name, signature) ;
7880 }
79- ( )
8081 } )
8182 }
8283
@@ -92,11 +93,11 @@ impl Implementations {
9293 signature : Positioned < Signature > ,
9394 ) -> Result < ( ) , LintErrorPos > {
9495 // add if doesn't already exist, do not tolerate multiple implementations
95- if self . 0 . contains_key ( & bare_name) {
96- Err ( LintError :: DuplicateDefinition . at_pos ( signature. pos ) )
97- } else {
98- self . 0 . insert ( bare_name, signature) ;
96+ if let hash_map:: Entry :: Vacant ( e) = self . 0 . entry ( bare_name) {
97+ e. insert ( signature) ;
9998 Ok ( ( ) )
99+ } else {
100+ Err ( LintError :: DuplicateDefinition . at_pos ( signature. pos ) )
100101 }
101102 }
102103
Original file line number Diff line number Diff line change @@ -809,8 +809,11 @@ mod variable {
809809
810810 fn map_to_property ( name_as_tokens : NameAsTokens ) -> Expression {
811811 let ( name_token, opt_q_token) = name_as_tokens;
812- let mut property_names: VecDeque < String > =
813- name_token. as_str ( ) . split ( '.' ) . map ( |s| s. to_owned ( ) ) . collect ( ) ;
812+ let mut property_names: VecDeque < String > = name_token
813+ . as_str ( )
814+ . split ( '.' )
815+ . map ( |s| s. to_owned ( ) )
816+ . collect ( ) ;
814817 let mut result = Expression :: Variable (
815818 Name :: bare ( BareName :: new ( property_names. pop_front ( ) . unwrap ( ) ) ) ,
816819 VariableInfo :: unresolved ( ) ,
You can’t perform that action at this time.
0 commit comments