rust-editions
Skill4 starsChanged 3 months agoApache-2.0View on GitHub
Master Rust editions, migration, and compatibility. Use when migrating between Rust editions (2015, 2018, 2021, 2024), understanding edition differences, using edition-specific features, or updating legacy code.
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 38
Default when edition is omitted from Cargo.toml
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rust Editions
Guide to Rust editions and migration based on The Edition Guide.
When to Use This Skill
- Migrating between Rust editions
- Understanding edition differences
- Using edition-specific features
- Updating legacy code
Core References
Edition Overview
| Edition | Year | Status |
| 2015 | 2015 | Stable |
| 2018 | 2018 | Stable |
| 2021 | 2021 | Stable |
| 2024 | 2024 | Stable (RFC 3501, Rust 1.85.0); prefer for new crates |
2021 and 2024 are both stable. New Cargo projects typically use 2024. Existing crates may stay on 2021 until migrated.
Edition 2015
Original edition. Key features:
- Ownership, borrowing, lifetimes
- Traits and generics
- Default when
editionis omitted fromCargo.toml
Edition 2018
Major improvements:
?forOptionandResult- Path/module system changes
- Raw identifiers (
r#match) dyn Traitfor trait objects- New keywords (
async,await,dyn,tryreserved)
fn foo(x: Option<i32>) -> Option<i32> {
Some(x? + 1)
}
let r#match = 42;
let x: Box<dyn Trait> = Box::new(Concrete::new());Edition 2021
Stable edition (still widely used). Key changes:
- Disjoint closure capture
- Or-patterns in
macro_rules! - Prelude adds
TryFrom,TryInto,FromIterator IntoIteratorfor arrays (edition-gated.into_iter()semantics)- Panic macro consistency
- Cargo feature resolver v2 by default
- Reserved prefixes (
ident#…forms)
match value {
Some(1) | Some(2) | Some(3) => println!("one two or three"),
_ => println!("other"),
}Edition 2024
Stable as of Rust 1.85.0 (RFC 3501). Prefer for new crates.
RPIT lifetime capture
Without an explicit use<..> bound, in-scope lifetime parameters are captured in return-position impl Trait (was edition-dependent before). Precise capturing (use<'a, T>) works in all editions since 1.82.
// 2024: captures `'_` implicitly (like async fn / trait RPIT)
fn f(_: &()) -> impl Sized {}
// Opt out of capturing lifetimes when needed:
fn g<'a>(x: &'a ()) -> impl Sized + use<> { *x }Migrate with cargo fix --edition (impl_trait_overcaptures lint). Prefer use<..> over old Captures / outlives tricks.
if let temporary scope
Temporaries from the if let scrutinee drop before the else branch (shorter than 2021). Avoids common RwLock deadlock patterns; code that relied on long-lived temps may need match instead.
Reserved gen keyword
gen is reserved for future gen blocks (RFC 3513). Identifiers named gen become r#gen via keyword_idents_2024. Gen blocks themselves are not stabilized by the edition.
Unsafe attributes and unsafe extern
These attributes require unsafe(...) in 2024:
#[unsafe(no_mangle)]#[unsafe(export_name = "...")]#[unsafe(link_section = "...")]
extern blocks must be unsafe extern "C" { ... } (items can be marked safe / unsafe).
Prelude: Future and IntoFuture
Both are in the 2024 prelude. Method-name collisions (e.g. custom poll) need fully qualified syntax; rust_2024_prelude_collisions migrates them.
IntoIterator for Box<[T]>
IntoIterator for boxed slices exists in all editions (1.80+). Method call .into_iter() yields values in 2024; pre-2024 method resolution still yielded &T. Migration rewrites .into_iter() → .iter() when references were intended (boxed_slice_into_iter).
Other notable 2024 changes
- Tail-expression temporary scope (block tail temps drop sooner)
letchains inif/whileunsafe_op_in_unsafe_fnwarn-by-default- Disallow references to
static mut - Never-type fallback change
- Macro fragment specifier tightening
- Cargo: rust-version-aware resolver; table/key consistency
- Rustdoc combined doctests; rustfmt style edition
Deeper notes and chapter links: references/edition-2024.md.
Migration
Official flow (Edition Guide):
cargo update
cargo fix --edition
# then edit Cargo.toml:[package]
edition = "2024"cargo build # or cargo test
cargo fmtcargo fix --edition applies the rust-2024-compatibility lint group against the next edition while your manifest still names the old one; then bump edition = "2024".
Requires a toolchain that supports 2024 (Rust 1.85+).
Common post-migration review
- RPIT: confirm
use<>bounds match intended capture if let→matchrewrites: keep only if you need 2021 temp lifetimes- Unsafe attrs /
unsafe extern: review soundness; autofix cannot verify it - Boxed-slice
.into_iter()vs.iter() - Prelude collisions on
poll/into_future
Reference Map
references/edition-2015.md— 2015 editionreferences/edition-2018.md— 2018 editionreferences/edition-2021.md— 2021 editionreferences/edition-2024.md— 2024 edition (deep dive + chapter links)references/migration.md— Migration commands and pitfalls
Key Commands
cargo fix --edition
# Cargo.toml: edition = "2024"
cargo build
cargo test
cargo fmtKey References
In this repository80 other files it gives its agents.
- a11y-accessibility-designSkill
- agentic-ui-patternsSkill
- ai-native-ui-designSkill
- ai-ui-anti-patternsSkill
- ai-ui-heuristicsSkill
- calm-technology-uiSkill
- conversion-growth-designSkill
- cross-platform-designSkill
- dark-mode-designSkill
- data-visualizationSkill
- design-systemsSkill
- design-thinking-processSkill
- error-empty-statesSkill
- ethical-design-patternsSkill
- form-uxSkill
- information-architectureSkill
- interaction-design-patternsSkill
- internationalization-uiSkill
- mobile-touch-designSkill
- modal-classes-lifecycleSkill
- modal-container-imagesSkill
- modal-dicts-queuesSkill
- modal-endpointsSkill
- modal-fundamentalsSkill
- modal-gpu-computeSkill
- modal-networkingSkill
- modal-observabilitySkill
- modal-parallel-executionSkill
- modal-sandboxesSkill
- modal-scaling-performanceSkill
- modal-schedulingSkill
- modal-secretsSkill
- modal-serversSkill
- modal-storageSkill
- modal-web-servingSkill
- modal-workspace-adminSkill
- motion-design-principlesSkill
- notifications-permissionsSkill
- onboarding-uxSkill
- rust-api-designSkill
- rust-async-programmingSkill
- rust-cargo-masterySkill
- rust-cli-applicationsSkill
- rust-clippy-lintsSkill
- rust-closures-iteratorsSkill
- rust-compiler-internalsSkill
- rust-concurrencySkill
- rust-design-patternsSkill
- rust-embeddedSkill
- rust-error-handlingSkill
- rust-game-developmentSkill
- rust-lifetimes-borrowingSkill
- rust-macrosSkill
- rust-performanceSkill
- rust-rustdocSkill
- rust-rustup-toolchainSkill
- rust-smart-pointersSkill
- rust-testing-benchmarkingSkill
- rust-type-systemSkill
- rust-unsafe-ffiSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

