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

Tweaks to support Edition 2024 of Rust in future #3530

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

kennykerr
Copy link
Collaborator

@kennykerr kennykerr commented Mar 5, 2025

While the 2024 edition of Rust is out, switching isn't so easy since it also requires bumping the MSRV on all crates. Still, making what changes are possible early on does help with eventual transition and can catch problems and blockers early. So I started testing with 2024 and encountered a few notable thigs:

  • extern blocks must be unsafe, but since this is not compatible with 2021 I have to leave that for now.
  • no_mangle is considered an unsafe attribute, but that is also incompatible with 2021.
  • Unsafe code within unsafe functions must be wrapped in unsafe blocks. Since this is compatible with 2021 I've gone ahead and applied this change.
  • There are some lifetime changes that restrict lifetime promotion particularly for const values. I've gone ahead and fixed those. Notably the h! macro cannot return an HSTRING reference to a const value as Rust thinks the HSTRING is a temporary and will be dropped as the expression returns. Making it static solves this problem by explicitly promoting to static lifetime. This has the downside that the result of h! is no longer const but that's less of an issue than it not living in static memory which is the whole point.

@kennykerr kennykerr merged commit c66decb into master Mar 5, 2025
34 checks passed
@kennykerr kennykerr deleted the edition-2025-prep branch March 5, 2025 19:50
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.

1 participant