Skip to content

Commit a8e1c64

Browse files
committed
rust: remove async-recursion dep
Since Rust 1.77 (https://github.com/rust-lang/rust/blob/ba956ef4b00c91579cff9b2220358ee3a46d982f/RELEASES.md#version-1770-2024-03-21), async recursion is suppoerted out of the box. The example in rust-lang/rust#117703 shows how to use `Box::pin()` to avoid this error message: ``` note: a recursive `async fn` call must introduce indirection such as `Box::pin` to avoid an infinitely sized future ``` This commit reduces the binary size by 1656 bytes.
1 parent 8013ad1 commit a8e1c64

23 files changed

+4
-1056
lines changed

src/rust/Cargo.lock

-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rust/bitbox02-rust/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ minicbor = { version = "0.20.0", default-features = false, features = ["alloc"],
4444
crc = { version = "3.0.1", optional = true }
4545
ed25519-dalek = { version = "2.0.0", default-features = false, features = ["hazmat"], optional = true }
4646
lazy_static = { version = "1.4.0", optional = true }
47-
async-recursion = "1.0.5"
4847
hmac = { version = "0.12.1", default-features = false, features = ["reset"] }
4948

5049
miniscript = { version = "11.0.0", default-features = false, features = ["no-std"], optional = true }

src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -288,25 +288,25 @@ async fn encode_member<U: sha3::digest::Update>(
288288
title_suffix: Option<String>,
289289
) -> Result<(), Error> {
290290
if member_type.r#type == DataType::Struct as _ {
291-
let value_encoded = hash_struct(
291+
let value_encoded = Box::pin(hash_struct(
292292
types,
293293
root_object,
294294
&member_type.struct_name,
295295
path,
296296
formatted_path,
297297
title_suffix,
298-
)
298+
))
299299
.await?;
300300
hasher.update(&value_encoded);
301301
} else if member_type.r#type == DataType::Array as _ {
302-
let encoded_value = hash_array(
302+
let encoded_value = Box::pin(hash_array(
303303
types,
304304
member_type,
305305
root_object,
306306
path,
307307
formatted_path,
308308
title_suffix,
309-
)
309+
))
310310
.await?;
311311
hasher.update(&encoded_value);
312312
} else {
@@ -341,7 +341,6 @@ async fn encode_member<U: sha3::digest::Update>(
341341
Ok(())
342342
}
343343

344-
#[async_recursion::async_recursion(?Send)]
345344
async fn hash_array(
346345
types: &[StructType],
347346
member_type: &MemberType,
@@ -404,7 +403,6 @@ async fn hash_array(
404403
Ok(hasher.finalize().to_vec())
405404
}
406405

407-
#[async_recursion::async_recursion(?Send)]
408406
async fn hash_struct(
409407
types: &[StructType],
410408
root_object: RootObject,

src/rust/vendor/async-recursion/.cargo-checksum.json

-1
This file was deleted.

src/rust/vendor/async-recursion/Cargo.toml

-49
This file was deleted.

src/rust/vendor/async-recursion/LICENSE-APACHE

-201
This file was deleted.

src/rust/vendor/async-recursion/LICENSE-MIT

-23
This file was deleted.

0 commit comments

Comments
 (0)