{"id":13595052,"url":"https://github.com/dtolnay/proc-macro2","last_synced_at":"2025-12-27T23:36:40.333Z","repository":{"id":36986890,"uuid":"91860126","full_name":"dtolnay/proc-macro2","owner":"dtolnay","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-24T02:36:27.000Z","size":1630,"stargazers_count":824,"open_issues_count":16,"forks_count":119,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-01T00:01:55.357Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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},"funding":{"github":"dtolnay"}},"created_at":"2017-05-20T02:35:07.000Z","updated_at":"2025-04-26T05:09:02.000Z","dependencies_parsed_at":"2023-10-03T07:27:45.180Z","dependency_job_id":"757b1061-c176-4eda-905d-87e5217f7664","html_url":"https://github.com/dtolnay/proc-macro2","commit_stats":{"total_commits":914,"total_committers":30,"mean_commits":"30.466666666666665","dds":0.1345733041575492,"last_synced_commit":"6d030a46bc2af41e1d802925118b8acb4f4c26dd"},"previous_names":["alexcrichton/proc-macro2"],"tags_count":151,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fproc-macro2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fproc-macro2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fproc-macro2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fproc-macro2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtolnay","download_url":"https://codeload.github.com/dtolnay/proc-macro2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252596418,"owners_count":21773845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-01T16:01:43.131Z","updated_at":"2025-12-12T14:50:31.476Z","avatar_url":"https://github.com/dtolnay.png","language":"Rust","funding_links":["https://github.com/sponsors/dtolnay"],"categories":["Rust","Summary"],"sub_categories":[],"readme":"# proc-macro2\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-dtolnay/proc--macro2-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/dtolnay/proc-macro2)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/proc-macro2.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/proc-macro2)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-proc--macro2-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logo=docs.rs\" height=\"20\"\u003e](https://docs.rs/proc-macro2)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/dtolnay/proc-macro2/ci.yml?branch=master\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/dtolnay/proc-macro2/actions?query=branch%3Amaster)\n\nA wrapper around the procedural macro API of the compiler's `proc_macro` crate.\nThis library serves two purposes:\n\n- **Bring proc-macro-like functionality to other contexts like build.rs and\n  main.rs.** Types from `proc_macro` are entirely specific to procedural macros\n  and cannot ever exist in code outside of a procedural macro. Meanwhile\n  `proc_macro2` types may exist anywhere including non-macro code. By developing\n  foundational libraries like [syn] and [quote] against `proc_macro2` rather\n  than `proc_macro`, the procedural macro ecosystem becomes easily applicable to\n  many other use cases and we avoid reimplementing non-macro equivalents of\n  those libraries.\n\n- **Make procedural macros unit testable.** As a consequence of being specific\n  to procedural macros, nothing that uses `proc_macro` can be executed from a\n  unit test. In order for helper libraries or components of a macro to be\n  testable in isolation, they must be implemented using `proc_macro2`.\n\n[syn]: https://github.com/dtolnay/syn\n[quote]: https://github.com/dtolnay/quote\n\n## Usage\n\n```toml\n[dependencies]\nproc-macro2 = \"1.0\"\n```\n\nThe skeleton of a typical procedural macro typically looks like this:\n\n```rust\nextern crate proc_macro;\n\n#[proc_macro_derive(MyDerive)]\npub fn my_derive(input: proc_macro::TokenStream) -\u003e proc_macro::TokenStream {\n    let input = proc_macro2::TokenStream::from(input);\n\n    let output: proc_macro2::TokenStream = {\n        /* transform input */\n    };\n\n    proc_macro::TokenStream::from(output)\n}\n```\n\nIf parsing with [Syn], you'll use [`parse_macro_input!`] instead to propagate\nparse errors correctly back to the compiler when parsing fails.\n\n[`parse_macro_input!`]: https://docs.rs/syn/2.0/syn/macro.parse_macro_input.html\n\n## Unstable features\n\nThe default feature set of proc-macro2 tracks the most recent stable compiler\nAPI. Functionality in `proc_macro` that is not yet stable is not exposed by\nproc-macro2 by default.\n\nTo opt into the additional APIs available in the most recent nightly compiler,\nthe `procmacro2_semver_exempt` config flag must be passed to rustc. We will\npolyfill those nightly-only APIs back to Rust 1.68.0. As these are unstable APIs\nthat track the nightly compiler, minor versions of proc-macro2 may make breaking\nchanges to them at any time.\n\n```\nRUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build\n```\n\nNote that this must not only be done for your crate, but for any crate that\ndepends on your crate. This infectious nature is intentional, as it serves as a\nreminder that you are outside of the normal semver guarantees.\n\nSemver exempt methods are marked as such in the proc-macro2 documentation.\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%2Fproc-macro2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdtolnay%2Fproc-macro2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtolnay%2Fproc-macro2/lists"}