Skip to content

Commit

Permalink
Add warn on missing_const_for_fn clippy (#1100)
Browse files Browse the repository at this point in the history
* add missing_const_for_fn to cargo toml

* update clippy
  • Loading branch information
tcoratger authored May 22, 2024
1 parent ec8fda0 commit 2d2fb05
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ unused_peekable = "warn"
unused_rounding = "warn"
useless_let_if_seq = "warn"
use_self = "warn"
missing_const_for_fn = "warn"

# These are nursery lints which have findings. Allow them for now. Some are not
# quite mature enough for use in our codebase and some we don't really want.
Expand All @@ -71,7 +72,6 @@ empty_line_after_doc_comments = "allow"
fallible_impl_from = "allow"
future_not_send = "allow"
iter_on_single_items = "allow"
missing_const_for_fn = "allow"
needless_collect = "allow"
non_send_fields_in_send_ty = "allow"
option_if_let_else = "allow"
Expand Down
2 changes: 1 addition & 1 deletion src/eth_provider/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Database {
}

/// Get a reference to the inner MongoDatabase
pub fn inner(&self) -> &MongoDatabase {
pub const fn inner(&self) -> &MongoDatabase {
&self.0
}

Expand Down
2 changes: 1 addition & 1 deletion src/eth_provider/database/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub struct StoredPendingTransaction {
}

impl StoredPendingTransaction {
pub fn new(tx: Transaction, retries: u64) -> Self {
pub const fn new(tx: Transaction, retries: u64) -> Self {
Self { tx, retries }
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/eth_provider/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ where
SP: starknet::providers::Provider,
{
/// Returns a reference to the database.
pub fn database(&self) -> &Database {
pub const fn database(&self) -> &Database {
&self.database
}
}
Expand Down Expand Up @@ -653,7 +653,7 @@ where
}

#[cfg(feature = "testing")]
pub fn starknet_provider(&self) -> &SP {
pub const fn starknet_provider(&self) -> &SP {
&self.starknet_provider
}

Expand Down
4 changes: 2 additions & 2 deletions src/eth_rpc/middleware/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub struct MetricsLayer {

impl MetricsLayer {
/// Create a new [`MetricsLayer`].
pub fn new(metrics: RpcMetrics, transport_label: &'static str) -> Self {
pub const fn new(metrics: RpcMetrics, transport_label: &'static str) -> Self {
Self { inner: metrics, transport_label }
}
}
Expand All @@ -129,7 +129,7 @@ pub struct Metrics<S> {

impl<S> Metrics<S> {
/// Create a new metrics middleware.
pub fn new(service: S, metrics: RpcMetrics, transport_label: &'static str) -> Self {
pub const fn new(service: S, metrics: RpcMetrics, transport_label: &'static str) -> Self {
Self { service, metrics, transport_label }
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod tests {
self
}

fn with_fee_market(mut self) -> Self {
const fn with_fee_market(mut self) -> Self {
self.tx.max_fee_per_gas = Some(30);
self.tx.max_priority_fee_per_gas = Some(10);
self
Expand Down
2 changes: 1 addition & 1 deletion src/test_utils/evm_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum TransactionInfo {

macro_rules! impl_common_info {
($field: ident, $type: ty) => {
pub fn $field(&self) -> $type {
pub const fn $field(&self) -> $type {
match self {
TransactionInfo::FeeMarketInfo(info) => info.common.$field,
TransactionInfo::LegacyInfo(info) => info.common.$field,
Expand Down
4 changes: 2 additions & 2 deletions src/test_utils/katana/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ impl KatanaGenesisBuilder<Initialized> {
self.cache.get(key).cloned().ok_or(eyre!("Cache miss for {key} address"))
}

pub fn cache(&self) -> &HashMap<String, FieldElement> {
pub const fn cache(&self) -> &HashMap<String, FieldElement> {
&self.cache
}

pub fn class_hashes(&self) -> &HashMap<String, FieldElement> {
pub const fn class_hashes(&self) -> &HashMap<String, FieldElement> {
&self.class_hashes
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/test_utils/mongo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,31 @@ pub enum StoredData {

impl StoredData {
/// Extracts the stored header if it exists, otherwise returns None.
pub fn extract_stored_header(&self) -> Option<&StoredHeader> {
pub const fn extract_stored_header(&self) -> Option<&StoredHeader> {
match self {
Self::StoredHeader(header) => Some(header),
_ => None,
}
}

/// Extracts the stored transaction if it exists, otherwise returns None.
pub fn extract_stored_transaction(&self) -> Option<&StoredTransaction> {
pub const fn extract_stored_transaction(&self) -> Option<&StoredTransaction> {
match self {
Self::StoredTransaction(transaction) => Some(transaction),
_ => None,
}
}

/// Extracts the stored transaction receipt if it exists, otherwise returns None.
pub fn extract_stored_transaction_receipt(&self) -> Option<&StoredTransactionReceipt> {
pub const fn extract_stored_transaction_receipt(&self) -> Option<&StoredTransactionReceipt> {
match self {
Self::StoredTransactionReceipt(receipt) => Some(receipt),
_ => None,
}
}

/// Extracts the stored log if it exists, otherwise returns None.
pub fn extract_stored_log(&self) -> Option<&StoredLog> {
pub const fn extract_stored_log(&self) -> Option<&StoredLog> {
match self {
Self::StoredLog(log) => Some(log),
_ => None,
Expand Down Expand Up @@ -167,7 +167,7 @@ impl MongoFuzzer {
}

/// Obtains an immutable reference to the documents HashMap.
pub fn documents(&self) -> &HashMap<CollectionDB, Vec<StoredData>> {
pub const fn documents(&self) -> &HashMap<CollectionDB, Vec<StoredData>> {
&self.documents
}

Expand All @@ -178,7 +178,7 @@ impl MongoFuzzer {
}

/// Get port number
pub fn port(&self) -> u16 {
pub const fn port(&self) -> u16 {
self.port
}

Expand Down Expand Up @@ -379,7 +379,7 @@ pub struct TransactionBuilder {

impl TransactionBuilder {
/// Specifies the type of transaction to build.
pub fn with_tx_type(mut self, tx_type: TxType) -> Self {
pub const fn with_tx_type(mut self, tx_type: TxType) -> Self {
self.tx_type = Some(tx_type);
self
}
Expand Down
2 changes: 1 addition & 1 deletion src/test_utils/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl RawRpcParamsBuilder {
}

/// Sets the ID for the JSON-RPC request.
pub fn set_id(mut self, id: i32) -> Self {
pub const fn set_id(mut self, id: i32) -> Self {
self.id = id;
self
}
Expand Down

0 comments on commit 2d2fb05

Please sign in to comment.