rust-syntax-edition-2024
Installation
SKILL.md
Contains Shell Commands
This skill contains shell command directives (!`command`) that may execute system commands. Review carefully before installing.
rust-syntax-edition-2024
Edition 2024 stabilized in Rust 1.85.0 (2025-02-20). It is the largest edition the Rust project has shipped: 13 language changes, library prelude additions, Cargo default shifts (cargo new defaults to edition = "2024" and resolver "3"), and Rustfmt rule updates. This skill is the authoritative reference every other syntax/impl skill in this package depends on. ALWAYS treat edition 2024 as the baseline; NEVER ship code in this package using pre-2024 idioms unless explicitly demonstrating a migration delta.
Quick Reference
Core rules (deterministic)
- ALWAYS migrate via
cargo fix --editionon a clean working tree. NEVER hand-edit edition idioms before running the automated migration; you will miss lints that only the rustc driver emits. - NEVER write
extern "C" { ... }in edition 2024 code. ALWAYS writeunsafe extern "C" { ... }; items inside areunsafeby default and may be opted intosafeper item. - NEVER use bare
#[no_mangle],#[link_section = "..."], or#[export_name = "..."]in edition 2024. ALWAYS wrap them as#[unsafe(no_mangle)],#[unsafe(link_section = "...")],#[unsafe(export_name = "...")]. - ALWAYS wrap every unsafe operation inside an
unsafe fnbody in its ownunsafe { ... }block. The 2024 default is#[warn(unsafe_op_in_unsafe_fn)]; pre-2024 code that calls unsafe ops bare inside an unsafe fn body breaks the lint. - NEVER assume RPIT (
-> impl Trait) does NOT capture an input lifetime in edition 2024. The 2024 default captures all in-scope generics and lifetimes. Opt out with+ use<>(or list specific params with+ use<'a, T>). - NEVER rely on
!falling back to()in 2024. The fallback is!itself; type-inference outcomes for?-and-unwrap-only paths change. Annotate the turbofish (f::<()>()) at the call site when migration breaks. - NEVER take a shared or mutable reference to a
static mut. Thestatic_mut_refslint isdeny-by-default in 2024. ALWAYS migrate toAtomicX,Mutex<T>,OnceLock<T>,LazyLock<T>, or&raw const/&raw mut. - NEVER use
genas an identifier in edition 2024 code. ALWAYS rename, or escape asr#genif you cannot.genblocks themselves remain unstable. - ALWAYS bind the result of a
RefCell::borrow()/Mutex::lock()to aletbefore the tail expression dot-chains it. Thetail_expr_drop_orderchange drops temporaries before locals in 2024. - ALWAYS rewrite
if let Some(x) = read_lock() { ... } else { write_lock() ... }patterns. In 2024 the scrutinee temporary drops BEFORE enteringelse, which fixes deadlocks but changes drop order observably.