Skip to content

Commit a6d8b17

Browse files
committed
feat!: migrate workspace to Rust edition 2024 (ADR-T-004)
BREAKING CHANGE: MSRV raised from 1.83 to 1.85; version bumped to 4.0.0-develop. - Set `edition = "2024"` and `rust-version = "1.85"` workspace-wide - Promote `rust-2024-compatibility` lint group from warn to deny - Remove `#[allow(if_let_rescope)]` in download handler (native in 2024) - Relax located-error doctest assertion for merged-doctest bundling - Add ADR-T-004 documenting the migration (supersedes ADR-T-003)
1 parent 3b9b5ac commit a6d8b17

5 files changed

Lines changed: 64 additions & 10 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 5 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 = []
@@ -39,7 +39,7 @@ default = []
3939
opt-level = 3
4040

4141
[dependencies]
42-
torrust-index-located-error = { version = "3.1.0-develop", path = "packages/located-error" }
42+
torrust-index-located-error = { version = "4.0.0-develop", path = "packages/located-error" }
4343
torrust-index-render-text-as-image = { version = "0.1.0", path = "packages/render-text-as-image" }
4444

4545
anyhow = "1"
@@ -119,7 +119,7 @@ nonstandard-style = { level = "deny", priority = -1 }
119119
rust-2018-compatibility = { level = "deny", priority = -1 }
120120
rust-2018-idioms = { level = "deny", priority = -1 }
121121
rust-2021-compatibility = { level = "deny", priority = -1 }
122-
rust-2024-compatibility = { level = "warn", priority = -1 }
122+
rust-2024-compatibility = { level = "deny", priority = -1 }
123123
unsafe-code = "warn"
124124
unused = { level = "deny", priority = -2 }
125125
warnings = { level = "deny", priority = -1 }

adr/004-edition-2024.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# ADR-T-004: 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+
| `located-error` doctest assertion | `"lib.rs"` | `".rs"` | Edition 2024 merged-doctest bundling changes `Location::caller()` path |
37+
38+
### Dependency-pin status
39+
40+
The transitive-dependency pins from ADR-T-003 remain in `Cargo.lock`
41+
for now. They can be lifted opportunistically: once those upstream
42+
crates publish releases that no longer conflict with the rest of the
43+
dependency tree, a routine `cargo update` will pick them up. No
44+
further manual pinning is required.
45+
46+
## Consequences
47+
48+
- The workspace compiles and passes all tests (`--all-features`,
49+
`--no-default-features`, `--release`, `--doc`) on rustc 1.85+.
50+
- Contributors must use rustc ≥ 1.85.
51+
- Edition-2024 language features (e.g. `gen` keyword reservation,
52+
`unsafe_op_in_unsafe_fn` default, tail-expression temporaries)
53+
are now available throughout the codebase.
54+
- The `rust-2024-compatibility` lint group is promoted to `deny`,
55+
preventing future regressions.

packages/located-error/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! let l = get_caller_location();
2525
//!
2626
//! assert!(b.to_string().contains("Test, "));
27-
//! assert!(b.to_string().contains("lib.rs"));
27+
//! assert!(b.to_string().contains(".rs"));
2828
//! ```
2929
//!
3030
//! # Credits

src/web/api/server/v1/contexts/torrent/handlers.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use std::io::{Cursor, Write};
44
use std::str::FromStr;
55
use std::sync::Arc;
66

7+
use axum::Json;
78
use axum::extract::{self, Multipart, Path, Query, State};
89
use axum::response::{IntoResponse, Redirect, Response};
9-
use axum::Json;
1010
use bittorrent_primitives::info_hash::InfoHash;
1111
use serde::Deserialize;
1212
use tracing::debug;
@@ -77,7 +77,6 @@ pub async fn download_torrent_handler(
7777

7878
debug!("Downloading torrent: {:?}", info_hash.to_hex_string());
7979

80-
#[allow(if_let_rescope)]
8180
if let Some(redirect_response) =
8281
redirect_to_download_url_using_canonical_info_hash_if_needed(&app_data, &info_hash, maybe_user_id).await
8382
{

0 commit comments

Comments
 (0)