Skip to content

Commit a8ee4e2

Browse files
authored
chore: more clippy lints (#598)
1 parent bd7c629 commit a8ee4e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+504
-408
lines changed

Cargo.toml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,78 @@ no_unknown_fields = [
5454
"starknet-core/no_unknown_fields",
5555
"starknet-providers/no_unknown_fields",
5656
]
57+
58+
[workspace.lints]
59+
rust.missing_debug_implementations = "warn"
60+
rust.missing_docs = "allow"
61+
rust.unreachable_pub = "allow"
62+
rust.unused_must_use = "deny"
63+
rust.rust_2018_idioms = { level = "deny", priority = -1 }
64+
rustdoc.all = "warn"
65+
66+
[workspace.lints.clippy]
67+
# These are some of clippy's nursery (i.e., experimental) lints that we like.
68+
# By default, nursery lints are allowed. Some of the lints below have made good
69+
# suggestions which we fixed. The others didn't have any findings, so we can
70+
# assume they don't have that many false positives. Let's enable them to
71+
# prevent future problems.
72+
branches_sharing_code = "warn"
73+
clear_with_drain = "warn"
74+
derive_partial_eq_without_eq = "warn"
75+
empty_line_after_outer_attr = "warn"
76+
equatable_if_let = "warn"
77+
imprecise_flops = "warn"
78+
iter_on_empty_collections = "warn"
79+
iter_with_drain = "warn"
80+
large_stack_frames = "warn"
81+
manual_clamp = "warn"
82+
mutex_integer = "warn"
83+
needless_pass_by_ref_mut = "warn"
84+
nonstandard_macro_braces = "warn"
85+
or_fun_call = "warn"
86+
path_buf_push_overwrite = "warn"
87+
read_zero_byte_vec = "warn"
88+
redundant_clone = "warn"
89+
suboptimal_flops = "warn"
90+
suspicious_operation_groupings = "warn"
91+
trailing_empty_array = "warn"
92+
trait_duplication_in_bounds = "warn"
93+
transmute_undefined_repr = "warn"
94+
trivial_regex = "warn"
95+
tuple_array_conversions = "warn"
96+
uninhabited_references = "warn"
97+
unused_peekable = "warn"
98+
unused_rounding = "warn"
99+
useless_let_if_seq = "warn"
100+
use_self = "warn"
101+
missing_const_for_fn = "warn"
102+
empty_line_after_doc_comments = "warn"
103+
iter_on_single_items = "warn"
104+
match_same_arms = "warn"
105+
doc_markdown = "warn"
106+
unnecessary_struct_initialization = "warn"
107+
string_lit_as_bytes = "warn"
108+
explicit_into_iter_loop = "warn"
109+
explicit_iter_loop = "warn"
110+
type_repetition_in_bounds = "allow"
111+
manual_string_new = "warn"
112+
naive_bytecount = "warn"
113+
needless_bitwise_bool = "warn"
114+
zero_sized_map_values = "warn"
115+
single_char_pattern = "warn"
116+
needless_continue = "warn"
117+
118+
# These are nursery lints which have findings. Allow them for now. Some are not
119+
# quite mature enough for use in our codebase and some we don't really want.
120+
# Explicitly listing should make it easier to fix in the future.
121+
as_ptr_cast_mut = "allow"
122+
cognitive_complexity = "allow"
123+
collection_is_never_read = "allow"
124+
debug_assert_with_mut_call = "allow"
125+
fallible_impl_from = "allow"
126+
future_not_send = "allow"
127+
needless_collect = "allow"
128+
non_send_fields_in_send_ty = "allow"
129+
redundant_pub_crate = "allow"
130+
significant_drop_in_scrutinee = "allow"
131+
significant_drop_tightening = "allow"

starknet-accounts/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ serde = { version = "1.0.160", features = ["derive"] }
2727
serde_json = "1.0.96"
2828
tokio = { version = "1.27.0", features = ["full"] }
2929
url = "2.3.1"
30+
31+
[lints]
32+
workspace = true

starknet-accounts/src/account/declaration.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const QUERY_VERSION_THREE: Felt = Felt::from_raw([
5252
]);
5353

5454
impl<'a, A> DeclarationV2<'a, A> {
55-
pub fn new(
55+
pub const fn new(
5656
contract_class: Arc<FlattenedSierraClass>,
5757
compiled_class_hash: Felt,
5858
account: &'a A,
@@ -88,8 +88,8 @@ impl<'a, A> DeclarationV2<'a, A> {
8888
}
8989
}
9090

91-
/// Calling this function after manually specifying `nonce` and `max_fee` turns [DeclarationV2]
92-
/// into [PreparedDeclarationV2]. Returns `Err` if either field is `None`.
91+
/// Calling this function after manually specifying `nonce` and `max_fee` turns [`DeclarationV2`]
92+
/// into [`PreparedDeclarationV2`]. Returns `Err` if either field is `None`.
9393
pub fn prepared(self) -> Result<PreparedDeclarationV2<'a, A>, NotPreparedError> {
9494
let nonce = self.nonce.ok_or(NotPreparedError)?;
9595
let max_fee = self.max_fee.ok_or(NotPreparedError)?;
@@ -275,7 +275,7 @@ where
275275
}
276276

277277
impl<'a, A> DeclarationV3<'a, A> {
278-
pub fn new(
278+
pub const fn new(
279279
contract_class: Arc<FlattenedSierraClass>,
280280
compiled_class_hash: Felt,
281281
account: &'a A,
@@ -328,7 +328,7 @@ impl<'a, A> DeclarationV3<'a, A> {
328328
}
329329

330330
/// Calling this function after manually specifying `nonce`, `gas` and `gas_price` turns
331-
/// [DeclarationV3] into [PreparedDeclarationV3]. Returns `Err` if any field is `None`.
331+
/// [`DeclarationV3`] into [`PreparedDeclarationV3`]. Returns `Err` if any field is `None`.
332332
pub fn prepared(self) -> Result<PreparedDeclarationV3<'a, A>, NotPreparedError> {
333333
let nonce = self.nonce.ok_or(NotPreparedError)?;
334334
let gas = self.gas.ok_or(NotPreparedError)?;
@@ -570,7 +570,7 @@ where
570570
}
571571

572572
impl<'a, A> LegacyDeclaration<'a, A> {
573-
pub fn new(contract_class: Arc<LegacyContractClass>, account: &'a A) -> Self {
573+
pub const fn new(contract_class: Arc<LegacyContractClass>, account: &'a A) -> Self {
574574
Self {
575575
account,
576576
contract_class,
@@ -602,7 +602,7 @@ impl<'a, A> LegacyDeclaration<'a, A> {
602602
}
603603

604604
/// Calling this function after manually specifying `nonce` and `max_fee` turns
605-
/// [LegacyDeclaration] into [PreparedLegacyDeclaration]. Returns `Err` if either field is
605+
/// [`LegacyDeclaration`] into [`PreparedLegacyDeclaration`]. Returns `Err` if either field is
606606
/// `None`.
607607
pub fn prepared(self) -> Result<PreparedLegacyDeclaration<'a, A>, NotPreparedError> {
608608
let nonce = self.nonce.ok_or(NotPreparedError)?;
@@ -809,15 +809,15 @@ impl RawDeclarationV2 {
809809
&self.contract_class
810810
}
811811

812-
pub fn compiled_class_hash(&self) -> Felt {
812+
pub const fn compiled_class_hash(&self) -> Felt {
813813
self.compiled_class_hash
814814
}
815815

816-
pub fn nonce(&self) -> Felt {
816+
pub const fn nonce(&self) -> Felt {
817817
self.nonce
818818
}
819819

820-
pub fn max_fee(&self) -> Felt {
820+
pub const fn max_fee(&self) -> Felt {
821821
self.max_fee
822822
}
823823
}
@@ -880,19 +880,19 @@ impl RawDeclarationV3 {
880880
&self.contract_class
881881
}
882882

883-
pub fn compiled_class_hash(&self) -> Felt {
883+
pub const fn compiled_class_hash(&self) -> Felt {
884884
self.compiled_class_hash
885885
}
886886

887-
pub fn nonce(&self) -> Felt {
887+
pub const fn nonce(&self) -> Felt {
888888
self.nonce
889889
}
890890

891-
pub fn gas(&self) -> u64 {
891+
pub const fn gas(&self) -> u64 {
892892
self.gas
893893
}
894894

895-
pub fn gas_price(&self) -> u128 {
895+
pub const fn gas_price(&self) -> u128 {
896896
self.gas_price
897897
}
898898
}
@@ -924,11 +924,11 @@ impl RawLegacyDeclaration {
924924
&self.contract_class
925925
}
926926

927-
pub fn nonce(&self) -> Felt {
927+
pub const fn nonce(&self) -> Felt {
928928
self.nonce
929929
}
930930

931-
pub fn max_fee(&self) -> Felt {
931+
pub const fn max_fee(&self) -> Felt {
932932
self.max_fee
933933
}
934934
}

starknet-accounts/src/account/execution.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const QUERY_VERSION_THREE: Felt = Felt::from_raw([
4141
]);
4242

4343
impl<'a, A> ExecutionV1<'a, A> {
44-
pub fn new(calls: Vec<Call>, account: &'a A) -> Self {
44+
pub const fn new(calls: Vec<Call>, account: &'a A) -> Self {
4545
Self {
4646
account,
4747
calls,
@@ -72,8 +72,8 @@ impl<'a, A> ExecutionV1<'a, A> {
7272
}
7373
}
7474

75-
/// Calling this function after manually specifying `nonce` and `max_fee` turns [ExecutionV1] into
76-
/// [PreparedExecutionV1]. Returns `Err` if either field is `None`.
75+
/// Calling this function after manually specifying `nonce` and `max_fee` turns [`ExecutionV1`] into
76+
/// [`PreparedExecutionV1`]. Returns `Err` if either field is `None`.
7777
pub fn prepared(self) -> Result<PreparedExecutionV1<'a, A>, NotPreparedError> {
7878
let nonce = self.nonce.ok_or(NotPreparedError)?;
7979
let max_fee = self.max_fee.ok_or(NotPreparedError)?;
@@ -90,7 +90,7 @@ impl<'a, A> ExecutionV1<'a, A> {
9090
}
9191

9292
impl<'a, A> ExecutionV3<'a, A> {
93-
pub fn new(calls: Vec<Call>, account: &'a A) -> Self {
93+
pub const fn new(calls: Vec<Call>, account: &'a A) -> Self {
9494
Self {
9595
account,
9696
calls,
@@ -138,7 +138,7 @@ impl<'a, A> ExecutionV3<'a, A> {
138138
}
139139

140140
/// Calling this function after manually specifying `nonce`, `gas` and `gas_price` turns
141-
/// [ExecutionV3] into [PreparedExecutionV3]. Returns `Err` if any field is `None`.
141+
/// [`ExecutionV3`] into [`PreparedExecutionV3`]. Returns `Err` if any field is `None`.
142142
pub fn prepared(self) -> Result<PreparedExecutionV3<'a, A>, NotPreparedError> {
143143
let nonce = self.nonce.ok_or(NotPreparedError)?;
144144
let gas = self.gas.ok_or(NotPreparedError)?;
@@ -583,11 +583,11 @@ impl RawExecutionV1 {
583583
&self.calls
584584
}
585585

586-
pub fn nonce(&self) -> Felt {
586+
pub const fn nonce(&self) -> Felt {
587587
self.nonce
588588
}
589589

590-
pub fn max_fee(&self) -> Felt {
590+
pub const fn max_fee(&self) -> Felt {
591591
self.max_fee
592592
}
593593
}
@@ -667,15 +667,15 @@ impl RawExecutionV3 {
667667
&self.calls
668668
}
669669

670-
pub fn nonce(&self) -> Felt {
670+
pub const fn nonce(&self) -> Felt {
671671
self.nonce
672672
}
673673

674-
pub fn gas(&self) -> u64 {
674+
pub const fn gas(&self) -> u64 {
675675
self.gas
676676
}
677677

678-
pub fn gas_price(&self) -> u128 {
678+
pub const fn gas_price(&self) -> u128 {
679679
self.gas_price
680680
}
681681
}

0 commit comments

Comments
 (0)