diff --git a/rust/main/agents/relayer/src/msg/gas_payment/policies/minimum.rs b/rust/main/agents/relayer/src/msg/gas_payment/policies/minimum.rs index 0485f025b24..6af77b518d6 100644 --- a/rust/main/agents/relayer/src/msg/gas_payment/policies/minimum.rs +++ b/rust/main/agents/relayer/src/msg/gas_payment/policies/minimum.rs @@ -21,7 +21,6 @@ impl GasPaymentPolicy for GasPaymentPolicyMinimum { /// This is different from not requiring message senders to make any payment at all to /// the configured IGP to get relayed. To relay regardless of the existence of a payment, /// the `None` IGP policy should be used. - async fn message_meets_gas_payment_requirement( &self, _message: &HyperlaneMessage, diff --git a/rust/main/agents/relayer/src/msg/gas_payment/policies/on_chain_fee_quoting.rs b/rust/main/agents/relayer/src/msg/gas_payment/policies/on_chain_fee_quoting.rs index d871f6f270e..bf934c3d2cc 100644 --- a/rust/main/agents/relayer/src/msg/gas_payment/policies/on_chain_fee_quoting.rs +++ b/rust/main/agents/relayer/src/msg/gas_payment/policies/on_chain_fee_quoting.rs @@ -41,7 +41,6 @@ impl GasPaymentPolicy for GasPaymentPolicyOnChainFeeQuoting { /// OnChainFeeQuoting requires the user to pay a specified fraction of the /// estimated gas. Like the Minimum policy, OnChainFeeQuoting requires a /// payment to exist on the IGP specified in the config. - async fn message_meets_gas_payment_requirement( &self, _message: &HyperlaneMessage, diff --git a/rust/main/agents/relayer/src/msg/metadata/base.rs b/rust/main/agents/relayer/src/msg/metadata/base.rs index cc8371ca935..59e59674830 100644 --- a/rust/main/agents/relayer/src/msg/metadata/base.rs +++ b/rust/main/agents/relayer/src/msg/metadata/base.rs @@ -300,7 +300,7 @@ impl IsmCachePolicyClassifier { } IsmCacheSelector::AppContext { context: selector_app_context, - } => app_context.map_or(false, |app_context| app_context == selector_app_context), + } => app_context == Some(selector_app_context), }; if matches_module diff --git a/rust/main/agents/relayer/src/server/mod.rs b/rust/main/agents/relayer/src/server/mod.rs index 8f90fcfdb3e..345cd3ef81d 100644 --- a/rust/main/agents/relayer/src/server/mod.rs +++ b/rust/main/agents/relayer/src/server/mod.rs @@ -85,7 +85,7 @@ impl Server { let expose_environment_variable_endpoint = env::var("HYPERLANE_RELAYER_ENVIRONMENT_VARIABLE_ENDPOINT_ENABLED") - .map_or(false, |v| v == "true"); + .is_ok_and(|v| v == "true"); if expose_environment_variable_endpoint { router = router.merge(EnvironmentVariableApi::new().router()); } diff --git a/rust/main/agents/relayer/src/settings/matching_list.rs b/rust/main/agents/relayer/src/settings/matching_list.rs index ec8500fea12..27bafc1ec67 100644 --- a/rust/main/agents/relayer/src/settings/matching_list.rs +++ b/rust/main/agents/relayer/src/settings/matching_list.rs @@ -199,7 +199,7 @@ impl<'de> Visitor<'de> for FilterVisitor { } } -impl<'de> Visitor<'de> for FilterVisitor { +impl Visitor<'_> for FilterVisitor { type Value = RegexWrapper; fn expecting(&self, fmt: &mut Formatter) -> fmt::Result { diff --git a/rust/main/chains/hyperlane-cosmos-native/src/libs/address.rs b/rust/main/chains/hyperlane-cosmos-native/src/libs/address.rs index 8ec1c00e381..1ac9bb07fde 100644 --- a/rust/main/chains/hyperlane-cosmos-native/src/libs/address.rs +++ b/rust/main/chains/hyperlane-cosmos-native/src/libs/address.rs @@ -45,8 +45,7 @@ impl CosmosAddress { /// - digest: H256 digest (hex representation of address) /// - prefix: Bech32 prefix /// - byte_count: Number of bytes to truncate the digest to. Cosmos addresses can sometimes - /// be less than 32 bytes, so this helps to serialize it in bech32 with the appropriate - /// length. + /// be less than 32 bytes, so this helps to serialize it in bech32 with the appropriate length. pub fn from_h256(digest: H256, prefix: &str, byte_count: usize) -> ChainResult { // This is the hex-encoded version of the address let untruncated_bytes = digest.as_bytes(); diff --git a/rust/main/chains/hyperlane-cosmos-native/src/providers/grpc.rs b/rust/main/chains/hyperlane-cosmos-native/src/providers/grpc.rs index 49468aa051a..4766e81552e 100644 --- a/rust/main/chains/hyperlane-cosmos-native/src/providers/grpc.rs +++ b/rust/main/chains/hyperlane-cosmos-native/src/providers/grpc.rs @@ -82,8 +82,7 @@ impl GrpcProvider { .map(CosmosGrpcClient::new) .map_err(Into::::into) }) - .collect::, _>>() - .map_err(HyperlaneCosmosError::from)?; + .collect::, _>>()?; let fallback = FallbackProvider::new(clients); Ok(Self { fallback }) diff --git a/rust/main/chains/hyperlane-cosmos/src/libs/address.rs b/rust/main/chains/hyperlane-cosmos/src/libs/address.rs index 3c12c3c7884..f314a1f5937 100644 --- a/rust/main/chains/hyperlane-cosmos/src/libs/address.rs +++ b/rust/main/chains/hyperlane-cosmos/src/libs/address.rs @@ -46,8 +46,7 @@ impl CosmosAddress { /// - digest: H256 digest (hex representation of address) /// - prefix: Bech32 prefix /// - byte_count: Number of bytes to truncate the digest to. Cosmos addresses can sometimes - /// be less than 32 bytes, so this helps to serialize it in bech32 with the appropriate - /// length. + /// be less than 32 bytes, so this helps to serialize it in bech32 with the appropriate length. pub fn from_h256(digest: H256, prefix: &str, byte_count: usize) -> ChainResult { // This is the hex-encoded version of the address let untruncated_bytes = digest.as_bytes(); diff --git a/rust/main/chains/hyperlane-ethereum/src/rpc_clients/error.rs b/rust/main/chains/hyperlane-ethereum/src/rpc_clients/error.rs index 0975e975cc1..b109bef415d 100644 --- a/rust/main/chains/hyperlane-ethereum/src/rpc_clients/error.rs +++ b/rust/main/chains/hyperlane-ethereum/src/rpc_clients/error.rs @@ -14,10 +14,7 @@ pub fn decode_revert_reason(return_data: &Bytes) -> Option { // Manually decode the ABI-encoded string // Equivalent to ethers.js: ethers.utils.defaultAbiCoder.decode(['string'], data) - match ::decode(data) { - Ok(reason) => Some(reason), - Err(_) => None, - } + ::decode(data).ok() } else { None } diff --git a/rust/main/chains/hyperlane-ethereum/src/rpc_clients/fallback.rs b/rust/main/chains/hyperlane-ethereum/src/rpc_clients/fallback.rs index 908112e5c75..23c5c2b69d5 100644 --- a/rust/main/chains/hyperlane-ethereum/src/rpc_clients/fallback.rs +++ b/rust/main/chains/hyperlane-ethereum/src/rpc_clients/fallback.rs @@ -24,9 +24,10 @@ const METHOD_SEND_RAW_TRANSACTION: &str = "eth_sendRawTransaction"; /// Wrapper of `FallbackProvider` for use in `hyperlane-ethereum` /// The wrapper uses two distinct strategies to place requests to chains: /// 1. multicast - the request will be sent to all the providers simultaneously and the first -/// successful response will be used. +/// successful response will be used. +/// /// 2. fallback - the request will be sent to each provider one by one according to their -/// priority and the priority will be updated depending on success/failure. +/// priority and the priority will be updated depending on success/failure. /// /// Multicast strategy is used to submit transactions into the chain, namely with RPC method /// `eth_sendRawTransaction` while fallback strategy is used for all the other RPC methods. @@ -235,7 +236,7 @@ where &'a self, method: &'a str, params: &'a Value, - ) -> FuturesUnordered> + Sized + '_> { + ) -> FuturesUnordered> + Sized + 'a> { let unordered = FuturesUnordered::new(); self.inner .providers diff --git a/rust/main/chains/hyperlane-sealevel/src/log_meta_composer.rs b/rust/main/chains/hyperlane-sealevel/src/log_meta_composer.rs index 8c0c232305c..5ae5db10aa7 100644 --- a/rust/main/chains/hyperlane-sealevel/src/log_meta_composer.rs +++ b/rust/main/chains/hyperlane-sealevel/src/log_meta_composer.rs @@ -138,7 +138,7 @@ pub fn is_interchain_payment_instruction(instruction_data: &[u8]) -> bool { /// * `program_id` - Identifier of program for which we are searching transactions for. /// * `pda_pubkey` - Identifier for PDA the relevant transaction should operate upon. /// * `is_specified_instruction` - Function which returns `true` for instruction which should be -/// included into the relevant transaction. +/// included into the relevant transaction. fn search_transactions( transactions: Vec, program_id: &Pubkey, diff --git a/rust/main/chains/hyperlane-starknet/src/indexer.rs b/rust/main/chains/hyperlane-starknet/src/indexer.rs index 2515b09ea7f..63ce1b9ed89 100644 --- a/rust/main/chains/hyperlane-starknet/src/indexer.rs +++ b/rust/main/chains/hyperlane-starknet/src/indexer.rs @@ -212,8 +212,8 @@ impl SequenceAwareIndexer for StarknetMerkleTreeHookIndexer } } -/// TODO: This is a placeholder for the Interchain Gas Paymaster indexer. -/// Interchain Gas Paymaster +// TODO: This is a placeholder for the Interchain Gas Paymaster indexer. +// Interchain Gas Paymaster /// A reference to a InterchainGasPaymasterIndexer contract on some Starknet chain #[derive(Debug, Clone)] diff --git a/rust/main/chains/hyperlane-starknet/src/utils.rs b/rust/main/chains/hyperlane-starknet/src/utils.rs index 5030c94603d..eb14e0a7963 100644 --- a/rust/main/chains/hyperlane-starknet/src/utils.rs +++ b/rust/main/chains/hyperlane-starknet/src/utils.rs @@ -253,7 +253,7 @@ pub fn to_packed_bytes(bytes: &[u8]) -> Vec { // Create a new byte vector with the necessary padding let mut padded_bytes = Vec::with_capacity(total_len); padded_bytes.extend_from_slice(bytes); - padded_bytes.extend(std::iter::repeat(0).take(padding)); + padded_bytes.extend(std::iter::repeat_n(0, padding)); let mut result = Vec::with_capacity(total_len / 16); for chunk in padded_bytes.chunks_exact(16) { diff --git a/rust/main/hyperlane-base/src/db/rocks/iterator.rs b/rust/main/hyperlane-base/src/db/rocks/iterator.rs index 8eaa03fd3dd..c59f551a9e9 100644 --- a/rust/main/hyperlane-base/src/db/rocks/iterator.rs +++ b/rust/main/hyperlane-base/src/db/rocks/iterator.rs @@ -11,7 +11,7 @@ pub struct PrefixIterator<'a, V> { _phantom: PhantomData<*const V>, } -impl<'a, V> Iterator for PrefixIterator<'a, V> +impl Iterator for PrefixIterator<'_, V> where V: Encode + Decode, { diff --git a/rust/main/hyperlane-base/src/server/base_server.rs b/rust/main/hyperlane-base/src/server/base_server.rs index b84d93d3be4..c6683555b51 100644 --- a/rust/main/hyperlane-base/src/server/base_server.rs +++ b/rust/main/hyperlane-base/src/server/base_server.rs @@ -22,7 +22,7 @@ impl Server { /// /// routes: /// - metrics - serving OpenMetrics format reports on `/metrics` - /// (this is compatible with Prometheus, which ought to be configured to scrape this endpoint) + /// (this is compatible with Prometheus, which ought to be configured to scrape this endpoint) /// - custom_routes - additional routes to be served by the server as per the specific agent pub fn run_with_custom_router(self: Arc, router: Router) -> JoinHandle<()> { let port = self.listen_port; diff --git a/rust/main/hyperlane-base/src/settings/parser/json_value_parser.rs b/rust/main/hyperlane-base/src/settings/parser/json_value_parser.rs index 889ff48eee9..8636da3f75f 100644 --- a/rust/main/hyperlane-base/src/settings/parser/json_value_parser.rs +++ b/rust/main/hyperlane-base/src/settings/parser/json_value_parser.rs @@ -401,7 +401,7 @@ impl<'e, T> ParseChain<'e, T> { } } -impl<'e, T: Default> ParseChain<'e, T> { +impl ParseChain<'_, T> { pub fn unwrap_or_default(self) -> T { self.0.unwrap_or_default() } diff --git a/rust/main/hyperlane-base/src/types/multisig.rs b/rust/main/hyperlane-base/src/types/multisig.rs index c61cf959c9c..ea450d6b852 100644 --- a/rust/main/hyperlane-base/src/types/multisig.rs +++ b/rust/main/hyperlane-base/src/types/multisig.rs @@ -267,7 +267,7 @@ impl MultisigCheckpointSyncer { } #[cfg(test)] -pub mod test { +mod test { use std::str::FromStr; use aws_config::Region; diff --git a/rust/main/hyperlane-core/src/chain.rs b/rust/main/hyperlane-core/src/chain.rs index 3e69817f119..fb4fb30fa47 100644 --- a/rust/main/hyperlane-core/src/chain.rs +++ b/rust/main/hyperlane-core/src/chain.rs @@ -29,7 +29,7 @@ pub struct ContractLocator<'a> { } #[cfg(feature = "strum")] -impl<'a> std::fmt::Display for ContractLocator<'a> { +impl std::fmt::Display for ContractLocator<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( f, @@ -91,7 +91,7 @@ impl<'de> Deserialize<'de> for ReorgPeriod { struct ReorgPeriodVisitor; - impl<'de> de::Visitor<'de> for ReorgPeriodVisitor { + impl de::Visitor<'_> for ReorgPeriodVisitor { type Value = ReorgPeriod; fn expecting(&self, f: &mut Formatter) -> std::fmt::Result { diff --git a/rust/main/hyperlane-core/src/lib.rs b/rust/main/hyperlane-core/src/lib.rs index b92b1b48794..b8ff03341ff 100644 --- a/rust/main/hyperlane-core/src/lib.rs +++ b/rust/main/hyperlane-core/src/lib.rs @@ -4,7 +4,6 @@ #![warn(missing_docs)] #![deny(unsafe_code)] #![allow(unknown_lints)] // TODO: `rustc` 1.80.1 clippy issue -#![forbid(where_clauses_object_safety)] #![deny(clippy::unwrap_used, clippy::panic)] extern crate core; diff --git a/rust/main/hyperlane-core/src/rpc_clients/fallback.rs b/rust/main/hyperlane-core/src/rpc_clients/fallback.rs index ec809a7396a..31bce5b2e41 100644 --- a/rust/main/hyperlane-core/src/rpc_clients/fallback.rs +++ b/rust/main/hyperlane-core/src/rpc_clients/fallback.rs @@ -396,7 +396,7 @@ pub mod test { } #[tokio::test] - pub async fn test_deprioritization_by_failed_count() { + async fn test_deprioritization_by_failed_count() { let provider1 = ProviderMock::new(None); let provider2 = ProviderMock::new(None); let provider3 = ProviderMock::new(None); diff --git a/rust/main/hyperlane-core/src/traits/pending_operation.rs b/rust/main/hyperlane-core/src/traits/pending_operation.rs index 0fdace9c4b4..c34e7ee2b0b 100644 --- a/rust/main/hyperlane-core/src/traits/pending_operation.rs +++ b/rust/main/hyperlane-core/src/traits/pending_operation.rs @@ -369,6 +369,7 @@ impl PartialEq for QueueOperation { impl Eq for QueueOperation {} +#[allow(clippy::unnecessary_map_or)] // can't use `.is_ok_and` because it still unstables in `sbf` impl Ord for QueueOperation { fn cmp(&self, other: &Self) -> Ordering { use Ordering::*; diff --git a/rust/main/hyperlane-core/src/types/primitive_types.rs b/rust/main/hyperlane-core/src/types/primitive_types.rs index 648119cddc6..3d063108fcd 100644 --- a/rust/main/hyperlane-core/src/types/primitive_types.rs +++ b/rust/main/hyperlane-core/src/types/primitive_types.rs @@ -2,6 +2,7 @@ #![allow(clippy::assign_op_pattern)] #![allow(clippy::reversed_empty_ranges)] +#![allow(clippy::manual_div_ceil)] use std::{ ops::{Div, Mul}, @@ -45,6 +46,7 @@ construct_uint! { mod fixed_hashes { // we can't change how they made the macro, so ignore the lint #![allow(clippy::non_canonical_clone_impl)] + #![allow(unexpected_cfgs)] use borsh::{BorshDeserialize, BorshSerialize}; use fixed_hash::construct_fixed_hash; diff --git a/rust/main/hyperlane-core/src/types/serialize.rs b/rust/main/hyperlane-core/src/types/serialize.rs index 73558e10ca8..f0d87e10754 100644 --- a/rust/main/hyperlane-core/src/types/serialize.rs +++ b/rust/main/hyperlane-core/src/types/serialize.rs @@ -102,6 +102,7 @@ impl fmt::Display for FromHexError { /// Decode given (both 0x-prefixed or not) hex string into a vector of bytes. /// /// Returns an error if non-hex characters are present. +#[allow(clippy::manual_div_ceil)] // can't use `.div_ceil` because it still unstables in `sbf` pub fn from_hex(v: &str) -> Result, FromHexError> { let (v, stripped) = v.strip_prefix("0x").map_or((v, false), |v| (v, true)); @@ -196,7 +197,7 @@ pub enum ExpectedLen<'a> { Between(usize, &'a mut [u8]), } -impl<'a> fmt::Display for ExpectedLen<'a> { +impl fmt::Display for ExpectedLen<'_> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { ExpectedLen::Exact(ref v) => write!(fmt, "{} bytes", v.len()), @@ -271,7 +272,7 @@ where len: ExpectedLen<'a>, } - impl<'a, 'b> de::Visitor<'b> for Visitor<'a> { + impl<'b> de::Visitor<'b> for Visitor<'_> { type Value = usize; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/rust/main/hyperlane-test/src/lib.rs b/rust/main/hyperlane-test/src/lib.rs index aa76ffae5c0..5a7d5599d9c 100644 --- a/rust/main/hyperlane-test/src/lib.rs +++ b/rust/main/hyperlane-test/src/lib.rs @@ -3,7 +3,6 @@ #![forbid(unsafe_code)] #![cfg_attr(test, warn(missing_docs))] #![allow(unknown_lints)] // TODO: `rustc` 1.80.1 clippy issue -#![forbid(where_clauses_object_safety)] /// Mock contracts pub mod mocks; diff --git a/rust/main/hyperlane-test/src/mocks/mailbox.rs b/rust/main/hyperlane-test/src/mocks/mailbox.rs index 50a775eeffe..8985abd917a 100644 --- a/rust/main/hyperlane-test/src/mocks/mailbox.rs +++ b/rust/main/hyperlane-test/src/mocks/mailbox.rs @@ -5,63 +5,71 @@ use mockall::*; use hyperlane_core::{accumulator::incremental::IncrementalMerkle, *}; -mock! { - pub MailboxContract { - // Mailbox - pub fn _address(&self) -> H256 {} +pub use mock_mailbox_contract::MockMailboxContract; - pub fn _domain(&self) -> &HyperlaneDomain {} +mod mock_mailbox_contract { - pub fn _provider(&self) -> Box {} + #![allow(missing_docs)] + use super::*; - pub fn _domain_hash(&self) -> H256 {} + mock! { + pub MailboxContract { + // Mailbox + pub fn _address(&self) -> H256 {} - pub fn _raw_message_by_id( - &self, - leaf: H256, - ) -> ChainResult> {} + pub fn _domain(&self) -> &HyperlaneDomain {} - pub fn _id_by_nonce( - &self, - nonce: usize, - ) -> ChainResult> {} + pub fn _provider(&self) -> Box {} - pub fn _tree(&self, reorg_period: &ReorgPeriod) -> ChainResult {} + pub fn _domain_hash(&self) -> H256 {} - pub fn _count(&self, reorg_period: &ReorgPeriod) -> ChainResult {} + pub fn _raw_message_by_id( + &self, + leaf: H256, + ) -> ChainResult> {} - pub fn _latest_checkpoint(&self, reorg_period: &ReorgPeriod) -> ChainResult {} + pub fn _id_by_nonce( + &self, + nonce: usize, + ) -> ChainResult> {} - pub fn _default_ism(&self) -> ChainResult {} - pub fn _recipient_ism(&self, recipient: H256) -> ChainResult {} + pub fn _tree(&self, reorg_period: &ReorgPeriod) -> ChainResult {} - pub fn _delivered(&self, id: H256) -> ChainResult {} + pub fn _count(&self, reorg_period: &ReorgPeriod) -> ChainResult {} - pub fn process( - &self, - message: &HyperlaneMessage, - metadata: &[u8], - tx_gas_limit: Option, - ) -> ChainResult {} + pub fn _latest_checkpoint(&self, reorg_period: &ReorgPeriod) -> ChainResult {} - pub fn process_estimate_costs( - &self, - message: &HyperlaneMessage, - metadata: &[u8], - ) -> ChainResult {} + pub fn _default_ism(&self) -> ChainResult {} + pub fn _recipient_ism(&self, recipient: H256) -> ChainResult {} - pub fn process_calldata( - &self, - message: &HyperlaneMessage, - metadata: &[u8], - ) -> Vec {} + pub fn _delivered(&self, id: H256) -> ChainResult {} - pub fn process_batch<'a>( - &self, - ops: Vec<&'a QueueOperation>, - ) -> ChainResult {} + pub fn process( + &self, + message: &HyperlaneMessage, + metadata: &[u8], + tx_gas_limit: Option, + ) -> ChainResult {} - pub fn supports_batching(&self) -> bool { + pub fn process_estimate_costs( + &self, + message: &HyperlaneMessage, + metadata: &[u8], + ) -> ChainResult {} + + pub fn process_calldata( + &self, + message: &HyperlaneMessage, + metadata: &[u8], + ) -> Vec {} + + pub fn process_batch<'a>( + &self, + ops: Vec<&'a QueueOperation>, + ) -> ChainResult {} + + pub fn supports_batching(&self) -> bool { + } } } } @@ -145,6 +153,7 @@ impl HyperlaneContract for MockMailboxContract { } impl MockMailboxContract { + /// Create a new mock mailbox contract with a default ISM pub fn new_with_default_ism(default_ism: H256) -> Self { let mut mock = Self::new(); mock.expect__default_ism() diff --git a/rust/main/hyperlane-test/src/mocks/mod.rs b/rust/main/hyperlane-test/src/mocks/mod.rs index 930ee0059f7..a1177e6d180 100644 --- a/rust/main/hyperlane-test/src/mocks/mod.rs +++ b/rust/main/hyperlane-test/src/mocks/mod.rs @@ -1,5 +1,6 @@ /// Mock mailbox contract pub mod mailbox; +/// Mock validator announce contract pub mod validator_announce; pub use mailbox::MockMailboxContract; diff --git a/rust/main/rust-toolchain b/rust/main/rust-toolchain index bbf217f21b9..4bd1ff459ff 100644 --- a/rust/main/rust-toolchain +++ b/rust/main/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "1.81.0" +channel = "1.86.0" profile = "default" diff --git a/rust/main/utils/abigen/src/lib.rs b/rust/main/utils/abigen/src/lib.rs index 59792424047..201318a40c0 100644 --- a/rust/main/utils/abigen/src/lib.rs +++ b/rust/main/utils/abigen/src/lib.rs @@ -184,25 +184,15 @@ fn fmt_file(path: &Path) { /// Get the rustfmt binary path. #[cfg(feature = "fmt")] fn rustfmt_path() -> &'static Path { - use std::path::PathBuf; + use std::{path::PathBuf, sync::LazyLock}; - // lazy static var - static mut PATH: Option = None; - - if let Some(path) = unsafe { PATH.as_ref() } { - return path; - } - - if let Ok(path) = std::env::var("RUSTFMT") { - unsafe { - PATH = Some(PathBuf::from(path)); - PATH.as_ref().unwrap() + static PATH: LazyLock = LazyLock::new(|| { + if let Ok(path) = std::env::var("RUSTFMT") { + PathBuf::from(path) + } else { + which::which("rustfmt").unwrap_or_else(|_| "rustfmt".into()) } - } else { - // assume it is in PATH - unsafe { - PATH = Some(which::which("rustmft").unwrap_or_else(|_| "rustfmt".into())); - PATH.as_ref().unwrap() - } - } + }); + + PATH.as_path() } diff --git a/rust/main/utils/run-locally/src/utils.rs b/rust/main/utils/run-locally/src/utils.rs index ea9622795c7..411be41c4fb 100644 --- a/rust/main/utils/run-locally/src/utils.rs +++ b/rust/main/utils/run-locally/src/utils.rs @@ -137,8 +137,7 @@ pub fn get_matching_lines<'a>( search_strings.iter().for_each(|search_string_vec| { if search_string_vec .iter() - .map(|search_string| line.contains(search_string)) - .all(|x| x) + .all(|search_string| line.contains(search_string)) { let count = matches.entry(search_string_vec.clone()).or_insert(0); *count += 1; diff --git a/rust/sealevel/programs/helloworld/src/lib.rs b/rust/sealevel/programs/helloworld/src/lib.rs index 7900575e42a..7f753973854 100644 --- a/rust/sealevel/programs/helloworld/src/lib.rs +++ b/rust/sealevel/programs/helloworld/src/lib.rs @@ -3,6 +3,7 @@ #![deny(warnings)] #![deny(missing_docs)] #![deny(unsafe_code)] +#![allow(unexpected_cfgs)] pub mod accounts; pub mod instruction;