From 4f3f56b03c0dabc4f1d3fdbf7b25ed4dd77d2a91 Mon Sep 17 00:00:00 2001 From: tommytrg Date: Mon, 25 Mar 2024 19:14:05 +0100 Subject: [PATCH] chore(cargo): adapt codebase to latest Rust (1.77) --- bridges/centralized-ethereum/src/config.rs | 2 +- config/src/loaders/toml.rs | 2 +- net/src/server/ws/mod.rs | 2 ++ rad/src/operators/array.rs | 2 +- rad/src/operators/map.rs | 2 +- src/cli/node/json_rpc_client.rs | 6 +++--- wallet/src/actors/worker/methods.rs | 10 +++++----- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bridges/centralized-ethereum/src/config.rs b/bridges/centralized-ethereum/src/config.rs index 8a4affce5..55a25fbd9 100644 --- a/bridges/centralized-ethereum/src/config.rs +++ b/bridges/centralized-ethereum/src/config.rs @@ -120,7 +120,7 @@ pub fn from_env() -> Result { thread_local! { /// Thread-local flag to indicate the `nested_toml_if_using_envy` function that we are indeed /// using envy. - static USING_ENVY: Cell = Cell::new(false); + static USING_ENVY: Cell = const { Cell::new(false) }; } /// If using the `envy` crate to deserialize this value, try to deserialize it as a TOML string. diff --git a/config/src/loaders/toml.rs b/config/src/loaders/toml.rs index e44206152..1b6b23e24 100644 --- a/config/src/loaders/toml.rs +++ b/config/src/loaders/toml.rs @@ -48,7 +48,7 @@ pub fn from_str(contents: &str) -> Result { } #[cfg(test)] -thread_local!(static FILE_CONTENTS: Cell<&'static str> = Cell::new("")); +thread_local!(static FILE_CONTENTS: Cell<&'static str> = const { Cell::new("") }); #[cfg(test)] fn read_file_contents(_filename: &Path, contents: &mut String) -> io::Result { diff --git a/net/src/server/ws/mod.rs b/net/src/server/ws/mod.rs index f0facf1c4..a0e0cbe00 100644 --- a/net/src/server/ws/mod.rs +++ b/net/src/server/ws/mod.rs @@ -11,7 +11,9 @@ pub use error::Error; type PubSubHandler = pubsub::PubSubHandler>; +// We need to pass the server as an argument to avoid dropping it before the start had finished /// TODO: doc +#[allow(dead_code)] pub struct Server(server::Server); impl Server { diff --git a/rad/src/operators/array.rs b/rad/src/operators/array.rs index a4136d9f8..80fbc22ab 100644 --- a/rad/src/operators/array.rs +++ b/rad/src/operators/array.rs @@ -64,7 +64,7 @@ fn inner_get(input: &RadonArray, args: &[Value]) -> Result input .value() .get(index) - .map(Clone::clone) + .cloned() .ok_or_else(|| not_found(index)) } diff --git a/rad/src/operators/map.rs b/rad/src/operators/map.rs index f0ccdc105..d02d1dc8c 100644 --- a/rad/src/operators/map.rs +++ b/rad/src/operators/map.rs @@ -22,7 +22,7 @@ fn inner_get(input: &RadonMap, args: &[Value]) -> Result { input .value() .get(&key) - .map(Clone::clone) + .cloned() .ok_or_else(|| not_found(key)) } diff --git a/src/cli/node/json_rpc_client.rs b/src/cli/node/json_rpc_client.rs index c1a9ee6c9..ebbeb5f76 100644 --- a/src/cli/node/json_rpc_client.rs +++ b/src/cli/node/json_rpc_client.rs @@ -1728,10 +1728,10 @@ struct JsonRpcError { /// Id. Can be null, a number, or a string #[derive(Debug, Deserialize)] #[serde(untagged)] -enum Id<'a> { +enum Id { Null, - Number(u64), - String(&'a str), + Number(), + String(), } /// A failed request returns an error with code and message diff --git a/wallet/src/actors/worker/methods.rs b/wallet/src/actors/worker/methods.rs index 268daf6cf..0d20cd0c4 100644 --- a/wallet/src/actors/worker/methods.rs +++ b/wallet/src/actors/worker/methods.rs @@ -618,7 +618,7 @@ impl Worker { .body .outputs .get(output.output_index as usize) - .map(ValueTransferOutput::clone) + .cloned() .ok_or_else(|| { Error::OutputIndexNotFound(output.output_index, format!("{:?}", txn)) }), @@ -626,21 +626,21 @@ impl Worker { .body .outputs .get(output.output_index as usize) - .map(ValueTransferOutput::clone) + .cloned() .ok_or_else(|| { Error::OutputIndexNotFound(output.output_index, format!("{:?}", txn)) }), Transaction::Tally(tally) => tally .outputs .get(output.output_index as usize) - .map(ValueTransferOutput::clone) + .cloned() .ok_or_else(|| { Error::OutputIndexNotFound(output.output_index, format!("{:?}", txn)) }), Transaction::Mint(mint) => mint .outputs .get(output.output_index as usize) - .map(ValueTransferOutput::clone) + .cloned() .ok_or_else(|| { Error::OutputIndexNotFound(output.output_index, format!("{:?}", txn)) }), @@ -648,7 +648,7 @@ impl Worker { .body .outputs .get(output.output_index as usize) - .map(ValueTransferOutput::clone) + .cloned() .ok_or_else(|| { Error::OutputIndexNotFound(output.output_index, format!("{:?}", txn)) }),