Skip to content

chore: update edition to 2024 in most crates#3371

Merged
gilcu3 merged 2 commits into
mainfrom
1035-define-rust-edition-in-cargo-workspace-once
May 27, 2026
Merged

chore: update edition to 2024 in most crates#3371
gilcu3 merged 2 commits into
mainfrom
1035-define-rust-edition-in-cargo-workspace-once

Conversation

@gilcu3

@gilcu3 gilcu3 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Closes #1035

This looks huge, but it includes only mechanical changes triggered by clippy and rustfmt (mostly this actually)

The only remaining exception is tracked in #3369

@gilcu3 gilcu3 linked an issue May 27, 2026 that may be closed by this pull request
@gilcu3 gilcu3 force-pushed the 1035-define-rust-edition-in-cargo-workspace-once branch from a9fdcda to 0f8d211 Compare May 27, 2026 07:28
Comment thread Cargo.lock

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I sneaked a minor bump of dstack-sdk to fix https://github.com/near/mpc/security/dependabot/72

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... sneaky!

@gilcu3 gilcu3 force-pushed the 1035-define-rust-edition-in-cargo-workspace-once branch from 0f8d211 to 958b01c Compare May 27, 2026 07:33
@gilcu3 gilcu3 marked this pull request as ready for review May 27, 2026 07:35
@claude

claude Bot commented May 27, 2026

Copy link
Copy Markdown

Pull request overview

