Skip to content

Commit 3eb47ea

Browse files
authored
chore: fix clippy (#9333)
1 parent a79dfae commit 3eb47ea

File tree

13 files changed

+18
-18
lines changed

13 files changed

+18
-18
lines changed

crates/cast/bin/tx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ where
252252
};
253253

254254
if self.state.to.is_none() && code.is_none() {
255-
let has_value = self.tx.value.map_or(false, |v| !v.is_zero());
255+
let has_value = self.tx.value.is_some_and(|v| !v.is_zero());
256256
let has_auth = self.auth.is_some();
257257
// We only allow user to omit the recipient address if transaction is an EIP-7702 tx
258258
// without a value.

crates/cheatcodes/src/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ mod tests {
682682
match value {
683683
DynSolValue::Tuple(_) | DynSolValue::CustomStruct { .. } => true,
684684
DynSolValue::Array(v) | DynSolValue::FixedArray(v) => {
685-
v.first().map_or(false, contains_tuple)
685+
v.first().is_some_and(contains_tuple)
686686
}
687687
_ => false,
688688
}

crates/cheatcodes/src/test/expect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ pub(crate) fn handle_expect_emit(
633633
return false
634634
}
635635
// Maybe match source address.
636-
if event_to_fill_or_check.address.map_or(false, |addr| addr != log.address) {
636+
if event_to_fill_or_check.address.is_some_and(|addr| addr != log.address) {
637637
return false;
638638
}
639639
// Maybe match data.

crates/common/src/provider/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl ProviderBuilder {
137137
.wrap_err_with(|| format!("invalid provider URL: {url_str:?}"));
138138

139139
// Use the final URL string to guess if it's a local URL.
140-
let is_local = url.as_ref().map_or(false, |url| guess_local_url(url.as_str()));
140+
let is_local = url.as_ref().is_ok_and(|url| guess_local_url(url.as_str()));
141141

142142
Self {
143143
url,

crates/evm/core/src/backend/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ pub fn update_state<DB: Database>(
19721972
persistent_accounts: Option<&HashSet<Address>>,
19731973
) -> Result<(), DB::Error> {
19741974
for (addr, acc) in state.iter_mut() {
1975-
if !persistent_accounts.map_or(false, |accounts| accounts.contains(addr)) {
1975+
if !persistent_accounts.is_some_and(|accounts| accounts.contains(addr)) {
19761976
acc.info = db.basic(*addr)?.unwrap_or_default();
19771977
for (key, val) in acc.storage.iter_mut() {
19781978
val.present_value = db.storage(*addr, *key)?;

crates/evm/core/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub fn create2_handler_register<I: InspectorExt>(
236236
if create2_overrides_inner
237237
.borrow()
238238
.last()
239-
.map_or(false, |(depth, _)| *depth == ctx.evm.journaled_state.depth())
239+
.is_some_and(|(depth, _)| *depth == ctx.evm.journaled_state.depth())
240240
{
241241
let (_, call_inputs) = create2_overrides_inner.borrow_mut().pop().unwrap();
242242
outcome = ctx.external.call_end(&mut ctx.evm, &call_inputs, outcome);

crates/evm/coverage/src/anchors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub fn find_anchor_branch(
171171
/// Calculates whether `element` is within the range of the target `location`.
172172
fn is_in_source_range(element: &SourceElement, location: &SourceLocation) -> bool {
173173
// Source IDs must match.
174-
let source_ids_match = element.index().map_or(false, |a| a as usize == location.source_id);
174+
let source_ids_match = element.index().is_some_and(|a| a as usize == location.source_id);
175175
if !source_ids_match {
176176
return false;
177177
}

crates/fmt/src/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl CommentWithMetadata {
112112
// line has something
113113
// check if the last comment after code was a postfix comment
114114
if last_comment
115-
.map_or(false, |last| last.loc.end() > code_end && !last.is_prefix())
115+
.is_some_and(|last| last.loc.end() > code_end && !last.is_prefix())
116116
{
117117
// get the indent size of the next item of code
118118
let next_indent_len = src[comment.loc().end()..]

crates/fmt/src/formatter.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct Context {
8888
impl Context {
8989
/// Returns true if the current function context is the constructor
9090
pub(crate) fn is_constructor_function(&self) -> bool {
91-
self.function.as_ref().map_or(false, |f| matches!(f.ty, FunctionTy::Constructor))
91+
self.function.as_ref().is_some_and(|f| matches!(f.ty, FunctionTy::Constructor))
9292
}
9393
}
9494

@@ -341,7 +341,7 @@ impl<'a, W: Write> Formatter<'a, W> {
341341
_ => stmt.loc().start(),
342342
};
343343

344-
self.find_next_line(start_from).map_or(false, |loc| loc >= end_at)
344+
self.find_next_line(start_from).is_some_and(|loc| loc >= end_at)
345345
}
346346
}
347347
}
@@ -560,7 +560,7 @@ impl<'a, W: Write> Formatter<'a, W> {
560560
fn write_doc_block_line(&mut self, comment: &CommentWithMetadata, line: &str) -> Result<()> {
561561
if line.trim().starts_with('*') {
562562
let line = line.trim().trim_start_matches('*');
563-
let needs_space = line.chars().next().map_or(false, |ch| !ch.is_whitespace());
563+
let needs_space = line.chars().next().is_some_and(|ch| !ch.is_whitespace());
564564
write!(self.buf(), " *{}", if needs_space { " " } else { "" })?;
565565
self.write_comment_line(comment, line)?;
566566
self.write_whitespace_separator(true)?;
@@ -1945,7 +1945,7 @@ impl<W: Write> Visitor for Formatter<'_, W> {
19451945
)?;
19461946

19471947
// EOF newline
1948-
if self.last_char().map_or(true, |char| char != '\n') {
1948+
if self.last_char() != Some('\n') {
19491949
writeln!(self.buf())?;
19501950
}
19511951

@@ -3259,7 +3259,7 @@ impl<W: Write> Visitor for Formatter<'_, W> {
32593259

32603260
// we can however check if the contract `is` the `base`, this however also does
32613261
// not cover all cases
3262-
let is_contract_base = self.context.contract.as_ref().map_or(false, |contract| {
3262+
let is_contract_base = self.context.contract.as_ref().is_some_and(|contract| {
32633263
contract.base.iter().any(|contract_base| {
32643264
contract_base
32653265
.name
@@ -3280,7 +3280,7 @@ impl<W: Write> Visitor for Formatter<'_, W> {
32803280
let mut base_or_modifier =
32813281
self.visit_to_chunk(loc.start(), Some(loc.end()), base)?;
32823282
let is_lowercase =
3283-
base_or_modifier.content.chars().next().map_or(false, |c| c.is_lowercase());
3283+
base_or_modifier.content.chars().next().is_some_and(|c| c.is_lowercase());
32843284
if is_lowercase && base_or_modifier.content.ends_with("()") {
32853285
base_or_modifier.content.truncate(base_or_modifier.content.len() - 2);
32863286
}

crates/forge/bin/cmd/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl InitArgs {
8888
}
8989
} else {
9090
// if target is not empty
91-
if root.read_dir().map_or(false, |mut i| i.next().is_some()) {
91+
if root.read_dir().is_ok_and(|mut i| i.next().is_some()) {
9292
if !force {
9393
eyre::bail!(
9494
"Cannot run `init` on a non-empty directory.\n\

crates/forge/src/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl ContractRunner<'_> {
296296
warnings,
297297
)
298298
}
299-
let call_after_invariant = after_invariant_fns.first().map_or(false, |after_invariant_fn| {
299+
let call_after_invariant = after_invariant_fns.first().is_some_and(|after_invariant_fn| {
300300
let match_sig = after_invariant_fn.name == "afterInvariant";
301301
if !match_sig {
302302
warnings.push(format!(

crates/script/src/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl ScriptTransactionBuilder {
152152
// Add the additional contracts created in this transaction, so we can verify them later.
153153
created_contracts.retain(|contract| {
154154
// Filter out the contract that was created by the transaction itself.
155-
self.transaction.contract_address.map_or(true, |addr| addr != contract.address)
155+
self.transaction.contract_address != Some(contract.address)
156156
});
157157

158158
self.transaction.additional_contracts = created_contracts;

crates/script/src/verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl VerifyBundle {
116116
if data.split_at(create2_offset).1.starts_with(bytecode) {
117117
let constructor_args = data.split_at(create2_offset + bytecode.len()).1.to_vec();
118118

119-
if artifact.source.extension().map_or(false, |e| e.to_str() == Some("vy")) {
119+
if artifact.source.extension().is_some_and(|e| e.to_str() == Some("vy")) {
120120
warn!("Skipping verification of Vyper contract: {}", artifact.name);
121121
}
122122

0 commit comments

Comments
 (0)