rust-lang / rust-lang/rust

Tracking issue for `proc_macro` in non-`proc-macro` crates

Open
#130,856 9 comments 11 reactions 2 assignees View on GitHub

@cyrgani is already working on this.

Since Oct 9, 2025.

A-macros A-proc-macros C-tracking-issue E-medium S-tracking-unimplemented T-compiler T-libs WG-macros
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This is a tracking issue for making proc_macro usable in all crates, not just those with crate type proc-macro. Advantages:

  • Simplified testing of procedural macros
  • Examples in the API docs can get checked or run. Development of proc_macro would probably get a bit easier in general
  • Fewer crates would need a dependency on proc_macro2, which exists to solve these problems
  • This would be a step toward same-crate proc macros, if we ever decide we want them

proc_macro2 does this by selecting between the actual bridge implementation and a fallback, https://github.com/dtolnay/proc-macro2/blob/9c1d3eb1b6bddc5b86522bf3af98c2fb3de8e30a/src/lib.rs#L154-L158.

Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/404510-wg-macros/topic/Using.20proc_macro.20outside.20of.20proc.20macro.20crates (also some around https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Future.20macro.20possibilities.20.28e.2Eg.2E.20inline.20procedural.20macros.2E.2E.2E/near/472781328)

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps
Unresolved Questions

ACP is not yet complete, design work needed

Implementation history

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.