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

frb incompatible with Rust 2024 edition #2491

Open
anlumo opened this issue Jan 9, 2025 · 5 comments
Open

frb incompatible with Rust 2024 edition #2491

anlumo opened this issue Jan 9, 2025 · 5 comments
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working

Comments

@anlumo
Copy link
Contributor

anlumo commented Jan 9, 2025

Describe the bug

In Rust 2024 edition, the deprecated #[no_mangle] attribute is now a hard error. frb's code generator still generates it though.

error: unsafe attribute used without unsafe
    --> myproj\src\frb_generated.rs:2902:7
     |
2902 |     #[no_mangle]
     |       ^^^^^^^^^ usage of unsafe attribute
     |
help: wrap the attribute in `unsafe(...)`
     |
2902 |     #[unsafe(no_mangle)]
     |       +++++++         +

You can read more about it here.

@anlumo anlumo added the bug Something isn't working label Jan 9, 2025
@fzyzcjy
Copy link
Owner

fzyzcjy commented Jan 9, 2025

Good point! The simplest way may be add a flag (e.g. "rust_edition: 2024") and generate different things according to this. A slightly more fancy way is to utilize the existing infrastructure that parses the Cargo.toml, and check what is the current edition, and do different things based on it.

Feel free to PR! Alternatively I may work on it in the next batch. The workaround is to simply not upgrade to Rust 2024 edition now.

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Jan 9, 2025
@anlumo
Copy link
Contributor Author

anlumo commented Jan 9, 2025

It's already accepted by rustc 1.82, it doesn't need the 2024 edition specifically. I don't know if it would be ok to just define 1.82 as the minimum compiler version for frb.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jan 9, 2025

Hmm, but it seems to complain frb's generated code. Thus, it is the user's Cargo.toml that handles this.

@anlumo
Copy link
Contributor Author

anlumo commented Jan 9, 2025

Yes, so a project that uses Rust 2024 can't use frb at the moment.

If you would just change the generated code, it's still work on older editions, but would need a compiler 1.82 or later.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jan 9, 2025

If you would just change the generated code, it's still work on older editions, but would need a compiler 1.82 or later.

Oh I see! Hmm 1.82 looks quite recent, but maybe we can do that, and if someone has strong reason to be on <1.82 he/she can either use older version of frb, or create an issue and we can do the "create a flag" thing above.

Feel free to PR since it seems not very hard :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants