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

[wit-bindgen-rust] Fix 2024 edition compat #1183

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yoshuawuyts
Copy link
Member

@yoshuawuyts yoshuawuyts commented Mar 1, 2025

I believe this should fix the failing CI in bytecodealliance/cargo-component#372, triggered by the new edition. I'm not entirely sure why the tests seem to be opting into a new edition, but I guess they do? Regardless: this changes the codegen of wit-bindgen-rust to respect the new "unsafe fn does not imply unsafe {}" rule added in the 2024 edition.

This PR is best reviewed commit by commit. The first commit is just the output of cargo fix --edition. The second commit are the actual unsafe changes. (edit: and the third commit reverts the 2024 edition style changes to make CI pass).

Thanks!

@yoshuawuyts yoshuawuyts changed the title Wit bindgen rust 2024 compat [wit-bindgen-rust] Fix 2024 edition compat Mar 1, 2025
@alexcrichton
Copy link
Member

Would you be up for adding a test for this? For example leaving the wit-bindgen crate itself as edition 2021 but changing the generated output to be compatible with 2024. I'd ideally like to change r#gen to generator since raw idents aren't the actual fix to have here (just the quick fix) down the road, and I'd also like to double-check that the generated output is indeed compatible with 2024 since IIRC we also need to do unsafe extern "C" { .. } I think?

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

Successfully merging this pull request may close these issues.

2 participants