Migrates most workspace crates from Rust edition 2021 to 2024. The diff is large but the changes are mechanical — driven by rustfmt and clippy under the new edition. threshold-signatures is intentionally kept at 2021 with a TODO(#3369) comment, since it needs precise-capturing use<> work across its public API. The author also slipped in a dstack-sdk bump (0.1.20.1.3) for security advisory dependabot/72, which is already called out in the inline thread.

Changes:

  • Cargo.toml workspace edition = "2024", every crate (except threshold-signatures) switched to inherit it
  • Import reorderings throughout to match the new rustfmt ordering
  • Nested if let { if cond } collapsed into let-chains (if let … && cond)
  • Rng::genRng::r#gen (gen is reserved in 2024)
  • impl Trait returns annotated with + use<...> for precise capturing (db.rs, p2p.rs, sign_utils.rs)
  • Explicit AutoAbortTask<()> annotations where 2024 inference no longer figures it out (indexer/fake.rs)
  • Cargo.lock regenerated; includes the intentional dstack-sdk bump plus a few transitive resolutions (e.g. windows-sys, socket2) and dropped reqwest deps (hickory-resolver, once_cell) — all pulled in by the new dstack-sdk

Reviewed changes

Per-file summary (high-traffic files)
File Description
Cargo.lock dstack-sdk bumped 0.1.2 → 0.1.3 (security fix), plus transitive shuffles
Cargo.toml (root) edition = "2024" in [workspace.package]
crates/*/Cargo.toml edition = "2021"edition = { workspace = true } except threshold-signatures
crates/threshold-signatures/Cargo.toml Pinned to 2021 with TODO referencing #3369
crates/contract/src/lib.rs Import re-sort, let-chain consolidation, test-only testing_env!(...) re-indenting
crates/contract/src/errors.rs thiserror #[error(...)] strings split across lines for long messages
crates/contract/src/foreign_chain_rpc.rs Two nested if let { if cond } → let-chain
crates/contract/src/tee/{proposal,tee_state}.rs Mechanical reformat; one let-chain in tee_state.rs::insert_or_replace_attestation
crates/node/src/p2p.rs Let-chains in close-notify handling; impl Trait + use<> on new_tls_mesh_network; r#gen in tests
crates/node/src/indexer/handler.rs Two nested-if-let blocks collapsed into let-chains in handle_message
crates/node/src/indexer/fake.rs AutoAbortTask<()> annotations added to several tokio::spawn results
crates/node/src/keyshare*.rs Multiple if let { if cond } → let-chain
crates/node/src/assets.rs if let Some(Ok(...)) else { break } rewritten as match { _ => break }
crates/node/src/db.rs impl Iterator … + '_… + '_ + use<'_> on SecretDB::iter
crates/node/src/network.rs One let-chain; trailing-; after return Ok(Some(...)); long test-fn signature split
crates/node/src/tests/*.rs Pure reformat of multi-line assert!(...)/testing_env!(...) expressions
crates/devnet/src/*.rs Import re-sort, multi-line println!/panic! reformat

Findings

I went through the substantive files (crates/contract/src/lib.rs, errors.rs, foreign_chain_rpc.rs, tee/{proposal,tee_state}.rs, crates/node/src/{p2p,coordinator,network,db,assets,config,keyshare*,indexer/{handler,fake}}.rs, the heavily-rewritten test files, and the devnet helpers). Every change I looked at is a structural rewrite that preserves behavior:

  • All if let { if … }if let … && … rewrites preserve the original short-circuit semantics, including the ones in receipt classification (indexer/handler.rs), keyshare guards (keyshare.rs), refund logic (contract/src/lib.rs::checked_sub blocks), TLS close-notify (p2p.rs), and attestation overwrite check (tee/tee_state.rs::insert_or_replace_attestation).
  • The if let { if cond } else { … }match { _ => break } rewrite in assets.rs::process_hot_queue is behavior-equivalent (the original else branch only fired on None or Some(Err(_)), which is exactly what the new _ arm matches).
  • Rng::genRng::r#gen is purely a raw-identifier rename — gen is a reserved keyword in 2024.
  • + use<> and + use<'_> annotations on impl Trait returns are required because 2024 changes default lifetime capture for opaque return types — these annotations preserve the old behavior (no extra captures), which is what we want.
  • AutoAbortTask<()> annotations in indexer/fake.rs are necessary because 2024 inference can no longer pin down the Output type through AutoAbortTask::from(tokio::spawn(async move { … })) when the closure is used; no behavior change.

Blocking: none.

Non-blocking (nits / follow-ups):

  • `Cargo.lock:1` — Already discussed: the `dstack-sdk` bump is unrelated to the edition migration. It's fine as called out, but consider splitting unrelated security bumps from large mechanical migrations in the future so they're easier to revert independently.
  • `crates/threshold-signatures/Cargo.toml:6` — The pinned 2021 edition is appropriately marked with a TODO referencing Migrate threshold-signatures crate to Rust edition 2024 #3369. No action needed in this PR.
  • `crates/node/src/db.rs:131` — `+ '_ + use<'>` is redundant: `use<'>` already captures the lifetime; the `+ '_` bound is now subsumed. Not wrong, just noisy. (Same pattern is fine elsewhere — kept consistent.)

✅ Approved

@gilcu3 gilcu3 force-pushed the 1035-define-rust-edition-in-cargo-workspace-once branch from 958b01c to 9c26730 Compare May 27, 2026 07:47

@netrome netrome left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I skimmed this quickly. I assume there are no functional changes.

Comment thread Cargo.lock

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... sneaky!

@anodar anodar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some dependency downgrades (probably fine though):

  • darling 0.21.3 → 0.20.11, windows-sys 0.61.2 → 0.59.0, socket2 0.6.3 → 0.5.10

@gilcu3

gilcu3 commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

There are some dependency downgrades (probably fine though):

  • darling 0.21.3 → 0.20.11, windows-sys 0.61.2 → 0.59.0, socket2 0.6.3 → 0.5.10

yep, this is normal. When a dep is updated (the one I sneaked in) cargo resolves the tree, and it seems that when there are many possibilities for acceptable crates, the ones selected are not stable (i.e. can change due to unrelated changes)

@gilcu3 gilcu3 added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit c9bd55b May 27, 2026
14 checks passed
@gilcu3 gilcu3 deleted the 1035-define-rust-edition-in-cargo-workspace-once branch May 27, 2026 09:23
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.

Define Rust edition in cargo workspace once

3 participants