Skip to content

Commit 6df933e

Browse files
committed
Make Clippy happy
1 parent f44c3cf commit 6df933e

File tree

10 files changed

+21
-19
lines changed

10 files changed

+21
-19
lines changed

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
too-many-arguments-threshold = 13
22
cognitive-complexity-threshold = 37
3-
disallowed-names = ["binary"]
3+
disallowed-names = ["binary", "_binary"]

src/codegen/encoding/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,9 +1242,7 @@ pub(crate) trait AbiEncoding {
12421242
// allocated the outer dimension, i.e., we are about to read a 'int[3][4]' item.
12431243
// Arrays whose elements are dynamic cannot be verified.
12441244
if validator.validation_necessary()
1245-
&& !dims[0..(dimension + 1)]
1246-
.iter()
1247-
.any(|d| *d == ArrayLength::Dynamic)
1245+
&& !dims[0..(dimension + 1)].contains(&ArrayLength::Dynamic)
12481246
&& !elem_ty.is_dynamic(ns)
12491247
{
12501248
let mut elems = BigInt::one();

src/codegen/events/polkadot.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ impl EventEmitter for PolkadotEventEmitter<'_> {
148148
.iter()
149149
.map(|e| expression(e, cfg, contract_no, Some(func), self.ns, vartab, opt))
150150
.collect::<Vec<_>>();
151-
let encoded_data = data
152-
.is_empty()
153-
.then(|| Expression::AllocDynamicBytes {
151+
let encoded_data = if data.is_empty() {
152+
Expression::AllocDynamicBytes {
154153
loc,
155154
ty: Type::DynamicBytes,
156155
size: Expression::NumberLiteral {
@@ -160,8 +159,10 @@ impl EventEmitter for PolkadotEventEmitter<'_> {
160159
}
161160
.into(),
162161
initializer: Vec::new().into(),
163-
})
164-
.unwrap_or_else(|| abi_encode(&loc, data, self.ns, vartab, cfg, false).0);
162+
}
163+
} else {
164+
abi_encode(&loc, data, self.ns, vartab, cfg, false).0
165+
};
165166

166167
cfg.add(
167168
vartab,

src/codegen/revert.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub(crate) const PANIC_SELECTOR: [u8; 4] = [0x4e, 0x48, 0x7b, 0x71];
3131
/// Corresponds to the error types from the Solidity language.
3232
///
3333
/// Marked as non-exhaustive because Solidity may add more variants in the future.
34+
#[allow(clippy::large_enum_variant)]
3435
#[non_exhaustive]
3536
#[derive(Debug, PartialEq, Clone)]
3637
pub enum SolidityError {

src/emit/expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2701,7 +2701,7 @@ fn bytes_swap<'a, T: TargetRuntime<'a> + ?Sized>(
27012701
Type::Int(_) | Type::Uint(_) => {
27022702
let value = expression(target, bin, expr, vartab, function).into_int_value();
27032703

2704-
let llvm_ty = bin.llvm_type(&ty);
2704+
let llvm_ty = bin.llvm_type(ty);
27052705

27062706
let src = bin.build_alloca(function, llvm_ty, "src");
27072707

src/emit/strings.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ pub(super) fn format_evaluated_args<'a>(
252252
};
253253
}
254254
(false, Type::Bytes(size)) => {
255-
let buf = bin.build_alloca(function, bin.llvm_type(&arg_ty), "bytesN");
255+
let buf = bin.build_alloca(function, bin.llvm_type(arg_ty), "bytesN");
256256

257257
bin.builder.build_store(buf, val.into_int_value()).unwrap();
258258

@@ -375,7 +375,7 @@ pub(super) fn format_evaluated_args<'a>(
375375
.unwrap()
376376
.into_pointer_value();
377377
} else {
378-
let buf = bin.build_alloca(function, bin.llvm_type(&arg_ty), "uint");
378+
let buf = bin.build_alloca(function, bin.llvm_type(arg_ty), "uint");
379379

380380
bin.builder.build_store(buf, val.into_int_value()).unwrap();
381381

@@ -535,7 +535,7 @@ pub(super) fn format_evaluated_args<'a>(
535535
.unwrap()
536536
.into_pointer_value();
537537
} else {
538-
let buf = bin.build_alloca(function, bin.llvm_type(&arg_ty), "int");
538+
let buf = bin.build_alloca(function, bin.llvm_type(arg_ty), "int");
539539

540540
bin.builder
541541
.build_store(buf, val_phi.as_basic_value().into_int_value())

src/lir/lir_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub enum Type {
5050
Slice(Box<Type>),
5151
}
5252

53+
#[allow(clippy::large_enum_variant)]
5354
#[derive(Clone, Debug)]
5455
pub enum InternalCallTy {
5556
Static { cfg_no: usize },

src/sema/expression/function_call.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3129,6 +3129,7 @@ fn is_solana_external_call(
31293129
}
31303130

31313131
/// Data structure to manage the returns of 'preprocess_contract_call'
3132+
#[allow(clippy::large_enum_variant)]
31323133
enum PreProcessedCall {
31333134
Success {
31343135
call_args: CallArgs,

src/sema/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ impl Type {
14081408
Type::Bytes(_) => false,
14091409
Type::Enum(_) => false,
14101410
Type::Struct(_) => true,
1411-
Type::Array(_, dims) => !dims.iter().any(|d| *d == ArrayLength::Dynamic),
1411+
Type::Array(_, dims) => !dims.contains(&ArrayLength::Dynamic),
14121412
Type::DynamicBytes => false,
14131413
Type::String => false,
14141414
Type::Mapping(..) => false,
@@ -1552,7 +1552,7 @@ impl Type {
15521552
Type::Int(n) | Type::Uint(n) => BigInt::from(n / 8),
15531553
Type::Rational => unreachable!(),
15541554
Type::Array(ty, dims) => {
1555-
if dims.iter().any(|d| *d == ArrayLength::Dynamic) {
1555+
if dims.contains(&ArrayLength::Dynamic) {
15561556
BigInt::from(ns.target.ptr_size() / 8)
15571557
} else {
15581558
ty.struct_elem_alignment(ns)

tests/stylus.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn tests(required_forbidden_pairs: &[(&[&str], &[&str])]) {
7474
let mut successes = Vec::new();
7575
let mut failures = Vec::new();
7676
for path in &paths {
77-
let contents = read_to_string(&path).unwrap();
77+
let contents = read_to_string(path).unwrap();
7878
let contracts = contract_re
7979
.captures_iter(&contents)
8080
.map(|captures| {
@@ -108,7 +108,7 @@ fn tests(required_forbidden_pairs: &[(&[&str], &[&str])]) {
108108
eprintln!("Deploying `{}`", path.display());
109109

110110
let (tempdir, address) = match deploy(
111-
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(&path),
111+
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(path),
112112
contract,
113113
) {
114114
Ok((tempdir, address)) => (tempdir, address),
@@ -130,7 +130,7 @@ fn tests(required_forbidden_pairs: &[(&[&str], &[&str])]) {
130130

131131
for function in argless_functions {
132132
eprintln!("Testing `{function}`");
133-
match call(dir, &address, &[&format!("{function}()")]) {
133+
match call(dir, &address, [format!("{function}()")]) {
134134
Ok(_) => successes.push((path.to_path_buf(), function.to_owned())),
135135
Err(Error(severity, error)) => {
136136
failures.push((path.to_path_buf(), function.to_owned(), severity, error))
@@ -244,7 +244,7 @@ where
244244
"--rpc-url=http://localhost:8547",
245245
"--private-key",
246246
PRIVATE_KEY,
247-
&address,
247+
address,
248248
]
249249
.into_iter()
250250
.map(OsStr::new);

0 commit comments

Comments
 (0)