Skip to content

chore!: migrate workspace to Rust edition 2024#839

Merged
da2ce7 merged 2 commits intotorrust:developfrom
da2ce7:20260323_chore_edition2024
Mar 23, 2026
Merged

chore!: migrate workspace to Rust edition 2024#839
da2ce7 merged 2 commits intotorrust:developfrom
da2ce7:20260323_chore_edition2024

Conversation

@da2ce7
Copy link
Copy Markdown
Contributor

@da2ce7 da2ce7 commented Mar 23, 2026

Summary

This PR completes two related housekeeping tasks that prepare the codebase for the next major release cycle:

  1. Remove the located-error package — The first-party torrust-index-located-error crate is replaced by direct tracing::error! calls at error-construction sites. Error types in config and web::api::server are simplified from LocatedError<'static, dyn Error + Send + Sync> to plain Arc<dyn Error + Send + Sync> (DynError), eliminating a lifetime parameter and unnecessary Arc indirection. (See ADR-T-004.)

  2. Migrate the entire workspace to Rust edition 2024 — The edition is bumped from 2021 to 2024, the MSRV is raised from 1.83 to 1.85, and the workspace version goes from 3.1.0-develop to 4.0.0-develop. Key dependency upgrades include jsonwebtoken 9.3 → 10, rand 0.9 → 0.10, and the rust-2024-compatibility lint group is promoted from warn to deny. Import ordering across ~55 files is reformatted to edition-2024 style. (See ADR-T-005.)

Breaking Changes

  • MSRV raised to 1.85 — contributors and CI must use rustc 1.85+.
  • Major version bump4.0.0-develop to reflect the edition change and removed package.
  • located-error crate removed — any downstream code depending on torrust-index-located-error must migrate to tracing or plain error types.

Dependency Pin Status

Most transitive pins from ADR-T-003 have been lifted thanks to the MSRV-aware resolver in edition 2024. A handful of pins remain for the time family and psm until their upstream crates support Rust 1.85 (details in ADR-T-005).

Scope

68 files changed, ~920 insertions, ~1120 deletions (net reduction). The bulk of the diff is the deleted located-error package, Cargo.lock churn from dependency upgrades, and mechanical import reordering by cargo fmt.

…text

Replace the first-party `torrust-index-located-error` crate with
direct `tracing::error!` calls at error-construction sites. The
`LocatedError<'static, dyn Error + Send + Sync>` wrapper is replaced
by plain `Arc<dyn Error + Send + Sync>` (`DynError`), eliminating
the lifetime parameter and unnecessary indirection.

- Delete `packages/located-error/` (crate, LICENSE, README)
- Remove workspace member and dependency from `Cargo.toml`
- Simplify error variants in `config::Error` and `web::api::server::Error`
- Emit `tracing::error!` events where `LocatedError` previously logged

See ADR-T-004 for rationale.
Copilot AI review requested due to automatic review settings March 23, 2026 06:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prepares the workspace for the next major release by removing the internal torrust-index-located-error crate (moving error-origin context to tracing) and migrating the entire workspace to Rust edition 2024 (including an MSRV bump and dependency updates).

Changes:

  • Remove the packages/located-error workspace member and replace LocatedError usages with DynError + tracing logging.
  • Migrate workspace to edition = "2024", raise rust-version to 1.85, and bump workspace version to 4.0.0-develop.
  • Update key dependencies (e.g., jsonwebtoken v10, rand v0.10) and apply rustfmt/import reordering and small lint-driven edits.

Reviewed changes

