Skip to content

Commit bab223d

Browse files
committed
Address remaining Clippy warnings in Stylus files
1 parent a97b565 commit bab223d

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

src/emit/stylus/cargo_stylus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn compress_wasm(wasm: &[u8]) -> anyhow::Result<(Vec<u8>, Vec<u8>)> {
1515
/// EOF prefix used in Stylus compressed WASMs on-chain
1616
const EOF_PREFIX_NO_DICT: &str = "EFF00000";
1717

18-
let mut compressor = BrotliEncoder::new(&*wasm, BROTLI_COMPRESSION_LEVEL);
18+
let mut compressor = BrotliEncoder::new(wasm, BROTLI_COMPRESSION_LEVEL);
1919
let mut compressed_bytes = vec![];
2020
compressor
2121
.read_to_end(&mut compressed_bytes)

src/emit/stylus/target.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ impl<'a> TargetRuntime<'a> for StylusTarget {
683683
ptr_plus_offset(
684684
bin,
685685
contract_byte_ptr,
686-
bin.context.i32_type().const_int(19 as u64, false),
686+
bin.context.i32_type().const_int(19_u64, false),
687687
),
688688
bin.context.i8_type().const_int(0x01, false),
689689
)
@@ -695,7 +695,7 @@ impl<'a> TargetRuntime<'a> for StylusTarget {
695695
.builder
696696
.build_array_alloca(
697697
bin.context.i8_type(),
698-
i32_const!(32 + 32 + 32 + 32 as u64),
698+
i32_const!(32 + 32 + 32 + 32_u64),
699699
"buffer",
700700
)
701701
.unwrap();
@@ -1124,7 +1124,7 @@ impl<'a> TargetRuntime<'a> for StylusTarget {
11241124
.left()
11251125
.unwrap();
11261126

1127-
number.into()
1127+
number
11281128
}
11291129
Expression::Builtin {
11301130
kind: Builtin::ChainId,
@@ -1135,7 +1135,7 @@ impl<'a> TargetRuntime<'a> for StylusTarget {
11351135
.left()
11361136
.unwrap();
11371137

1138-
chainid.into()
1138+
chainid
11391139
}
11401140
Expression::Builtin {
11411141
kind: Builtin::ContractCode,
@@ -1286,7 +1286,7 @@ impl<'a> TargetRuntime<'a> for StylusTarget {
12861286
.left()
12871287
.unwrap();
12881288

1289-
gasleft.into()
1289+
gasleft
12901290
}
12911291
Expression::Builtin {
12921292
kind: Builtin::GasLimit,
@@ -1297,7 +1297,7 @@ impl<'a> TargetRuntime<'a> for StylusTarget {
12971297
.left()
12981298
.unwrap();
12991299

1300-
gaslimit.into()
1300+
gaslimit
13011301
}
13021302
Expression::Builtin {
13031303
kind: Builtin::GetAddress,
@@ -1408,7 +1408,7 @@ impl<'a> TargetRuntime<'a> for StylusTarget {
14081408
.left()
14091409
.unwrap();
14101410

1411-
timestamp.into()
1411+
timestamp
14121412
}
14131413
Expression::Builtin {
14141414
kind: Builtin::Value,

tests/stylus_tests/milestone_2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fn milestone_2() {
7171
assert!(line.contains(r#""topics":["0xa8142743f8f70a4c26f3691cf4ed59718381fb2f18070ec52be1f1022d855557"],"data":"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000""#));
7272
}
7373

74+
#[allow(clippy::format_collect)]
7475
fn label_test_block_output(stdout: &str) -> String {
7576
const LABELS: &[&str] = &[
7677
"gasleft",
@@ -90,6 +91,7 @@ fn label_test_block_output(stdout: &str) -> String {
9091
.collect()
9192
}
9293

94+
#[allow(clippy::format_collect)]
9395
fn label_test_tstore_output(stdout: &str) -> String {
9496
const LABELS: &[&str] = &["sload", "tload"];
9597
let lines = stdout.lines().collect::<Vec<_>>();

tests/stylus_tests/milestone_3.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ fn milestone_3() {
3737
println!("{}", &labeled_stdout);
3838

3939
let balance = get(&labeled_stdout, "balance").unwrap();
40-
assert_eq!(1000, u64::from_str_radix(balance, 10).unwrap());
40+
assert_eq!(1000, balance.parse::<u64>().unwrap());
4141

4242
let codehash = get(&labeled_stdout, "codehash")
43-
.map(|s| s.strip_prefix("0x"))
44-
.flatten()
43+
.and_then(|s| s.strip_prefix("0x"))
4544
.unwrap();
4645

4746
let stdout = call(dir, &address, ["getCode()"]).unwrap();
@@ -59,8 +58,8 @@ fn milestone_3() {
5958
let i = gasprice
6059
.bytes()
6160
.position(|c| c.is_ascii_whitespace())
62-
.unwrap_or_else(|| gasprice.len());
63-
assert_eq!(100000000, u64::from_str_radix(&gasprice[..i], 10).unwrap());
61+
.unwrap_or(gasprice.len());
62+
assert_eq!(100_000_000, gasprice[..i].parse::<u64>().unwrap());
6463

6564
call(dir, &address, ["test_addmod()"]).unwrap();
6665

@@ -73,6 +72,7 @@ fn milestone_3() {
7372
call(dir, &address, ["test_power()"]).unwrap();
7473
}
7574

75+
#[allow(clippy::format_collect)]
7676
fn label(stdout: &str) -> String {
7777
const LABELS: &[&str] = &["balance", "codehash", "manual_codehash", "gasprice"];
7878
let lines = stdout.lines().collect::<Vec<_>>();

tests/stylus_tests/uniswap.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ fn deploy_uniswap_factory(pair_base: &str, pair_creator: &str) -> (TempDir, Stri
222222
(tempdir, address)
223223
}
224224

225+
#[allow(clippy::items_after_statements)]
225226
fn create_pair(dir: impl AsRef<Path>, factory: &str, erc20_a: &str, erc20_b: &str) -> String {
226227
let stdout = send(
227228
dir,
@@ -268,6 +269,6 @@ fn assert_roughly_starts_with(line: &str, prefix: &str) {
268269
"mismatch at index {i}\n
269270
line: {line}
270271
prefix: {prefix}"
271-
)
272+
);
272273
}
273274
}

0 commit comments

Comments
 (0)