cargo-expand
« Back to VersTracker
Description:
Show what Rust code looks like with macros expanded
Type: Formula  |  Latest Version: 1.0.118@0  |  Tracked Since: Dec 17, 2025
Links: Homepage  |  @dtolnay  |  formulae.brew.sh
Category: Developer tools
Tags: rust cargo macros development debugging compiler
Install: brew install cargo-expand
About:
Cargo expand is a Rust compiler driver that runs your code through the macro expansion engine and pretty printer, showing the result. It helps developers debug complex macros by revealing the actual code generated after all derive, attribute, and function-like macros have been expanded.
Key Features:
  • Shows post-expansion Rust source code for any crate or module
  • Supports pretty-printing with syntax highlighting for readability
  • Integrates directly with Cargo as a subcommand for seamless workflow
  • Can expand specific modules or targets to focus on relevant code
Use Cases:
  • Debugging complex derive macros and attribute macros in your codebase
  • Understanding how procedural macros transform code during development
  • Inspecting generated code from third-party libraries to learn their internals
Alternatives:
  • cargo-show-asm – Shows assembly output instead of expanded Rust code; better for low-level optimization analysis
  • rust-analyzer – Provides macro expansion hints in IDE but doesn't show full expanded source as a single file
Version History
Detected Version Rev Change Commit
Oct 19, 2025 10:56pm 0 VERSION_BUMP b32698ae
Oct 2, 2025 4:52am 0 VERSION_BUMP eab7f4ff
Sep 12, 2025 6:16pm 0 VERSION_BUMP 99c69950
Jan 12, 2025 5:26pm 0 VERSION_BUMP 5b90dee4
Jan 12, 2025 4:51pm 0 VERSION_BUMP b755b488
Jan 12, 2025 4:51am 0 VERSION_BUMP 41e15886
Jan 7, 2025 7:52pm 0 VERSION_BUMP 962ac4e7
Jan 5, 2025 10:50pm 0 VERSION_BUMP 27a61706