@@ -186,7 +186,7 @@ impl Opnd
186186
187187 /// Maps the indices from a previous list of instructions to a new list of
188188 /// instructions.
189- pub fn map_index ( self , indices : & Vec < usize > ) -> Opnd {
189+ pub fn map_index ( self , indices : & [ usize ] ) -> Opnd {
190190 match self {
191191 Opnd :: InsnOut { idx, num_bits } => {
192192 Opnd :: InsnOut { idx : indices[ idx] , num_bits }
@@ -1186,7 +1186,7 @@ impl Assembler
11861186 assert ! ( !name. contains( ' ' ) , "use underscores in label names, not spaces" ) ;
11871187
11881188 let label_idx = self . label_names . len ( ) ;
1189- self . label_names . push ( name. to_string ( ) ) ;
1189+ self . label_names . push ( name. into ( ) ) ;
11901190 Target :: Label ( label_idx)
11911191 }
11921192
@@ -1266,11 +1266,11 @@ impl Assembler
12661266
12671267 /// Spill all live registers to the stack
12681268 pub fn spill_regs ( & mut self ) {
1269- self . spill_regs_except ( & vec ! [ ] ) ;
1269+ self . spill_regs_except ( & [ ] ) ;
12701270 }
12711271
12721272 /// Spill all live registers except `ignored_temps` to the stack
1273- pub fn spill_regs_except ( & mut self , ignored_temps : & Vec < RegOpnd > ) {
1273+ pub fn spill_regs_except ( & mut self , ignored_temps : & [ RegOpnd ] ) {
12741274 // Forget registers above the stack top
12751275 let mut reg_mapping = self . ctx . get_reg_mapping ( ) ;
12761276 for stack_idx in self . ctx . get_stack_size ( ) ..MAX_CTX_TEMPS as u8 {
@@ -1348,17 +1348,17 @@ impl Assembler
13481348
13491349 // Shuffle register moves, sometimes adding extra moves using SCRATCH_REG,
13501350 // so that they will not rewrite each other before they are used.
1351- pub fn reorder_reg_moves ( old_moves : & Vec < ( Reg , Opnd ) > ) -> Vec < ( Reg , Opnd ) > {
1351+ pub fn reorder_reg_moves ( old_moves : & [ ( Reg , Opnd ) ] ) -> Vec < ( Reg , Opnd ) > {
13521352 // Return the index of a move whose destination is not used as a source if any.
1353- fn find_safe_move ( moves : & Vec < ( Reg , Opnd ) > ) -> Option < usize > {
1353+ fn find_safe_move ( moves : & [ ( Reg , Opnd ) ] ) -> Option < usize > {
13541354 moves. iter ( ) . enumerate ( ) . find ( |( _, & ( dest_reg, _) ) | {
13551355 moves. iter ( ) . all ( |& ( _, src_opnd) | src_opnd != Opnd :: Reg ( dest_reg) )
13561356 } ) . map ( |( index, _) | index)
13571357 }
13581358
13591359 // Remove moves whose source and destination are the same
1360- let mut old_moves: Vec < ( Reg , Opnd ) > = old_moves. clone ( ) . into_iter ( )
1361- . filter ( |& ( reg, opnd) | Opnd :: Reg ( reg) != opnd) . collect ( ) ;
1360+ let mut old_moves: Vec < ( Reg , Opnd ) > = old_moves. into_iter ( )
1361+ . filter ( |& & ( reg, opnd) | Opnd :: Reg ( reg) != opnd) . copied ( ) . collect ( ) ;
13621362
13631363 let mut new_moves = vec ! [ ] ;
13641364 while old_moves. len ( ) > 0 {
@@ -1385,6 +1385,7 @@ impl Assembler
13851385 /// Sets the out field on the various instructions that require allocated
13861386 /// registers because their output is used as the operand on a subsequent
13871387 /// instruction. This is our implementation of the linear scan algorithm.
1388+ #[ allow( clippy:: useless_conversion) ]
13881389 pub ( super ) fn alloc_regs ( mut self , regs : Vec < Reg > ) -> Assembler
13891390 {
13901391 //dbg!(&self);
@@ -1394,7 +1395,7 @@ impl Assembler
13941395
13951396 // Mutate the pool bitmap to indicate that the register at that index
13961397 // has been allocated and is live.
1397- fn alloc_reg ( pool : & mut u32 , regs : & Vec < Reg > ) -> Option < Reg > {
1398+ fn alloc_reg ( pool : & mut u32 , regs : & [ Reg ] ) -> Option < Reg > {
13981399 for ( index, reg) in regs. iter ( ) . enumerate ( ) {
13991400 if ( * pool & ( 1 << index) ) == 0 {
14001401 * pool |= 1 << index;
@@ -1405,7 +1406,7 @@ impl Assembler
14051406 }
14061407
14071408 // Allocate a specific register
1408- fn take_reg ( pool : & mut u32 , regs : & Vec < Reg > , reg : & Reg ) -> Reg {
1409+ fn take_reg ( pool : & mut u32 , regs : & [ Reg ] , reg : & Reg ) -> Reg {
14091410 let reg_index = regs. iter ( ) . position ( |elem| elem. reg_no == reg. reg_no ) ;
14101411
14111412 if let Some ( reg_index) = reg_index {
@@ -1419,7 +1420,7 @@ impl Assembler
14191420 // Mutate the pool bitmap to indicate that the given register is being
14201421 // returned as it is no longer used by the instruction that previously
14211422 // held it.
1422- fn dealloc_reg ( pool : & mut u32 , regs : & Vec < Reg > , reg : & Reg ) {
1423+ fn dealloc_reg ( pool : & mut u32 , regs : & [ Reg ] , reg : & Reg ) {
14231424 let reg_index = regs. iter ( ) . position ( |elem| elem. reg_no == reg. reg_no ) ;
14241425
14251426 if let Some ( reg_index) = reg_index {
@@ -1602,7 +1603,7 @@ impl Assembler
16021603 if c_args. len ( ) > 0 {
16031604 // Resolve C argument dependencies
16041605 let c_args_len = c_args. len ( ) as isize ;
1605- let moves = Self :: reorder_reg_moves ( & c_args. drain ( ..) . into_iter ( ) . collect ( ) ) ;
1606+ let moves = Self :: reorder_reg_moves ( & c_args. drain ( ..) . into_iter ( ) . collect :: < Vec < _ > > ( ) ) ;
16061607 shift_live_ranges ( & mut shifted_live_ranges, asm. insns . len ( ) , moves. len ( ) as isize - c_args_len) ;
16071608
16081609 // Push batched C arguments
@@ -1751,7 +1752,7 @@ impl Assembler {
17511752 }
17521753
17531754 pub fn bake_string ( & mut self , text : & str ) {
1754- self . push_insn ( Insn :: BakeString ( text. to_string ( ) ) ) ;
1755+ self . push_insn ( Insn :: BakeString ( text. into ( ) ) ) ;
17551756 }
17561757
17571758 #[ allow( dead_code) ]
@@ -1791,7 +1792,7 @@ impl Assembler {
17911792 }
17921793
17931794 /// Let vm_check_canary() assert the leafness of this ccall if leaf_ccall is set
1794- fn set_stack_canary ( & mut self , opnds : & Vec < Opnd > ) -> Option < Opnd > {
1795+ fn set_stack_canary ( & mut self , opnds : & [ Opnd ] ) -> Option < Opnd > {
17951796 // Use the slot right above the stack top for verifying leafness.
17961797 let canary_opnd = self . stack_opnd ( -1 ) ;
17971798
0 commit comments