Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix type annotations #1050

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

fakedev9999
Copy link
Contributor

Issue

The original code attempted to convert a byte slice to B256 using:

let hash: B256 = hint.data[..32].as_ref().try_into()?;

However, this resulted in the following error due to missing type inference when I ran cargo clippy --all-features --all-targets -- -D warnings -A incomplete-features in op-succinct repo:

error[E0282]: type annotations needed
   --> /Users/fakedev9999/.cargo/git/checkouts/kona-eb08956031b8bea7/cef9b87/bin/host/src/interop/handler.rs:300:50
    |
300 |                 let hash: B256 = hint.data[..32].as_ref().try_into()?;
    |                                                  ^^^^^^   -------- type must be known at this point
    |
help: try using a fully qualified path to specify the expected types
    |
300 |                 let hash: B256 = <[u8] as AsRef<T>>::as_ref(&hint.data[..32]).try_into()?;
    |                                  ++++++++++++++++++++++++++++               ~

For more information about this error, try `rustc --explain E0282`.
error: could not compile `kona-host` (lib) due to 1 previous error

Fix

Replaced the failing conversion with:

let hash: B256 = B256::from_slice(&hint.data[0..32]);

This explicitly converts the first 32 bytes of hint.data into B256, resolving the type inference issue and making the conversion unambiguous.

Impact

No functional changes beyond resolving the compilation issue

@clabby clabby merged commit 62d3e61 into op-rs:main Feb 14, 2025
10 of 14 checks passed
@fakedev9999 fakedev9999 deleted the taehoon/fix-type-annotations branch February 15, 2025 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants