Skip to content

Commit

Permalink
rust: remove async-recursion dep
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
benma committed May 13, 2024
1 parent af6863b commit cf4d896
Show file tree
Hide file tree
Showing 23 changed files with 4 additions and 1,056 deletions.
12 changes: 0 additions & 12 deletions src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/rust/bitbox02-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 44,6 @@ minicbor = { version = "0.20.0", default-features = false, features = ["alloc"],
crc = { version = "3.0.1", optional = true }
ed25519-dalek = { version = "2.0.0", default-features = false, features = ["hazmat"], optional = true }
lazy_static = { version = "1.4.0", optional = true }
async-recursion = "1.0.5"
hmac = { version = "0.12.1", default-features = false, features = ["reset"] }

miniscript = { version = "11.0.0", default-features = false, features = ["no-std"], optional = true }
Expand Down
10 changes: 4 additions & 6 deletions src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,25 288,25 @@ async fn encode_member<U: sha3::digest::Update>(
title_suffix: Option<String>,
) -> Result<(), Error> {
if member_type.r#type == DataType::Struct as _ {
let value_encoded = hash_struct(
let value_encoded = Box::pin(hash_struct(
types,
root_object,
&member_type.struct_name,
path,
formatted_path,
title_suffix,
)
))
.await?;
hasher.update(&value_encoded);
} else if member_type.r#type == DataType::Array as _ {
let encoded_value = hash_array(
let encoded_value = Box::pin(hash_array(
types,
member_type,
root_object,
path,
formatted_path,
title_suffix,
)
))
.await?;
hasher.update(&encoded_value);
} else {
Expand Down Expand Up @@ -341,7 341,6 @@ async fn encode_member<U: sha3::digest::Update>(
Ok(())
}

#[async_recursion::async_recursion(?Send)]
async fn hash_array(
types: &[StructType],
member_type: &MemberType,
Expand Down Expand Up @@ -404,7 403,6 @@ async fn hash_array(
Ok(hasher.finalize().to_vec())
}

#[async_recursion::async_recursion(?Send)]
async fn hash_struct(
types: &[StructType],
root_object: RootObject,
Expand Down
1 change: 0 additions & 1 deletion src/rust/vendor/async-recursion/.cargo-checksum.json

This file was deleted.

49 changes: 0 additions & 49 deletions src/rust/vendor/async-recursion/Cargo.toml

This file was deleted.

201 changes: 0 additions & 201 deletions src/rust/vendor/async-recursion/LICENSE-APACHE

This file was deleted.

23 changes: 0 additions & 23 deletions src/rust/vendor/async-recursion/LICENSE-MIT

This file was deleted.

Loading

0 comments on commit cf4d896

Please sign in to comment.