Browse Source

src: Fix rust-analyzer diagnostics for shorthand struct initialization

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Quentin Monnet 2 years ago
parent
commit
1c3bf0046d
5 changed files with 26 additions and 23 deletions
  1. 1 1
      src/assembler.rs
  2. 2 2
      src/disassembler.rs
  3. 10 10
      src/insn_builder.rs
  4. 5 2
      src/jit.rs
  5. 8 8
      src/lib.rs

+ 1 - 1
src/assembler.rs

@@ -131,7 +131,7 @@ fn insn(opc: u8, dst: i64, src: i64, off: i64, imm: i64) -> Result<Insn, String>
         return Err(format!("Invalid immediate {imm}"));
     }
     Ok(Insn {
-        opc: opc,
+        opc,
         dst: dst as u8,
         src: src as u8,
         off: off as i16,

+ 2 - 2
src/disassembler.rs

@@ -339,11 +339,11 @@ pub fn to_insn_vec(prog: &[u8]) -> Vec<HLInsn> {
         let hl_insn = HLInsn {
             opc:  insn.opc,
             name: name.to_string(),
-            desc: desc,
+            desc,
             dst:  insn.dst,
             src:  insn.src,
             off:  insn.off,
-            imm:  imm,
+            imm,
         };
 
         res.push(hl_insn);

+ 10 - 10
src/insn_builder.rs

@@ -175,8 +175,8 @@ impl BpfCode {
         Move {
             bpf_code: self,
             src_bit: source,
-            op_bits: op_bits,
-            arch_bits: arch_bits,
+            op_bits,
+            arch_bits,
             insn: Insn {
                 opc: 0x00,
                 dst: 0x00,
@@ -191,7 +191,7 @@ impl BpfCode {
     pub fn swap_bytes(&mut self, endian: Endian) -> SwapBytes {
         SwapBytes {
             bpf_code: self,
-            endian: endian,
+            endian,
             insn: Insn {
                 opc: 0x00,
                 dst: 0x00,
@@ -226,9 +226,9 @@ impl BpfCode {
     fn load_internal(&mut self, mem_size: MemSize, addressing: Addressing, source: u8) -> Load {
         Load {
             bpf_code: self,
-            addressing: addressing,
-            mem_size: mem_size,
-            source: source,
+            addressing,
+            mem_size,
+            source,
             insn: Insn {
                 opc: 0x00,
                 dst: 0x00,
@@ -253,8 +253,8 @@ impl BpfCode {
     fn store_internal(&mut self, mem_size: MemSize, source: u8) -> Store {
         Store {
             bpf_code: self,
-            mem_size: mem_size,
-            source: source,
+            mem_size,
+            source,
             insn: Insn {
                 opc: 0x00,
                 dst: 0x00,
@@ -274,8 +274,8 @@ impl BpfCode {
     pub fn jump_conditional(&mut self, cond: Cond, src_bit: Source) -> Jump {
         Jump {
             bpf_code: self,
-            cond: cond,
-            src_bit: src_bit,
+            cond,
+            src_bit,
             insn: Insn {
                 opc: 0x00,
                 dst: 0x00,

+ 5 - 2
src/jit.rs

@@ -107,7 +107,10 @@ fn emit8(jit: &mut JitMemory, data: u64) {
 
 #[inline]
 fn emit_jump_offset(jit: &mut JitMemory, target_pc: isize) {
-    let jump = Jump { offset_loc: jit.offset, target_pc: target_pc };
+    let jump = Jump {
+        offset_loc: jit.offset,
+        target_pc,
+    };
     jit.jumps.push(jump);
     emit4(jit, 0);
 }
@@ -480,7 +483,7 @@ impl<'a> JitMemory<'a> {
         }
 
         JitMemory {
-            contents:        contents,
+            contents,
             offset:          0,
             pc_locs:         vec![],
             jumps:           vec![],

+ 8 - 8
src/lib.rs

@@ -126,7 +126,7 @@ impl<'a> EbpfVmMbuff<'a> {
         }
 
         Ok(EbpfVmMbuff {
-            prog:     prog,
+            prog,
             verifier: verifier::check,
             jit:      None,
             helpers:  HashMap::new(),
@@ -475,13 +475,13 @@ impl<'a> EbpfVmFixedMbuff<'a> {
         let get_buff_len = | x: usize, y: usize | if x >= y { x + 8 } else { y + 8 };
         let buffer = vec![0u8; get_buff_len(data_offset, data_end_offset)];
         let mbuff = MetaBuff {
-            data_offset:     data_offset,
-            data_end_offset: data_end_offset,
-            buffer:          buffer,
+            data_offset,
+            data_end_offset,
+            buffer,
         };
         Ok(EbpfVmFixedMbuff {
-            parent: parent,
-            mbuff:  mbuff,
+            parent,
+            mbuff,
         })
     }
 
@@ -801,7 +801,7 @@ impl<'a> EbpfVmRaw<'a> {
     pub fn new(prog: Option<&'a [u8]>) -> Result<EbpfVmRaw<'a>, Error> {
         let parent = EbpfVmMbuff::new(prog)?;
          Ok(EbpfVmRaw {
-            parent: parent,
+            parent,
         })
     }
 
@@ -1070,7 +1070,7 @@ impl<'a> EbpfVmNoData<'a> {
     pub fn new(prog: Option<&'a [u8]>) -> Result<EbpfVmNoData<'a>, Error> {
         let parent = EbpfVmRaw::new(prog)?;
         Ok(EbpfVmNoData {
-            parent: parent,
+            parent,
         })
     }