Skip to content

Commit

Permalink
🥢 Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Philogy committed Nov 18, 2024
1 parent 679a436 commit 763a9e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
13 changes: 4 additions & 9 deletions crates/analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,10 @@ impl<'a, 'src, 'ast: 'src, E: FnMut(AnalysisError<'ast, 'src>)> MacroAnalysis<'a
});
return;
}
if self
.global_defs
.get(code_ref.ident())
.map_or(false, |defs| {
defs.iter().any(
|def| matches!(def, Definition::Macro(m) if m.args.0.len() > 0),
)
})
{
if self.global_defs.get(code_ref.ident()).is_some_and(|defs| {
defs.iter()
.any(|def| matches!(def, Definition::Macro(m) if m.args.0.len() > 0))
}) {
self.emit(AnalysisError::NotYetSupported {
intent: "code introspection for macros with arguments".to_owned(),
span: ((), code_ref.1),
Expand Down
8 changes: 5 additions & 3 deletions crates/ast/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn u256_as_push(value: U256) -> Opcode {
}
}

pub fn compute_selector(name: &Spanned<&str>, args: Box<[&Spanned<DynSolType>]>) -> FixedBytes<4> {
pub fn compute_selector(name: &Spanned<&str>, args: &[&Spanned<DynSolType>]) -> FixedBytes<4> {
let arg_types: Vec<String> = args.iter().map(|arg| arg.0.to_string()).collect();

let signature = format!("{}({})", name.0, arg_types.join(","));
Expand Down Expand Up @@ -90,8 +90,10 @@ mod tests {
]),
};

let func_selector = compute_selector(&func.name, func.args.iter().collect::<Box<[_]>>());
let err_selector = compute_selector(&err.name, err.args.iter().collect::<Box<[_]>>());
let func_selector =
compute_selector(&func.name, func.args.iter().collect::<Vec<_>>().as_slice());
let err_selector =
compute_selector(&err.name, err.args.iter().collect::<Vec<_>>().as_slice());

let expected_func_signature = "transfer(address,uint256)";
let expected_err_signature = "TransferFailed(string,uint256)";
Expand Down

0 comments on commit 763a9e9

Please sign in to comment.