@@ -122,12 +122,12 @@ pub(crate) fn partially_evaluate<'a>(
122122 // Expand function bodies of any function named in a directive.
123123 let mut funcs = HashMap :: default ( ) ;
124124 for directive in & directives {
125- if ! funcs. contains_key ( & directive. func ) {
125+ if let std :: collections :: hash_map :: Entry :: Vacant ( e ) = funcs. entry ( directive. func ) {
126126 let mut f = module. clone_and_expand_body ( directive. func ) ?;
127127
128128 if let Some ( path) = & output_ir {
129129 let mut generic_ir_file = path. clone ( ) ;
130- generic_ir_file. push ( & format ! ( "generic_{}.txt" , directive. func) ) ;
130+ generic_ir_file. push ( format ! ( "generic_{}.txt" , directive. func) ) ;
131131 std:: fs:: write (
132132 & generic_ir_file,
133133 format ! ( "{}" , f. display_verbose( "" , Some ( & module) ) ) ,
@@ -150,7 +150,7 @@ pub(crate) fn partially_evaluate<'a>(
150150
151151 f. convert_to_max_ssa ( Some ( cut_blocks) ) ;
152152
153- funcs . insert ( directive . func , ( f, cfg, stats) ) ;
153+ e . insert ( ( f, cfg, stats) ) ;
154154 }
155155 }
156156
@@ -196,7 +196,7 @@ pub(crate) fn partially_evaluate<'a>(
196196 live. sort ( ) ;
197197 writeln ! ( & mut s, "# {}: {:?}" , block, live) . unwrap ( ) ;
198198 }
199- writeln ! ( & mut s, "" ) . unwrap ( ) ;
199+ writeln ! ( & mut s) . unwrap ( ) ;
200200 writeln ! ( & mut s, "{}" , body. display_verbose( "" , Some ( & module) ) ) . unwrap ( ) ;
201201 s
202202 } else {
@@ -259,7 +259,7 @@ pub(crate) fn partially_evaluate<'a>(
259259
260260 if let Some ( path) = & output_ir {
261261 let mut specialized_ir_file = path. clone ( ) ;
262- specialized_ir_file. push ( & format ! ( "specialized_{}_to_{}.txt" , directive. func, func) ) ;
262+ specialized_ir_file. push ( format ! ( "specialized_{}_to_{}.txt" , directive. func, func) ) ;
263263 std:: fs:: write ( & specialized_ir_file, ir) . unwrap ( ) ;
264264 }
265265
@@ -483,10 +483,8 @@ fn find_cut_blocks(
483483 let changed = new != current;
484484 highest_same_ctx_ancestor[ succ] = new;
485485 log:: trace!( "highest same-context ancestor for {}: {}" , succ, new) ;
486- if changed {
487- if queue_set. insert ( succ) {
488- queue. push ( succ) ;
489- }
486+ if changed && queue_set. insert ( succ) {
487+ queue. push ( succ) ;
490488 }
491489 } ) ;
492490 }
@@ -569,10 +567,7 @@ enum EvalResult {
569567}
570568impl EvalResult {
571569 fn is_handled ( & self ) -> bool {
572- match self {
573- & EvalResult :: Unhandled => false ,
574- _ => true ,
575- }
570+ !matches ! ( self , & EvalResult :: Unhandled )
576571 }
577572}
578573
@@ -1106,7 +1101,7 @@ impl<'a> Evaluator<'a> {
11061101 ref if_true,
11071102 ref if_false,
11081103 } => {
1109- assert ! ( ! state. pending_specialize. is_some ( ) ) ;
1104+ assert ! ( state. pending_specialize. is_none ( ) ) ;
11101105 let ( cond, abs_cond) = self . use_value ( state. context , orig_block, new_block, cond) ;
11111106 // Update pending context with new stack if necessary.
11121107 match abs_cond. as_const_truthy ( ) {
@@ -1147,7 +1142,7 @@ impl<'a> Evaluator<'a> {
11471142 } ,
11481143 }
11491144 }
1150- & Terminator :: Br { ref target } => {
1145+ Terminator :: Br { target } => {
11511146 if let Some ( ( index, lo, hi) ) = state. pending_specialize . take ( ) {
11521147 log:: trace!(
11531148 "Branch to target {} with PendingSpecialize on {}" ,
@@ -1192,7 +1187,7 @@ impl<'a> Evaluator<'a> {
11921187 ref targets,
11931188 ref default,
11941189 } => {
1195- assert ! ( ! state. pending_specialize. is_some ( ) ) ;
1190+ assert ! ( state. pending_specialize. is_none ( ) ) ;
11961191 let ( value, abs_value) =
11971192 self . use_value ( state. context , orig_block, new_block, value) ;
11981193 if let Some ( selector) = abs_value. as_const_u32 ( ) {
@@ -1238,7 +1233,7 @@ impl<'a> Evaluator<'a> {
12381233 }
12391234 }
12401235 }
1241- & Terminator :: Return { ref values } => {
1236+ Terminator :: Return { values } => {
12421237 let values = values
12431238 . iter ( )
12441239 . map ( |& value| {
@@ -1255,6 +1250,7 @@ impl<'a> Evaluator<'a> {
12551250 self . func . blocks [ new_block] . terminator = new_term;
12561251 }
12571252
1253+ #[ allow( clippy:: too_many_arguments) ]
12581254 fn abstract_eval (
12591255 & mut self ,
12601256 orig_block : Block ,
@@ -1319,6 +1315,7 @@ impl<'a> Evaluator<'a> {
13191315 Ok ( EvalResult :: Normal ( ret) )
13201316 }
13211317
1318+ #[ allow( clippy:: too_many_arguments) ]
13221319 fn abstract_eval_intrinsic (
13231320 & mut self ,
13241321 orig_block : Block ,
@@ -1470,7 +1467,7 @@ impl<'a> Evaluator<'a> {
14701467 } else if Some ( function_index) == self . intrinsics . pop_stack {
14711468 log:: trace!( "pop_stack: current stack is {:?}" , state. flow. stack) ;
14721469 self . stats . virtstack_reads += 1 ;
1473- if state. flow . stack . len ( ) > 0 {
1470+ if ! state. flow . stack . is_empty ( ) {
14741471 let ( _, reg) = state. flow . stack . remove ( 0 ) ;
14751472 let ( value, abs) = match reg {
14761473 RegValue :: Value { data, abs, .. } => ( data, abs) ,
@@ -1664,6 +1661,7 @@ impl<'a> Evaluator<'a> {
16641661 }
16651662 }
16661663
1664+ #[ allow( clippy:: too_many_arguments) ]
16671665 fn abstract_eval_regs (
16681666 & mut self ,
16691667 _inst : Value ,
@@ -2286,7 +2284,7 @@ impl<'a> Evaluator<'a> {
22862284 //
22872285 // Also look at `locals` and find locals present in pred and
22882286 // not in some succ, and sync them.
2289- for ( _ , & block) in & self . block_map {
2287+ for & block in self . block_map . values ( ) {
22902288 if self . func . blocks [ block] . succs . is_empty ( ) {
22912289 continue ;
22922290 }
0 commit comments