Tweaks to support Edition 2024 of Rust in future #3530
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
externblocks must beunsafe, but since this is not compatible with 2021 I have to leave that for now.no_mangleis considered an unsafe attribute, but that is also incompatible with 2021.unsafefunctions must be wrapped inunsafeblocks. Since this is compatible with 2021 I've gone ahead and applied this change.constvalues. I've gone ahead and fixed those. Notably theh!macro cannot return anHSTRINGreference to aconstvalue as Rust thinks theHSTRINGis a temporary and will be dropped as the expression returns. Making itstaticsolves this problem by explicitly promoting tostaticlifetime. This has the downside that the result ofh!is no longerconstbut that's less of an issue than it not living in static memory which is the whole point.