rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.7k stars 12.75k forks source link

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

Open tgross35 opened 1 month ago

tgross35 commented 1 month ago

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

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

tgross35 commented 1 month ago

This idea has been thrown around a lot but there hasn't been any central place for discussion, so opened this issue to create one. This still needs some design work, see the ACP.

Cc @dtolnay, as always when your crates are mentioned.

tgross35 commented 1 month ago

@joshtriplett pointed out that https://github.com/rust-lang/libs-team/issues/406 exists, I'll just turn this into a tracking issue.

programmerjake commented 1 month ago

maybe add C-tracking-issue?

tgross35 commented 1 month ago

We discussed this a bit at the WG-Macros meeting today https://rust-lang.zulipchat.com/#narrow/stream/404510-wg-macros/topic/.E2.9C.94.20Open.20Discussion.20-.2010.2F01.2F2024. One item of note is that it seems like some experimentation will be needed to determine which solutions are feasible.