Skip to content

Update Rust edition to 2024#2049

Open
ImplOfAnImpl wants to merge 3 commits intomasterfrom
update_rust_edition
Open

Update Rust edition to 2024#2049
ImplOfAnImpl wants to merge 3 commits intomasterfrom
update_rust_edition

Conversation

@ImplOfAnImpl
Copy link
Copy Markdown
Contributor

The breaking changes are:

  • gen is a reserved keyword now, so the raw syntax has to be uses instead - r#gen (though after the rand upgrade there are only a few places that had to be changed).
  • Return-position impl Trait now implicitly captures all lifetime parameters, so an explicit use<..> has to be used where it's not what is needed.
  • There were some changes in how the ref keyword can be used. Basically, redundant refs are now disallowed.
  • std::env::{set_var, remove_var} are now unsafe (but note that they were never safe to use in multithreaded environments on *nix, including the case when an env var is set at the start of a tokio::main and a multithreaded runtime is used).
    There were different scenarios where we were using them:
    • To set the default value of RUST_LOG to "info". I removed that, now the default value can be passed to logger initialization functions and if it's not, then "info" will be used by default.
    • To set the default value of RUST_BACKTRACE to "full". For this I added the enable_rust_backtrace macro that must be called at the module scope, so that the env var is set before main or tokio::main is entered. It uses ctor under the hood, so I also upgraded ctor to 0.10.
      Also, backtrace wasn't enabled in api-web-server for some reason, so I enabled it there for consistency.
    • In tests. The potential real unsafety is not a huge deal in tests, but it can cause wrong behavior both in env-modifying tests and ones that read an env var (even if it's a different var) if they're run in parallel.
      I wrapped the functions in non-unsafe ones in test-utils, to avoid writing unsafe every time, and wrote a comment about how to deal with the potential problems. We only have 2 env-modifying tests - in logging and utils, and I turned them into integration tests, to ensure they're not run in parallel with anything else.

Additionally, if let ... can now be chained with other conditions; though not a breaking change, clippy insists that all such calls should be chained, so I indulged.

P.S.

  • In "rustfmt.toml" I added style_edition = "2021" to prevent it from reformatting the code all over the place. I'll remove it and reformat the code in a follow-up PR.
  • Unrelated change: I also did cargo update openssl to address some of the dependabot errors.

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