Repository: quilt/etk (language: rust)

Issue:
`include_hex` errors out if the file ends with a newline



Discussion / hints:

Fix patch:
diff --git a/etk-analyze/src/blocks/annotated.rs b/etk-analyze/src/blocks/annotated.rs
index a9bd716a..ea3252ac 100644
--- a/etk-analyze/src/blocks/annotated.rs
+++ b/etk-analyze/src/blocks/annotated.rs
@@ -74,8 +74,8 @@ mod z3_exit {
                     when_false,
                     condition,
                 } => {
-                    let when_true = when_true.to_z3(&context);
-                    let condition = condition.to_z3(&context);
+                    let when_true = when_true.to_z3(context);
+                    let condition = condition.to_z3(context);
 
                     Exit::Branch {
                         when_false: *when_false,
diff --git a/etk-analyze/src/cfg.rs b/etk-analyze/src/cfg.rs
index cd55e784..53ed143c 100644
--- a/etk-analyze/src/cfg.rs
+++ b/etk-analyze/src/cfg.rs
@@ -244,6 +244,8 @@ impl ControlFlowGraph {
         !matches!(result, SatResult::Unsat)
     }
 
+    // https://github.com/rust-lang/rust-clippy/issues/6420
+    #[allow(clippy::needless_collect)]
     pub fn refine_shallow(&mut self) {
         let indexes: Vec<_> = self
             .by_offset
diff --git a/etk-analyze/src/sym.rs b/etk-analyze/src/sym.rs
index 96ab4afb..c9d0940a 100644
--- a/etk-analyze/src/sym.rs
+++ b/etk-analyze/src/sym.rs
@@ -855,8 +855,8 @@ mod z3_visit {
                     let lhs = self.arguments.pop().unwrap();
 
                     lhs.bvult(&rhs).ite(
-                        &BV::from_u64(&self.context, 1, 256),
-                        &BV::from_u64(&self.context, 0, 256),
+                        &BV::from_u64(self.context, 1, 256),
+                        &BV::from_u64(self.context, 0, 256),
                     )
                 }
 
@@ -865,8 +865,8 @@ mod z3_visit {
                     let lhs = self.arguments.pop().unwrap();
 
                     lhs.bvugt(&rhs).ite(
-                        &BV::from_u64(&self.context, 1, 256),
-                        &BV::from_u64(&self.context, 0, 256),
+                        &BV::from_u64(self.context, 1, 256),
+                        &BV::from_u64(self.context, 0, 256),
                     )
                 }
 
@@ -875,8 +875,8 @@ mod z3_visit {
                     let lhs = self.arguments.pop().unwrap();
 
                     lhs.bvslt(&rhs).ite(
-                        &BV::from_u64(&self.context, 1, 256),
-                        &BV::from_u64(&self.context, 0, 256),
+                        &BV::from_u64(self.context, 1, 256),
+                        &BV::from_u64(self.context, 0, 256),
                     )
                 }
 
@@ -885,8 +885,8 @@ mod z3_visit {
                     let lhs = self.arguments.pop().unwrap();
 
                     lhs.bvsgt(&rhs).ite(
-                        &BV::from_u64(&self.context, 1, 256),
-                        &BV::from_u64(&self.context, 0, 256),
+                        &BV::from_u64(self.context, 1, 256),
+                        &BV::from_u64(self.context, 0, 256),
                     )
                 }
 
@@ -895,8 +895,8 @@ mod z3_visit {
                     let lhs = self.arguments.pop().unwrap();
 
                     lhs._eq(&rhs).ite(
-                        &BV::from_u64(&self.context, 1, 256),
-                        &BV::from_u64(&self.context, 0, 256),
+                        &BV::from_u64(self.context, 1, 256),
+                        &BV::from_u64(self.context, 0, 256),
                     )
                 }
 
@@ -951,8 +951,8 @@ mod z3_visit {
                     let arg = self.arguments.pop().unwrap();
                     let zero = BV::from_u64(self.context, 0, 256);
                     arg._eq(&zero).ite(
-                        &BV::from_u64(&self.context, 1, 256),
-                        &BV::from_u64(&self.context, 0, 256),
+                        &BV::from_u64(self.context, 1, 256),
+                        &BV::from_u64(self.context, 0, 256),
                     )
                 }
 
@@ -974,9 +974,9 @@ mod z3_visit {
                 Sym::CallDataLoad => {
                     let offset = self.arguments.pop().unwrap();
 
-                    let sort = Sort::bitvector(&self.context, 256);
+                    let sort = Sort::bitvector(self.context, 256);
 
-                    let func = FuncDecl::new(&self.context, "calldataload", &[&sort], &sort);
+                    let func = FuncDecl::new(self.context, "calldataload", &[&sort], &sort);
 
                     let apply = func.apply(&[&Dynamic::from_ast(&offset)]);
                     apply.as_bv().unwrap()
@@ -1010,9 +1010,9 @@ mod z3_visit {
                 Sym::BlockHash => {
                     let num = self.arguments.pop().unwrap();
 
-                    let sort = Sort::bitvector(&self.context, 256);
+                    let sort = Sort::bitvector(self.context, 256);
 
-                    let func = FuncDecl::new(&self.context, "blockhash", &[&sort], &sort);
+                    let func = FuncDecl::new(self.context, "blockhash", &[&sort], &sort);
 
                     let apply = func.apply(&[&Dynamic::from_ast(&num)]);
                     apply.as_bv().unwrap()
diff --git a/etk-asm/src/ingest.rs b/etk-asm/src/ingest.rs
index 584e7704..2a262158 100644
--- a/etk-asm/src/ingest.rs
+++ b/etk-asm/src/ingest.rs
@@ -450,7 +450,7 @@ where
                             path: partial.path().to_owned(),
                         })?;
 
-                    let raw = hex::decode(file)
+                    let raw = hex::decode(file.trim())
                         .map_err(|e| Box::new(e) as Box<dyn std::error::Error>)
                         .context(error::InvalidHex {
                             path: partial.path().to_owned(),


Test patch: