Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Move a crate to edition 2024

Use when: a crate you own is on edition 2021 or older and you want the 2024 rules

Goal: the same program on edition 2024, building, tested and reviewed

Taught in Migrating to edition 2024

  1. 1

    Run cargo update, build and test, and commit so the tree is clean.

    Why: newer dependency releases often fix edition problems of their own, and cargo fix refuses to edit uncommitted files.

  2. 2

    Leave the edition line alone and run cargo fix --edition. It fixes every target (library, binaries, tests, examples) by default. For a crate with Cargo features, add --all-features, and for code behind #[cfg(windows)]-style conditions, run it again with --target for those platforms, so every file is compiled and fixed.

    Example

    Fixed src/main.rs (6 fixes) for tidewatch.

    Why: the fixing lints run under the current edition and rewrite code to mean the same thing under the next one.

  3. 3

    Set edition = "2024" in Cargo.toml (and raise rust-version to at least 1.85 if it's lower).

    Why: the tool never changes the line itself, and Cargo refuses a 2024 crate whose rust-version is below 1.85.

  4. 4

    Run cargo build, cargo test, cargo clippy and cargo fmt, and fix anything left by hand, such as static mut references.

    Why: some changes have no automatic fix, and the tests confirm the meaning didn't move.

  5. 5

    Read the diff: check each new unsafe, replace each FIXME, and decide whether to keep each use<..> and r# name.

    Why: the tool preserves meaning; it can't judge whether the code's promises are true.