Skip to content

Commit 2981b15

Browse files
committed
feat!: migrate workspace to Rust edition 2024
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.
1 parent 460f518 commit 2981b15

62 files changed

Lines changed: 810 additions & 249 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 629 additions & 155 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ authors = ["Nautilus Cyberneering <info@nautilus-cyberneering.de>, Mick van Dijk
2323
categories = ["network-programming", "web-programming"]
2424
description = "A BitTorrent Index"
2525
documentation = "https://docs.rs/crate/torrust-tracker/"
26-
edition = "2021"
26+
edition = "2024"
2727
homepage = "https://torrust.com/"
2828
keywords = ["bittorrent", "file-sharing", "index", "peer-to-peer", "torrent"]
2929
license = "AGPL-3.0-only"
3030
publish = true
3131
repository = "https://github.com/torrust/torrust-tracker"
32-
rust-version = "1.83"
33-
version = "3.1.0-develop"
32+
rust-version = "1.85"
33+
version = "4.0.0-develop"
3434

3535
[features]
3636
default = []
@@ -63,7 +63,7 @@ http-body = "1"
6363
hyper = "1"
6464
hyper-util = { version = "0", features = ["http1", "http2", "tokio"] }
6565
indexmap = "2"
66-
jsonwebtoken = "9.3"
66+
jsonwebtoken = { version = "10", features = ["rust_crypto"] }
6767
lettre = { version = "0", features = [
6868
"builder",
6969
"file-transport-envelope",
@@ -76,7 +76,7 @@ log = "0"
7676
mockall = "0"
7777
pbkdf2 = { version = "0", features = ["simple"] }
7878
pin-project-lite = "0"
79-
rand = "0.9"
79+
rand = "0.10"
8080
regex = "1"
8181
reqwest = { version = "0", features = ["json", "multipart", "query"] }
8282
serde = { version = "1", features = ["derive", "rc"] }
@@ -118,7 +118,7 @@ nonstandard-style = { level = "deny", priority = -1 }
118118
rust-2018-compatibility = { level = "deny", priority = -1 }
119119
rust-2018-idioms = { level = "deny", priority = -1 }
120120
rust-2021-compatibility = { level = "deny", priority = -1 }
121-
rust-2024-compatibility = { level = "warn", priority = -1 }
121+
rust-2024-compatibility = { level = "deny", priority = -1 }
122122
unsafe-code = "warn"
123123
unused = { level = "deny", priority = -2 }
124124
warnings = { level = "deny", priority = -1 }

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ The following services are provided by the default configuration:
124124
- [ADR-T-001: Lowercase Infohashes](adr/001-lowercase-infohashes.md) — All infohashes are normalized to lowercase throughout the codebase, database, and API.
125125
- [ADR-T-002: Ignore Non-Standard Fields in Info Dictionary](adr/002-ignore-non-standard-info-fields.md) — Non-standard fields in the torrent info dictionary are ignored to prevent info-hash mismatches.
126126
- [ADR-T-003: Preparing for Rust Edition 2024](adr/003-edition-2024-preparation.md) — Pin dependencies to avoid edition-2024-only crates while the workspace remains on edition 2021; raise MSRV to 1.83.
127+
- [ADR-T-004: Remove `located-error` Package](adr/004-remove-located-error.md) — Replace the `torrust-index-located-error` wrapper with `tracing` for error context.
128+
- [ADR-T-005: Migrate to Rust Edition 2024](adr/005-edition-2024.md) — Migrate the entire workspace to `edition = "2024"` and raise the MSRV to 1.85.
127129

128130
## Contributing
129131

adr/005-edition-2024.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# ADR-T-005: Migrate to Rust Edition 2024
2+
3+
**Status:** Decided
4+
**Date:** 2026-03-23
5+
**Supersedes:** [ADR-T-003](./003-edition-2024-preparation.md)
6+
(preparation / dependency pinning)
7+
8+
## Context
9+
10+
ADR-T-003 raised the MSRV to 1.83 and pinned several transitive
11+
dependencies to avoid edition-2024-only releases while the workspace
12+
remained on edition 2021. That was explicitly described as a
13+
temporary measure — the intention was always to complete the
14+
migration in a follow-up.
15+
16+
Rust edition 2024 was stabilised in rustc 1.85. `cargo fix --edition`
17+
reported only one automatic fix (an `if_let_rescope` rewrite in
18+
`handlers.rs`), confirming that the codebase was already
19+
well-prepared by the 2024-compatibility lint group enabled in
20+
ADR-T-003.
21+
22+
## Decision
23+
24+
**Migrate the entire workspace to `edition = "2024"` and raise
25+
the MSRV to 1.85.**
26+
27+
### Changes
28+
29+
| Setting / File | From | To | Reason |
30+
| ---------------------------------------------- | --------------- | --------------- | ---------------------------------------------------------------------- |
31+
| `workspace.package.version` | `3.1.0-develop` | `4.0.0-develop` | Major bump for edition change |
32+
| `workspace.package.edition` | `"2021"` | `"2024"` | Edition migration |
33+
| `workspace.package.rust-version` | `1.83` | `1.85` | Minimum compiler for edition 2024 |
34+
| `workspace.lints.rust.rust-2024-compatibility` | `warn` | `deny` | Now the active edition; violations must not land |
35+
| `handlers.rs``#[allow(if_let_rescope)]` | present | removed | Lint no longer needed; behaviour is native to edition 2024 |
36+
| `rand` direct dependency | `"0.9"` | `"0.10"` | ADR-T-003 pin no longer needed; edition 2024 satisfies `rand 0.10` |
37+
| `use rand::Rng` (5 files) | `Rng` | `RngExt` | Trait renamed in `rand 0.10` |
38+
| `jsonwebtoken` direct dependency | `"9.3"` | `"10"` | ADR-T-003 pin no longer needed; v10 works with pinned `simple_asn1` |
39+
40+
### Dependency-pin status
41+
42+
Most of the transitive-dependency pins from ADR-T-003 were lifted by
43+
a routine `cargo update` after the edition migration. The MSRV-aware
44+
resolver (active by default in edition 2024) automatically selects
45+
the latest MSRV-compatible version for most crates.
46+
47+
#### Pins lifted (now at latest compatible versions)
48+
49+
`clap`, `clap_builder`, `clap_derive`, `clap_lex`, `globset`,
50+
`ignore`, `image`, `png`, `quickcheck`, `env_logger`, `uuid`,
51+
`base64ct`, `psm`, `tera`, `deranged`, `home`.
52+
53+
#### Pins still required
54+
55+
The `time` family still requires manual pinning because
56+
`simple_asn1 ≥ 0.6.4` demands `time ^0.3.47`, which requires
57+
Rust 1.88. The MSRV-aware resolver cannot satisfy both the
58+
`simple_asn1` version constraint and the MSRV floor, so it falls
59+
back and pulls in the incompatible version.
60+
61+
| Crate | Pinned to | Latest | Reason |
62+
| -------------- | --------- | ------- | --------------------------------------- |
63+
| `simple_asn1` | 0.6.3 | 0.6.4 | 0.6.4 requires `time ^0.3.47` |
64+
| `time` | 0.3.45 | 0.3.47 | 0.3.47 requires Rust 1.88 |
65+
| `time-core` | 0.1.7 | 0.1.8 | 0.1.8 requires Rust 1.88 |
66+
| `time-macros` | 0.2.25 | 0.2.27 | 0.2.27 requires Rust 1.88 |
67+
| `num-conv` | 0.1.0 | 0.2.0 | pulled by `time` |
68+
| `psm` | 0.1.24 | 0.1.30 | 0.1.30 adds `ar_archive_writer` (unstable `let` exprs) |
69+
70+
After `cargo update`, re-pin with:
71+
72+
```sh
73+
cargo update simple_asn1@0.6.4 --precise 0.6.3
74+
cargo update time@0.3.47 --precise 0.3.45
75+
cargo update psm@0.1.30 --precise 0.1.24
76+
```
77+
78+
These pins can be dropped once `time` publishes a Rust-1.85-compatible
79+
release above 0.3.47, or when the workspace MSRV is raised to 1.88+.
80+
81+
## Consequences
82+
83+
- The workspace compiles and passes all tests (`--all-features`,
84+
`--no-default-features`, `--release`, `--doc`) on rustc 1.85+.
85+
- Contributors must use rustc ≥ 1.85.
86+
- Edition-2024 language features (e.g. `gen` keyword reservation,
87+
`unsafe_op_in_unsafe_fn` default, tail-expression temporaries)
88+
are now available throughout the codebase.
89+
- The `rust-2024-compatibility` lint group is promoted to `deny`,
90+
preventing future regressions.

packages/render-text-as-image/examples/test_render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fs;
22

3-
use torrust_index_render_text_as_image::{render_text_to_png, RenderParams, Rgba};
3+
use torrust_index_render_text_as_image::{RenderParams, Rgba, render_text_to_png};
44

55
fn main() {
66
let params = RenderParams {

packages/render-text-as-image/src/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::blend::blend_source_over;
77
use crate::encode::encode_rgba_png;
88
use crate::font::embedded_font;
99
use crate::layout::measure_text;
10-
use crate::types::{RenderError, RenderParams, MAX_TEXT_BYTES};
10+
use crate::types::{MAX_TEXT_BYTES, RenderError, RenderParams};
1111

1212
/// Saturating cast from `f32` to `u32`, clamped to `[0, u32::MAX]`.
1313
fn f32_to_u32_sat(v: f32) -> u32 {

packages/render-text-as-image/src/tests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Crate-level tests for the public API.
22
33
use crate::types::MAX_TEXT_BYTES;
4-
use crate::{render_text_to_png, RenderError, RenderParams, Rgba};
4+
use crate::{RenderError, RenderParams, Rgba, render_text_to_png};
55

66
// --- Rendering tests ---
77

src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use tracing::info;
77
use crate::bootstrap::logging;
88
use crate::cache::image::manager::ImageCacheService;
99
use crate::common::AppData;
10-
use crate::config::validator::Validator;
1110
use crate::config::Configuration;
11+
use crate::config::validator::Validator;
1212
use crate::databases::database;
1313
use crate::services::authentication::{DbUserAuthenticationRepository, JsonWebToken, Service};
1414
use crate::services::authorization::{CasbinConfiguration, CasbinEnforcer};
@@ -21,9 +21,9 @@ use crate::services::torrent::{
2121
use crate::services::user::{self, DbBannedUserList, DbUserProfileRepository, DbUserRepository, Repository};
2222
use crate::services::{about, authorization, proxy, settings, torrent};
2323
use crate::tracker::statistics_importer::StatisticsImporter;
24+
use crate::web::api::Version;
2425
use crate::web::api::server::signals::Halted;
2526
use crate::web::api::server::v1::auth::Authentication;
26-
use crate::web::api::Version;
2727
use crate::{console, mailer, tracker, web};
2828

2929
pub struct Running {

src/bin/parse_torrent.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ fn main() -> io::Result<()> {
1313
let args: Vec<String> = env::args().collect();
1414
if args.len() != 2 {
1515
eprintln!("Usage: cargo run --bin parse_torrent <PATH_TO_TORRENT_FILE>");
16-
eprintln!("Example: cargo run --bin parse_torrent ./tests/fixtures/torrents/MC_GRID.zip-3cd18ff2d3eec881207dcc5ca5a2c3a2a3afe462.torrent");
16+
eprintln!(
17+
"Example: cargo run --bin parse_torrent ./tests/fixtures/torrents/MC_GRID.zip-3cd18ff2d3eec881207dcc5ca5a2c3a2a3afe462.torrent"
18+
);
1719
std::process::exit(1);
1820
}
1921

src/config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use std::sync::Arc;
77

88
use camino::Utf8PathBuf;
99
use derive_more::Display;
10-
use figment::providers::{Env, Format, Serialized, Toml};
1110
use figment::Figment;
11+
use figment::providers::{Env, Format, Serialized, Toml};
1212
use serde::{Deserialize, Serialize};
13-
use serde_with::{serde_as, NoneAsEmptyString};
13+
use serde_with::{NoneAsEmptyString, serde_as};
1414
use thiserror::Error;
1515
use tokio::sync::RwLock;
1616

0 commit comments

Comments
 (0)