about summary refs log tree commit diff
path: root/tvix/eval/src/disassembler.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-03T01·20+0300
committertazjin <tazjin@tvl.su>2022-09-08T20·17+0000
commit09eaa0d4ae63b0513c934535a40fa2aaa25846e1 (patch)
tree8070b85c5408b5f3d7073c025a322c27502fc581 /tvix/eval/src/disassembler.rs
parentfe047885d75a97bd303176847db7fdb2a781344d (diff)
fix(tvix/eval): address current clippy & grfn lints r/4763
Change-Id: I65c6feb9f817b5b367d37204a1f57acfe4100d97
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6430
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/disassembler.rs')
-rw-r--r--tvix/eval/src/disassembler.rs34
1 files changed, 17 insertions, 17 deletions
diff --git a/tvix/eval/src/disassembler.rs b/tvix/eval/src/disassembler.rs
index a555f9179102..b089797f8ab1 100644
--- a/tvix/eval/src/disassembler.rs
+++ b/tvix/eval/src/disassembler.rs
@@ -13,34 +13,36 @@ use crate::value::Value;
 /// failure exits from the VM).
 pub struct Tracer(TabWriter<Stderr>);
 
-impl Tracer {
-    pub fn new() -> Self {
+impl Default for Tracer {
+    fn default() -> Self {
         Tracer(TabWriter::new(std::io::stderr()))
     }
+}
 
+impl Tracer {
     pub fn trace(&mut self, op: &OpCode, ip: usize, stack: &[Value]) {
-        write!(&mut self.0, "{:04} {:?}\t[ ", ip, op).ok();
+        let _ = write!(&mut self.0, "{:04} {:?}\t[ ", ip, op);
 
         for val in stack {
-            write!(&mut self.0, "{} ", val).ok();
+            let _ = write!(&mut self.0, "{} ", val);
         }
 
-        write!(&mut self.0, "]\n").ok();
+        let _ = writeln!(&mut self.0, "]");
     }
 
     pub fn literal(&mut self, line: &str) {
-        let _ = write!(&mut self.0, "{}\n", line);
+        let _ = writeln!(&mut self.0, "{}", line);
     }
 }
 
 impl Drop for Tracer {
     fn drop(&mut self) {
-        self.0.flush().ok();
+        let _ = self.0.flush();
     }
 }
 
 fn disassemble_op(tw: &mut TabWriter<Stderr>, chunk: &Chunk, width: usize, offset: usize) {
-    write!(tw, "{:0width$}\t ", offset, width = width).ok();
+    let _ = write!(tw, "{:0width$}\t ", offset, width = width);
 
     let span = chunk.get_span(CodeIdx(offset));
 
@@ -51,10 +53,9 @@ fn disassemble_op(tw: &mut TabWriter<Stderr>, chunk: &Chunk, width: usize, offse
         write!(tw, "{:4}\t", loc.begin.line + 1).unwrap();
     }
 
-    match chunk.code[offset] {
-        OpCode::OpConstant(idx) => write!(tw, "OpConstant({})\n", chunk.constant(idx)).ok(),
-
-        op => write!(tw, "{:?}\n", op).ok(),
+    let _ = match chunk.code[offset] {
+        OpCode::OpConstant(idx) => writeln!(tw, "OpConstant({})", chunk.constant(idx)),
+        op => writeln!(tw, "{:?}", op),
     };
 }
 
@@ -63,17 +64,16 @@ fn disassemble_op(tw: &mut TabWriter<Stderr>, chunk: &Chunk, width: usize, offse
 pub fn disassemble_chunk(chunk: &Chunk) {
     let mut tw = TabWriter::new(std::io::stderr());
 
-    write!(
+    let _ = writeln!(
         &mut tw,
-        "=== compiled bytecode ({} operations) ===\n",
+        "=== compiled bytecode ({} operations) ===",
         chunk.code.len()
-    )
-    .ok();
+    );
 
     let width = format!("{}", chunk.code.len()).len();
     for (idx, _) in chunk.code.iter().enumerate() {
         disassemble_op(&mut tw, chunk, width, idx);
     }
 
-    tw.flush().ok();
+    let _ = tw.flush();
 }