فهرست منبع

chore: clippy

skoupidi 2 سال پیش
والد
کامیت
2956207cc5

+ 6 - 6
bin/drk/src/main.rs

@@ -882,7 +882,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 OtcSubcmd::Join => {
                     let mut buf = String::new();
                     stdin().read_to_string(&mut buf)?;
-                    let Some(bytes) = base64::decode(&buf.trim()) else {
+                    let Some(bytes) = base64::decode(buf.trim()) else {
                         eprintln!("Failed to decode partial swap data");
                         exit(2);
                     };
@@ -904,7 +904,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 OtcSubcmd::Inspect => {
                     let mut buf = String::new();
                     stdin().read_to_string(&mut buf)?;
-                    let Some(bytes) = base64::decode(&buf.trim()) else {
+                    let Some(bytes) = base64::decode(buf.trim()) else {
                         eprintln!("Failed to decode swap transaction");
                         exit(2);
                     };
@@ -920,7 +920,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 OtcSubcmd::Sign => {
                     let mut buf = String::new();
                     stdin().read_to_string(&mut buf)?;
-                    let Some(bytes) = base64::decode(&buf.trim()) else {
+                    let Some(bytes) = base64::decode(buf.trim()) else {
                         eprintln!("Failed to decode swap transaction");
                         exit(1);
                     };
@@ -1215,7 +1215,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
         Subcmd::Inspect => {
             let mut buf = String::new();
             stdin().read_to_string(&mut buf)?;
-            let Some(bytes) = base64::decode(&buf.trim()) else {
+            let Some(bytes) = base64::decode(buf.trim()) else {
                 eprintln!("Failed to decode transaction");
                 exit(1);
             };
@@ -1229,7 +1229,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
             println!("Reading transaction from stdin...");
             let mut buf = String::new();
             stdin().read_to_string(&mut buf)?;
-            let Some(bytes) = base64::decode(&buf.trim()) else {
+            let Some(bytes) = base64::decode(buf.trim()) else {
                 eprintln!("Failed to decode transaction");
                 exit(1);
             };
@@ -1342,7 +1342,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 println!("Reading transaction from stdin...");
                 let mut buf = String::new();
                 stdin().read_to_string(&mut buf)?;
-                let Some(bytes) = base64::decode(&buf.trim()) else {
+                let Some(bytes) = base64::decode(buf.trim()) else {
                     eprintln!("Failed to decode transaction");
                     exit(1);
                 };

+ 1 - 1
bin/drk/src/money.rs

@@ -460,7 +460,7 @@ impl Drk {
             let Value::Blob(ref nullifier_bytes) = row[10] else {
                 return Err(Error::ParseFailed("[get_coins] Nullifier bytes parsing failed"))
             };
-            let nullifier: Nullifier = deserialize(nullifier_bytes)?;
+            let _nullifier: Nullifier = deserialize(nullifier_bytes)?;
 
             let Value::Blob(ref leaf_position_bytes) = row[11] else {
                 return Err(Error::ParseFailed("[get_coins] Leaf position bytes parsing failed"))

+ 1 - 1
bin/tau/taud/src/main.rs

@@ -234,7 +234,7 @@ async fn on_receive_task(
 
         let mut task = task.unwrap();
         info!(target: "taud", "Save the task: ref: {}", task.ref_id);
-        task.workspace = workspace.clone();
+        task.workspace.clone_from(workspace);
         if piped {
             // if we can't load the task then it's a new task.
             // otherwise it's a modification.

+ 1 - 1
bin/tau/taud/src/task_info.rs

@@ -434,7 +434,7 @@ impl TaskInfo {
 
     pub fn set_project(&mut self, projects: &[String]) {
         debug!(target: "tau", "TaskInfo::set_project()");
-        self.project = projects.to_owned();
+        projects.clone_into(&mut self.project);
     }
 
     pub fn set_comment(&mut self, c: Comment) {

+ 4 - 4
bin/vanityaddr/src/main.rs

@@ -68,7 +68,7 @@ struct DrkContract {
 trait Prefixable {
     fn new() -> Self;
     fn to_string(&self) -> String;
-    fn get_secret(&self) -> SecretKey;
+    fn _get_secret(&self) -> SecretKey;
 
     fn starts_with(&self, prefix: &str, case_sensitive: bool) -> bool {
         if case_sensitive {
@@ -94,7 +94,7 @@ impl Prefixable for DrkAddr {
         self.public.to_string()
     }
 
-    fn get_secret(&self) -> SecretKey {
+    fn _get_secret(&self) -> SecretKey {
         self.secret
     }
 }
@@ -110,7 +110,7 @@ impl Prefixable for DrkToken {
         self.token_id.to_string()
     }
 
-    fn get_secret(&self) -> SecretKey {
+    fn _get_secret(&self) -> SecretKey {
         self.secret
     }
 }
@@ -126,7 +126,7 @@ impl Prefixable for DrkContract {
         self.contract_id.to_string()
     }
 
-    fn get_secret(&self) -> SecretKey {
+    fn _get_secret(&self) -> SecretKey {
         self.secret
     }
 }

+ 1 - 6
src/contract/test-harness/src/lib.rs

@@ -284,12 +284,7 @@ fn benchmark_wasm_calls(
     tx: &Transaction,
     block_height: u64,
 ) {
-    let mut file = std::fs::OpenOptions::new()
-        .write(true)
-        .create(true)
-        .append(true)
-        .open("bench.csv")
-        .unwrap();
+    let mut file = std::fs::OpenOptions::new().create(true).append(true).open("bench.csv").unwrap();
 
     for (idx, call) in tx.calls.iter().enumerate() {
         let overlay = BlockchainOverlay::new(&validator.blockchain).expect("blockchain overlay");

+ 2 - 0
src/net/transport/nym.rs

@@ -25,6 +25,8 @@ use crate::{util::encoding::base32, Result};
 
 /// Unique, randomly-generated per-connection ID that's used to
 /// identify which connection a message belongs to.
+// TODO: remove this when implemented properly
+#[allow(dead_code)]
 #[derive(Clone, Eq, PartialEq, Hash)]
 struct ConnectionId([u8; 32]);
 

+ 1 - 1
src/runtime/import/smt.rs

@@ -59,7 +59,7 @@ impl<'a> StorageAdapter for SledStorage<'a> {
             );
             return None
         };
-        let Some(value) = value else { return None };
+        let value = value?;
         let mut repr = [0; 32];
         repr.copy_from_slice(&value);
         let value = pallas::Base::from_repr(repr);

+ 1 - 1
src/sdk/python/src/zkas.rs

@@ -193,7 +193,7 @@ impl ZkCircuit {
     fn render(&self, k: u32, filename: &str, width: u32, height: u32, font_size: u32) -> bool {
         use plotters::prelude::*;
         let root = BitMapBackend::new(filename, (width, height)).into_drawing_area();
-        if let Err(_) = root.fill(&WHITE) {
+        if root.fill(&WHITE).is_err() {
             return false
         }
         let root = if let Ok(root) = root.titled("circuit", ("sans-serif", font_size)) {

+ 2 - 2
src/zkas/analyzer.rs

@@ -253,7 +253,7 @@ impl Analyzer {
 
                     // We replace self.heap here so we can do proper heap lookups.
                     heap.push(v.clone());
-                    self.heap = heap.clone();
+                    self.heap.clone_from(&heap);
 
                     //println!("{:#?}", heap);
                     //println!("{:#?}", statements);
@@ -390,7 +390,7 @@ impl Analyzer {
                 var.typ = return_types[0];
                 stmt.lhs = Some(var.clone());
                 heap.push(var.clone());
-                self.heap = heap.clone();
+                self.heap.clone_from(&heap);
             }
 
             //println!("{:#?}", stmt);