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

Rust: unused_unsafe in generated code #752

Closed
morenol opened this issue Nov 9, 2023 · 7 comments
Closed

Rust: unused_unsafe in generated code #752

morenol opened this issue Nov 9, 2023 · 7 comments

Comments

@morenol
Copy link
Contributor

morenol commented Nov 9, 2023

I got this clippy failure on generated code

2751 |                       unsafe {
     |                       ^^^^^^ unnecessary `unsafe` block
@peterhuene peterhuene transferred this issue from bytecodealliance/cargo-component Nov 9, 2023
@peterhuene peterhuene changed the title unused_unsafe in generated code Rust: unused_unsafe in generated code Nov 9, 2023
@peterhuene
Copy link
Member

The warning is a result of the Rust code generation from wit-bindgen-rust, so I've transferred the issue here.

@morenol
Copy link
Contributor Author

morenol commented Nov 9, 2023

thanks @peterhuene

@peterhuene
Copy link
Member

I may have already fixed this with 560cf56, but cargo-component hasn't yet updated its dependencies to include the fix.

Do you happen to have a repro case so that I can ensure that updating dependencies to include the fix will also address your issue?

@morenol
Copy link
Contributor Author

morenol commented Nov 9, 2023

package my-org:service

interface my-service {
    terminate: func(input: string)
}

world service-guest {
  import my-service
  export run: func(config: string)
}
// src/lib.rs
cargo_component_bindings::generate!();

use bindings::Guest;

pub struct Component;

impl Guest for Component {
    fn run(_config: String) {
        todo!()
    }
}

@peterhuene
Copy link
Member

I've confirmed that this is fixed by the above commit; the next release of cargo-component should prevent the unused unsafe warning.

@peterhuene
Copy link
Member

I'm going to close the issue as fixed, but if for some reason you still encounter the warning after the next cargo-component release (should be immediately following Wasmtime 15), please reactive and let us know. Thanks for reporting this!

@peterhuene
Copy link
Member

Also, I'll put up a cargo-component PR in just a few minutes to get the deps updated in main so that if you build cargo-component from source it'll have the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants