chore: Bump Rust edition to 2024#1265
Draft
szokeasaurusrex wants to merge 10 commits into
Draft
Conversation
Edition 2024 pairs with Cargo resolver 3, which was suggested as a way to keep dependency resolution aligned with the workspace MSRV. MSRV is already 1.88, so only the edition/resolver change is needed. Also wrap `std::env::set_var` call sites in `unsafe` (now required) and apply rustfmt's edition-2024 import sorting. Closes #971 Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
Closes [#971](#971) Closes [RUST-137](https://linear.app/getsentry/issue/RUST-137/bump-rust-edition-to-2024) Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
Stable clippy (1.97) treats nested `if`/`if let` as `collapsible_if` and suggests `if … && let` chains, which edition 2024 enables. Related to [#971](#971) Related to [RUST-137](https://linear.app/getsentry/issue/RUST-137/bump-rust-edition-to-2024) Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
`set_var` is unsafe because concurrent environment access is UB on many platforms. Wrapping the old call sites in `unsafe` did not establish that precondition (and the actix example even started a multi-threaded runtime afterward). Remove process-environment mutation from examples/docs/tests, require `RUST_BACKTRACE=1` to already be set for anyhow backtrace tests (CI now provides it), and drop the changelog entry for this work. Related to [#971](#971) Related to [RUST-137](https://linear.app/getsentry/issue/RUST-137/bump-rust-edition-to-2024) Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
Document that actix examples expect `RUST_BACKTRACE=1` in the process environment for full backtraces, and why they avoid `std::env::set_var`. Use `temp-env` in unit tests so `SENTRY_ENVIRONMENT` / `RUST_BACKTRACE` are set for the cases that need them, with serialized access across concurrent tests. Related to [#971](#971) Related to [RUST-137](https://linear.app/getsentry/issue/RUST-137/bump-rust-edition-to-2024) Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
Related to [#971](#971) Related to [RUST-137](https://linear.app/getsentry/issue/RUST-137/bump-rust-edition-to-2024) Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
Related to [#971](#971) Related to [RUST-137](https://linear.app/getsentry/issue/RUST-137/bump-rust-edition-to-2024) Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
Set `SENTRY_ENVIRONMENT` / `RUST_BACKTRACE` via `Command::env` in a re-exec'd test child instead of pulling in `temp-env`. Related to [#971](#971) Related to [RUST-137](https://linear.app/getsentry/issue/RUST-137/bump-rust-edition-to-2024) Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
Controlling process environment from `cargo test` is not straightforward after `set_var` became unsafe: in-process mutation is unsound with concurrent env access, and child-process re-exec harnesses are awkward. Keep only assertions that do not need a crafted environment. Related to [#971](#971) Related to [RUST-137](https://linear.app/getsentry/issue/RUST-137/bump-rust-edition-to-2024) Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
CI already sets `RUST_BACKTRACE=1`, so this coverage does not need in-process environment mutation. Related to [#971](#971) Related to [RUST-137](https://linear.app/getsentry/issue/RUST-137/bump-rust-edition-to-2024) Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Bump the workspace Rust edition from 2021 to 2024 (and Cargo resolver from 2 to 3), as suggested in #970 / #971.
MSRV is already 1.88, so no toolchain bump is required for edition 2024.
Follow-up fixes from the edition change:
if/if letintoif … && letchains so stable clippy’scollapsible_iflint stays cleanset_varhere); keep only env-independent assertionsRUST_BACKTRACE=1for full backtracesIssues