# dtolnay/cargo-expand

Subcommand to show result of macro expansion

Repository: https://github.com/dtolnay/cargo-expand
Canonical: https://ross.abutalabs.com/products/cargo-expand
Language: Rust
License: Apache-2.0
License Family: permissive
Topics: cargo
Last push: 2026-08-19T03:50:18+00:00

## Health v2 (maintenance only)
Score: 98/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 98, release rhythm 98, longevity 100
- inputs: {"age_days": 3741, "days_push": 14, "days_rel": 14, "gap_med": 10.0, "n_releases_24m": 35}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3126, forks 78 (observed 2026-08-28T04:07:44.459853+00:00)

## What it is
A Cargo subcommand that prints the result of macro and #[derive] expansion for a Rust crate, wrapping the verbose `cargo rustc -- -Zunpretty=expanded` compiler command. It optionally formats the expanded output with rustfmt for readability.

## Use cases
- debug why a Rust macro isn't working
- see what #[derive] generates for my struct
- inspect expanded proc macro output
- understand what code a macro produces
- troubleshoot macro expansion in Rust

## When to choose
- you're developing or debugging Rust macros or proc macros
- you need to see the fully expanded code the compiler sees
- you want formatted, readable expansion output

## When to avoid
- you don't work with Rust or Cargo
- you need a general-purpose Rust debugger rather than macro inspection

## Facets
- artifact type: cli-tool
- maturity: stable
- function: developer-tools, compiler, documentation
- domain: developer-tools, programming-languages
- platform: cli, rust, cross-platform
- tags: cargo-subcommand, rust-macros, macro-expansion, debugging, command-line

## Member repositories
- dtolnay/cargo-expand (main) score 98

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:44.459853+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:26:22.249818+00:00, confidence not recorded.
  - readme: https://github.com/dtolnay/cargo-expand (fetched 2026-08-28T04:07:44.459853+00:00, sha 140c5cb03d10)
  - registry_crates: https://crates.io/api/v1/crates/cargo-expand (fetched 2026-08-29T09:41:17.039549+00:00, sha fbb89abeed24)
- Data as of 2026-08-30T08:39:29.467469+00:00.
