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 Edition 2024 #374

Open
DrewRidley opened this issue Feb 25, 2025 · 5 comments
Open

Rust Edition 2024 #374

DrewRidley opened this issue Feb 25, 2025 · 5 comments

Comments

@DrewRidley
Copy link

DrewRidley commented Feb 25, 2025

Hey all, super excited about the work you are doing for the future of wasm!

As of recently, I think a few days ago, Edition 2024 was officially released in Rust, and it seems like one of the biggest breaking changes made was the requirement of unsafe attributes for #[no_mangle] and #[link_section]

error: unsafe attribute used without unsafe
   --> src/bindings.rs:120:3
    |
120 | #[link_section = "component-type:wit-bindgen:0.36.0:example:compone...
    |   ^^^^^^^^^^^^ usage of unsafe attribute
    |
help: wrap the attribute in `unsafe(...)`
    |
120 | #[unsafe(link_section = "component-type:wit-bindgen:0.36.0:example:component:example:encoded world")]
    |   +++++++                             

Unfortunately as of late, the example code provided does not compile. Fortunately its a very easy fix (https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-attributes.html).

Let me know if I can help by getting a PR rolling to accommodate this change.

@yoshuawuyts
Copy link
Member

@DrewRidley that would be great actually, thank you!

@djoyce-ts
Copy link

Just bit me too. :)

@DrewRidley
Copy link
Author

bytecodealliance/wit-bindgen#1119

It appears this issue was fixed a month ago upstream, its just has to be incorporated in cargo-component's next release.
I will close this issue as it seems all the work was already done!

@yoshuawuyts
Copy link
Member

yoshuawuyts commented Feb 28, 2025

Ah shoot, I thought this might be the same failure that was causing #372 (comment). It seems something else related might be happening that needs digging into. E.g. we're still seeing this error in CI:

│   warning[E0133]: call to unsafe function `bindings::_export_hello_world_cabi` is unsafe and requires unsafe block
│     --> src/bindings.rs:33:43
│      |
│   33 |         _export_hello_world_cabi::<$ty > () } #[unsafe (export_name =
│      |                                           ^ call to unsafe function
│      |
│     ::: src/lib.rs:15:1
│      |
│   15 | bindings::export!(Component with_types_in bindings);
│      | --------------------------------------------------- in this macro invocation
│      |
│      = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html>
│      = note: consult the function's documentation for information on how to avoid undefined behavior
│   note: an unsafe function restricts its caller, but its body is safe by default

@yoshuawuyts
Copy link
Member

Filed bytecodealliance/wit-bindgen#1183 which I believe should fix this

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

3 participants