Skip to content

Upgrade to compatibility with rust edition 2024 #200

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pchickey
Copy link
Contributor

@pchickey pchickey commented Aug 20, 2025

Proposed changes

We can't actually upgrade to edition 2024, because the MSRV is currently stuck on 1.81 for LTS linux packaging, and 2024 shipped in 1.85. But, in order to have a consistent set of rules (especially around unsafe) to follow across Rust projects with a newer MSRV, make this source tree forwards-compatible to 2024.

Automatically make changes to source of all crates using cargo fix --edition --all, then all of the manual fixes required after that.

Add workspace level lints for rust-2024-compatibility, allowing the expr fragment specifier case which I don't expect to matter and is unstable when building with 1.81

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have written my commit messages in the Conventional Commits format.
  • I have read the CONTRIBUTING doc
  • I have added tests (when possible) that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

@pchickey pchickey force-pushed the pch/edition_2024 branch 2 times, most recently from 3052f83 to e482ef9 Compare August 20, 2025 19:15
@thresheek
Copy link
Member

Does that effectively bump nginx-acme (future releases) Rust toolchain requirement to 1.85.0?

@pchickey
Copy link
Contributor Author

pchickey commented Aug 20, 2025

Yes, it would. Is that a problem?

We don't have to land this now - it could wait, or we could make a separate CI build that modifies it to 2024 and then runs checks while actually keeping it at 2021 - but remembering there are different edition rules across related projects is a mental overhead I'm trying to resolve.

@bavshin-f5
Copy link
Member

Yes, it would. Is that a problem?

We want to support Rust toolchains avaliable in RHEL, Alpine and Ubuntu LTS, to allow building distribution packages of ngx-rust based modules. Currently, that limits us to 1.82.0.

@pchickey
Copy link
Contributor Author

pchickey commented Aug 20, 2025

OK: I will remove the upgrade of edition and msrv, I will switch this to lint that the libraries are compatible with the 2024 edition, which keeps the upgrade delta pretty small.

@pchickey pchickey force-pushed the pch/edition_2024 branch 3 times, most recently from 20b75fc to 3896684 Compare August 20, 2025 20:52
@pchickey pchickey changed the title Upgrade to rust edition 2024 Upgrade for compatiblity with rust edition 2024 Aug 20, 2025
@pchickey pchickey force-pushed the pch/edition_2024 branch 3 times, most recently from 1688760 to 737e368 Compare August 20, 2025 21:17
@pchickey pchickey marked this pull request as ready for review August 20, 2025 21:20
@pchickey pchickey changed the title Upgrade for compatiblity with rust edition 2024 Upgrade to compatibility with rust edition 2024 Aug 20, 2025
@pchickey pchickey force-pushed the pch/edition_2024 branch 2 times, most recently from 254a706 to cd1940f Compare August 20, 2025 23:27
enforced by workspace level lints, now specified in each Cargo.toml,
except nginx-sys, because bindgen can't be set to Edition2024 until MSRV
hits 1.85

this change set is created automatically by `cargo fix --edition --all`,
then with manual fixes afterwards:

* Back out any use of unsafe(no_mangle) for plain no_mangle, since 1.81
  wont accept it
* remove uses of expr_2021 in macros, which is not available in the
  MSRV.
* Manual fix to ngx_container_of! macro for safety rules in 2024,
  these weren't migrated automatically by `cargo fix`
* Manual fixes to several other macros that created an &mut Request in an
  expression, Rust 2024 is stricter about taking &mut of temporaries, so
  instead the request is let-bound first.
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.

3 participants