{"id":13437691,"url":"https://github.com/dtolnay/cargo-expand","last_synced_at":"2026-06-16T18:01:09.386Z","repository":{"id":40244171,"uuid":"60444394","full_name":"dtolnay/cargo-expand","owner":"dtolnay","description":"Subcommand to show result of macro expansion","archived":false,"fork":false,"pushed_at":"2026-05-18T12:55:29.000Z","size":1671,"stargazers_count":3091,"open_issues_count":9,"forks_count":73,"subscribers_count":13,"default_branch":"master","last_synced_at":"2026-06-13T13:15:51.703Z","etag":null,"topics":["cargo"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dtolnay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"dtolnay"}},"created_at":"2016-06-05T05:15:56.000Z","updated_at":"2026-06-09T09:04:20.000Z","dependencies_parsed_at":"2025-12-20T09:06:48.709Z","dependency_job_id":null,"html_url":"https://github.com/dtolnay/cargo-expand","commit_stats":{"total_commits":673,"total_committers":14,"mean_commits":48.07142857142857,"dds":0.0208023774145617,"last_synced_commit":"b33935ef7d9f175cb207b14b313aa4da247ef319"},"previous_names":[],"tags_count":178,"template":false,"template_full_name":null,"purl":"pkg:github/dtolnay/cargo-expand","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fcargo-expand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fcargo-expand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fcargo-expand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fcargo-expand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtolnay","download_url":"https://codeload.github.com/dtolnay/cargo-expand/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fcargo-expand/sbom","scorecard":{"id":358524,"data":{"date":"2025-08-11","repo":{"name":"github.com/dtolnay/cargo-expand","commit":"583dcb62deee38cb5bb2487d621b96a6592b7f26"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.5,"checks":[{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/ci.yml:10","Info: found token with 'none' permissions: .github/workflows/install.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:83: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/cargo-expand/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:84: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/cargo-expand/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:85: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/cargo-expand/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/cargo-expand/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/cargo-expand/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/cargo-expand/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:60: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/cargo-expand/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:73: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/cargo-expand/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:74: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/cargo-expand/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/install.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/cargo-expand/install.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   6 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE-APACHE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE-APACHE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":3,"reason":"security policy file detected","details":["Info: security policy file detected: github.com/dtolnay/.github/SECURITY.md:1","Warn: no linked content found","Warn: One or no descriptive hints of disclosure, vulnerability, and/or timelines in security policy","Info: Found text in security policy: github.com/dtolnay/.github/SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T10:12:08.094Z","repository_id":40244171,"created_at":"2025-08-18T10:12:08.094Z","updated_at":"2025-08-18T10:12:08.094Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34417416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cargo"],"created_at":"2024-07-31T03:00:59.330Z","updated_at":"2026-06-16T18:01:09.336Z","avatar_url":"https://github.com/dtolnay.png","language":"Rust","funding_links":["https://github.com/sponsors/dtolnay"],"categories":["Development tools","Rust","开发工具 Development tools","开发工具","Tools","Programming Languages","虚拟化"],"sub_categories":["Build system","构建系统 Build system","构建系统","创建系统 Build system"],"readme":"# cargo-expand\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-dtolnay/cargo--expand-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/dtolnay/cargo-expand)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/cargo-expand.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/cargo-expand)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/dtolnay/cargo-expand/ci.yml?branch=master\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/dtolnay/cargo-expand/actions?query=branch%3Amaster)\n\nOnce installed, the following command prints out the result of macro expansion\nand `#[derive]` expansion applied to the current crate.\n\n```console\n$ cargo expand\n```\n\nThis is a wrapper around the more verbose compiler command:\n\n```console\n$ cargo rustc --profile=check -- -Zunpretty=expanded\n```\n\n## Installation\n\nInstall with **`cargo install cargo-expand`**.\n\nThis command optionally uses [rustfmt] to format the expanded output. The\nresulting code is typically much more readable than what you get from the\ncompiler. If rustfmt is not available, the expanded code is not formatted.\nInstall rustfmt with **`rustup component add rustfmt`**.\n\n[rustfmt]: https://github.com/rust-lang/rustfmt\n\n## Example\n\n#### `$ cat src/main.rs`\n\n```rust\n#[derive(Debug)]\nstruct S;\n\nfn main() {\n    println!(\"{:?}\", S);\n}\n```\n\n#### `$ cargo expand`\n\n```rust\n#![feature(prelude_import)]\n#[prelude_import]\nuse std::prelude::v1::*;\n#[macro_use]\nextern crate std;\nstruct S;\n#[automatically_derived]\n#[allow(unused_qualifications)]\nimpl ::core::fmt::Debug for S {\n    fn fmt(\u0026self, f: \u0026mut ::core::fmt::Formatter) -\u003e ::core::fmt::Result {\n        match *self {\n            S =\u003e {\n                let mut debug_trait_builder = f.debug_tuple(\"S\");\n                debug_trait_builder.finish()\n            }\n        }\n    }\n}\nfn main() {\n    {\n        ::std::io::_print(::core::fmt::Arguments::new_v1(\n            \u0026[\"\", \"\\n\"],\n            \u0026match (\u0026S,) {\n                (arg0,) =\u003e [::core::fmt::ArgumentV1::new(arg0, ::core::fmt::Debug::fmt)],\n            },\n        ));\n    };\n}\n```\n\n## Options\n\n*See `cargo expand --help` for a complete list of options, most of which are\nconsistent with other Cargo subcommands. Here are a few that are common in the\ncontext of cargo expand.*\n\nTo expand a particular test target:\n\n`$ cargo expand --test test_something`\n\nTo expand without rustfmt:\n\n`$ cargo expand --ugly`\n\nTo expand a specific module or type or function only:\n\n`$ cargo expand path::to::module`\n\n[![cargo expand punctuated::printing][punctuated.png]][syn]\n[![cargo expand token::FatArrow][fatarrow.png]][syn]\n\n[punctuated.png]: https://raw.githubusercontent.com/dtolnay/cargo-expand/screenshots/punctuated.png\n[fatarrow.png]: https://raw.githubusercontent.com/dtolnay/cargo-expand/screenshots/fatarrow.png\n[syn]: https://github.com/dtolnay/syn\n\n## Configuration\n\nThe cargo expand command reads the `[expand]` section of $CARGO_HOME/config.toml\nif there is one (usually ~/.cargo/config.toml).\n\nSet the default syntax highlighting theme with the `theme` setting:\n\n```toml\n[expand]\ntheme = \"TwoDark\"\n```\n\nRun `cargo expand --themes` or `bat --list-themes` to print a list of available\nthemes. Use `theme = \"none\"` to disable coloring.\n\nChange the default coloring disposition (normally `auto`) with the `color`\nsetting:\n\n```toml\n[expand]\ncolor = \"always\"\n```\n\nEnable paging of the output with the `pager` setting:\n\n```toml\n[expand]\npager = true\n```\n\n## Disclaimer\n\nBe aware that macro expansion to text is a lossy process. This is a debugging\naid only. There should be no expectation that the expanded code can be compiled\nsuccessfully, nor that if it compiles then it behaves the same as the original\ncode.\n\nFor instance the following function returns `3` when compiled ordinarily by Rust\nbut the expanded code compiles and returns `4`.\n\n```rust\nfn f() -\u003e i32 {\n    let x = 1;\n\n    macro_rules! first_x {\n        () =\u003e { x }\n    }\n\n    let x = 2;\n\n    x + first_x!()\n}\n```\n\nRefer to [The Book] for more on the considerations around macro hygiene.\n\n[The Book]: https://doc.rust-lang.org/1.30.0/book/first-edition/macros.html#hygiene\n\n\u003cbr\u003e\n\n#### License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\u003e\n\n\u003cbr\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtolnay%2Fcargo-expand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdtolnay%2Fcargo-expand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtolnay%2Fcargo-expand/lists"}