Language Internals
Part 2 of 11 · Rust Language ProficiencyToolchain — rustup, Cargo, Editions & crates.io
rustup, Cargo, editions, crates.io, toolchain files.
- 1Gist
- 2Maps
- 3Q&A
- 4Sandbox
Voice readout needs Web Speech Synthesis in this browser.
Question ladder
L1
What does rustup install?
Answer
A toolchain: rustc, Cargo, the standard library, and optional components such as clippy and rustfmt.
L2
What does an edition change?
Answer
Your crate's language plus a few edition-tied defaults (edition 2024 implies Cargo resolver 3); dependencies keep their own editions and still compile together.
L3
Why both Cargo.toml and Cargo.lock?
Answer
The manifest holds version ranges and features. The lockfile holds exact pins and checksums.
L4
When do you commit the lockfile?
Answer
Commit it for applications so CI builds the same graph. Libraries often still commit it so their own tests are reproducible.
L5
What is a Cargo feature?
Answer
A compile-time flag. Features unify across the dependency graph, so one crate enabling a feature can turn it on for everyone.
L6
What is MSRV?
Answer
The oldest rustc you promise. rust-version in the manifest records it. Edition 2024 still needs a new enough compiler.
L7
What belongs in CI on rustc 1.98.1?
Answer
cargo fmt --check, cargo clippy with warnings denied, and cargo test, on the stable toolchain you pinned.
Failure modes
Nightly in production
A feature gate sneaks into the default toolchain and CI cannot reproduce it.
Unlocked application
Cargo.toml ranges float and next week's crates.io publish changes behavior.
Feature unification surprise
A dev-dependency feature enables code the published crate did not intend.
Edition assumed to be a compiler version
edition 2024 is a dialect. rustc 1.98.1 is the compiler. They are different knobs.
Misconceptions
Upgrading the edition rewrites every dependency.
cargo fix can update your crate. Dependencies stay on the edition they declared.
Cargo.lock is optional noise.
It is the pin set. Applications should commit it.
clippy is only formatting.
rustfmt formats. clippy is semantic lint, including ownership and allocation hints.
Interviewer traps
Calling the edition the Rust version.
Say rustc 1.98.1 and edition 2024 as two fields.
Comparing Cargo features to npm optional peers.
Features are compile-time and unify. Peers resolve differently.
Design scenario
Same prompt for every reader.
Requirements
rustup stable, edition 2024, a committed lockfile, rust-version set, fmt and clippy in CI.
Traffic / scale
One binary, a handful of crates, rebuilt on every pull request.
Latency
Cold cargo builds dominate. The lockfile keeps them repeatable.
Consistency
The same checksums in CI and on a laptop.
Availability
A missing component or a nightly-only flag blocks release.
Failure assumptions
- Developers install rustc from a distro package and skip rustup.
- The lockfile is gitignored.
Constraints
- Stay on the toolchain. Do not design a deploy pipeline.
Prompt
A new CLI must build on stable, pin dependencies, and fail CI when formatting or clippy drifts.
One tool versus a stack of tools
Prefer
Cargo owns the crate
Build, dependencies, tests, and the lockfile live in one manifest pair.
- edition is per crate and mixable.
- Features are compile-time flags.
- rustup pins the compiler.
Alternative
Split installers
npm still needs a runtime story. Python splits the interpreter from the package tool.
- package.json does not pick the language dialect.
- A venv is not a compiler pin.
- Lockfiles exist, but the build tool varies.
Overview
Install with rustup, build with Cargo, pin with Cargo.lock, lint with clippy, format with rustfmt. New crates in this series set edition = "2024" and expect stable 1.98.1.
Toolchain map
| Concern | TypeScript | Python | Rust |
|---|---|---|---|
| Version manager | nvm or fnm | pyenv or uv | rustup |
| Build and packages | npm or pnpm | pip, uv, or poetry | Cargo |
| Lockfile | package-lock | uv.lock | Cargo.lock |
| Registry | npmjs | PyPI | crates.io |
| Lint and format | eslint and prettier | ruff | clippy and rustfmt |
Decisions
- 1
Step 1 rustup toolchain install stable
- nextStep 2 cargo new app - Cargo.toml with edition 2024
- 2
Step 2 cargo new app - Cargo.toml with edition 2024
- nextStep 3 cargo add a dependency - Cargo.lock pins exact versions
- 3
Step 3 cargo add a dependency - Cargo.lock pins exact versions
- nextStep 4 cargo build and cargo test
- 4
Step 4 cargo build and cargo test
- nextStep 5 CI runs cargo clippy -D warnings and cargo fmt --check
- 5
Step 5 CI runs cargo clippy -D warnings and cargo fmt --check
- nextStep 6 Builds on the declared rust-version (MSRV)
- ?
Step 6 Builds on the declared rust-version (MSRV)
- yesStep 7 Ship - commit Cargo.lock for binaries
- noFailure path - a dependency needs newer rustc; pin it or raise MSRV
- 7
Step 7 Ship - commit Cargo.lock for binaries
- 8
Failure path - a dependency needs newer rustc; pin it or raise MSRV
Lesson map
Toolchain — rustup, Cargo, Editions & crates.io
rustup, Cargo, editions, crates.io, toolchain files.
Architecture. Step 1 rustup toolchain install stable Ready. Step 2 cargo new app - Cargo.toml with edition 2024 Ready. Step 3 cargo add a dependency - Cargo.lock pins exact versions Ready. Step 4 cargo build and cargo test Ready. Step 5 CI runs cargo clippy -D warnings and cargo fmt --check Ready. Step 6 Builds on the declared rust-version (MSRV) Ready. Step 7 Ship - commit Cargo.lock for binaries Ready. Failure path - a dependency needs newer rustc; pin it or raise MSRV Ready
Select a node to see why it exists, or an edge to see the protocol, direction, effect, and consequence.
Mermaid export
flowchart TB A["Step 1 rustup toolchain install stable Ready"] B["Step 2 cargo new app - Cargo.toml with edition 2024 Ready"] C["Step 3 cargo add a dependency - Cargo.lock pins exact versions Ready"] D["Step 4 cargo build and cargo test Ready"] E["Step 5 CI runs cargo clippy -D warnings and cargo fmt --check Ready"] F["Step 6 Builds on the declared rust-version (MSRV) Ready"] G["Step 7 Ship - commit Cargo.lock for binaries Ready"] X["Failure path - a dependency needs newer rustc pin it or raise MSRV Ready"] A -->|continues| B B -->|continues| C C -->|continues| D D -->|continues| E E -->|continues| F F -->|yes| G F -->|no| X
Press Run. Snippets must be self-contained — no network, files, or native modules.
Editions
| Edition | Role |
|---|---|
| 2015, 2018, 2021 | Earlier dialects that still compile |
| 2024 | Current for new code on 1.98.1 and 1.99.0 |
An edition change is local. A 2021 dependency can sit under a 2024 binary.
Rosetta — hello project
[package]
name = "hello_rust"
version = "0.1.0"
edition = "2024"fn main() {
println!("hello from rustc 1.98.1+");
}// npm i -D tsx typescript
// npx tsx hello.ts
console.log("hello from tsx");TypeScript here runs with npm i -D tsx typescript, then npx tsx hello.ts. The package manifest does not need a start script.
print("hello from python")Cargo runs, tests, and fetches in one CLI. npm still needs a runtime. Python separates the interpreter from the installer.
Rosetta — add a dependency
cargo add serde --features deriveuse serde::Serialize;
#[derive(Serialize)]
struct Hi {
n: u32,
}import { z } from "zod";
const Hi = z.object({ n: z.number() });from pydantic import BaseModel
class Hi(BaseModel):
n: intCargo features are additive compile-time flags and they unify across the graph. Python extras are the nearer analogy. npm optional peers resolve differently.
rustup commands worth memorizing
rustup update stable
rustc --version
rustup component add clippy rustfmtrustc --version should show 1.99.0 or newer (1.99.0 stable since 2026-10-01).
Interview Q&A
What does an edition change?
Answer
Your crate's language plus a few edition-tied defaults (edition 2024 implies Cargo resolver 3); dependencies keep their own editions.
Why Cargo.toml and Cargo.lock?
Answer
The manifest holds ranges, features, and the edition. The lockfile holds exact versions and checksums.
Is rustc 1.98.1 the same thing as edition 2024?
Answer
No. 1.98.1 is the compiler release. Edition 2024 is the dialect you opt into per crate. The 1.98.1 point release was 2026-09-03. 1.99.0 was released as stable on 2026-10-01, after this lesson was written; samples unchanged.
When do you commit Cargo.lock?
Answer
For any application you ship. It is what makes CI match a laptop. Libraries still often commit it for their own test graph.
What is feature unification?
Answer
If any crate in the graph enables a feature, Cargo turns that feature on for the shared build of that dependency.
clippy or rustfmt?
Answer
rustfmt is layout. clippy is the semantic linter. CI should run both, plus cargo test.
What is MSRV?
Answer
The minimum supported rustc. Record it with rust-version. A lower MSRV means fewer new syntax features.
Why not nightly for the default CI job?
Answer
Nightly moves. Stable 1.98.1 is the reproducible compiler for this series. Nightly stays in an experiment job.
Pitfalls
- Treating the edition as a compiler upgrade.
- Gitignoring Cargo.lock in a binary crate.
- Enabling a feature in a dev-dependency and shipping the unified result by accident.
- Installing clippy on one machine and not in CI.
Open a Cargo.toml and name the edition, the rust-version if present, and one feature. Say whether you would commit the matching lockfile.