Copilot reviewed 66 out of 68 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/upgrades/from_v1_0_0_to_v2_0_0/upgrader.rs Import reordering for edition-2024 formatting.
tests/upgrades/from_v1_0_0_to_v2_0_0/sqlite_v2_0_0.rs Import reordering.
tests/upgrades/from_v1_0_0_to_v2_0_0/sqlite_v1_0_0.rs Import reordering.
tests/environments/isolated.rs Import reordering.
tests/environments/app_starter.rs Import reordering.
tests/e2e/web/api/v1/contexts/user/contract.rs Import reordering.
tests/e2e/web/api/v1/contexts/torrent/steps.rs Import reordering.
tests/e2e/web/api/v1/contexts/torrent/contract.rs rustfmt-driven test signature formatting change.
tests/e2e/environment.rs Import reordering.
tests/common/random.rs rand API migration (RngRngExt).
tests/common/contexts/user/fixtures.rs rand API migration (RngRngExt).
tests/common/contexts/torrent/fixtures.rs Import reordering.
tests/common/contexts/tag/fixtures.rs rand API migration (RngRngExt).
tests/common/contexts/category/fixtures.rs rand API migration (RngRngExt).
tests/common/client.rs Import reordering.
src/web/api/server/v1/routes.rs Import reordering.
src/web/api/server/v1/responses.rs Import reordering.
src/web/api/server/v1/contexts/user/routes.rs Import reordering.
src/web/api/server/v1/contexts/user/handlers.rs Import reordering.
src/web/api/server/v1/contexts/torrent/routes.rs Import reordering.
src/web/api/server/v1/contexts/torrent/responses.rs Import reordering.
src/web/api/server/v1/contexts/torrent/handlers.rs Remove edition-2024 lint allow + import reordering.
src/web/api/server/v1/contexts/torrent/errors.rs Import reordering + string formatting wrap.
src/web/api/server/v1/contexts/tag/routes.rs Import reordering.
src/web/api/server/v1/contexts/settings/routes.rs Import reordering.
src/web/api/server/v1/contexts/proxy/routes.rs Import reordering.
src/web/api/server/v1/contexts/proxy/responses.rs Import reordering.
src/web/api/server/v1/contexts/category/routes.rs Import reordering.
src/web/api/server/v1/contexts/category/handlers.rs Import reordering.
src/web/api/server/v1/contexts/about/routes.rs Import reordering.
src/web/api/server/v1/contexts/about/handlers.rs Import reordering.
src/web/api/server/mod.rs Replace LocatedError with DynError and log TLS config errors via tracing.
src/web/api/server/custom_axum.rs Import reordering.
src/web/api/client/v1/random.rs rand API migration (RngRngExt).
src/web/api/client/v1/http.rs Import reordering.
src/web/api/client/v1/client.rs Import reordering.
src/utils/parse_torrent.rs Import reordering.
src/upgrades/from_v1_0_0_to_v2_0_0/databases/sqlite_v2_0_0.rs Import reordering.
src/upgrades/from_v1_0_0_to_v2_0_0/databases/sqlite_v1_0_0.rs Import reordering.
src/ui/proxy.rs Import reordering.
src/tests/services/settings.rs Import reordering.
src/tests/models/user.rs Import reordering.
src/tests/config/mod.rs Import reordering within tests.
src/tests/cache/bytes_cache.rs rustfmt-driven test signature formatting change.
src/services/user.rs Dependency import reordering + small formatting changes.
src/services/torrent.rs Import reordering.
src/services/authentication.rs Dependency import reordering for jsonwebtoken v10.
src/mailer.rs Dependency import reordering for jsonwebtoken v10 + minor import reorder.
src/lib.rs Small formatting change (condensed if expression).
src/databases/sqlite.rs Import reordering.
src/databases/mysql.rs Import reordering.
src/console/cronjobs/tracker_statistics_importer.rs Import reordering.
src/config/v2/mod.rs Import reordering.
src/config/mod.rs Replace LocatedError with DynError and add tracing logging in conversion.
src/bin/parse_torrent.rs rustfmt wrapping of long eprintln!.
src/app.rs Import reordering.
README.md Add links to ADR-T-004 and ADR-T-005.
packages/render-text-as-image/src/tests/mod.rs Import reordering.
packages/render-text-as-image/src/render.rs Import reordering.
packages/render-text-as-image/examples/test_render.rs Import reordering.
packages/located-error/src/lib.rs Deleted crate source (workspace member removed).
packages/located-error/README.md Deleted crate README.
packages/located-error/LICENSE Deleted crate license file.
packages/located-error/Cargo.toml Deleted crate manifest.
Cargo.toml Remove workspace member + bump edition/MSRV/version + dependency updates + stricter 2024 compatibility lints.
Cargo.lock Lockfile churn from dependency and edition/MSRV updates.
adr/004-remove-located-error.md New ADR documenting removal of located-error crate.
adr/005-edition-2024.md New ADR documenting edition-2024 migration and remaining dependency pins.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.20%. Comparing base (3b9b5ac) to head (ed58e78).
⚠️ Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
src/web/api/server/mod.rs 0.00% 8 Missing ⚠️
src/config/mod.rs 0.00% 2 Missing ⚠️
src/bin/parse_torrent.rs 0.00% 1 Missing ⚠️
src/lib.rs 0.00% 1 Missing ⚠️
src/services/user.rs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #839      +/-   ##
===========================================
+ Coverage    52.18%   52.20%   +0.02%     
===========================================
  Files          117      116       -1     
  Lines         6205     6166      -39     
  Branches      6205     6166      -39     
===========================================
- Hits          3238     3219      -19     
+ Misses        2887     2866      -21     
- Partials        80       81       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

BREAKING CHANGE: MSRV raised from 1.83 to 1.85; workspace version
bumped from 3.1.0-develop to 4.0.0-develop.

Edition migration
-----------------
- Set `edition = "2024"` workspace-wide.
- Raise `rust-version` to 1.85.
- Promote `rust-2024-compatibility` lint group from `warn` to `deny`.
- Remove `#[allow(if_let_rescope)]` in torrent handlers (native in
  edition 2024).
- Relax `located-error` doctest assertion from `"lib.rs"` to `".rs"`
  to accommodate edition 2024 merged-doctest bundling.
- Apply `cargo fmt` import reordering (edition 2024 style) across
  ~55 files.

Dependency upgrades
-------------------
- `jsonwebtoken`: 9.3 → 10 (with `rust_crypto` feature).
- `rand`: 0.9 → 0.10; rename `use rand::Rng` to `use rand::RngExt`
  in 5 files.

Cargo.lock pins still required for MSRV 1.85
---------------------------------------------
- `simple_asn1` 0.6.3 (0.6.4 requires `time ^0.3.47`)
- `time` 0.3.45, `time-core` 0.1.7, `time-macros` 0.2.25, `num-conv`
  0.1.0 (0.3.47+ requires Rust 1.88)
- `psm` 0.1.24 (0.1.30 pulls `ar_archive_writer` with unstable
  `let` expressions)

See ADR-T-004 for full rationale and pin-maintenance instructions.
@da2ce7 da2ce7 force-pushed the 20260323_chore_edition2024 branch from 2981b15 to ed58e78 Compare March 23, 2026 07:05
@da2ce7
Copy link
Copy Markdown
Contributor Author

da2ce7 commented Mar 23, 2026

ACK ed58e78

@da2ce7 da2ce7 merged commit 6749e87 into torrust:develop Mar 23, 2026
17 of 18 checks passed
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.

2 participants