Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks
tgross35 opened this issue Sep 25, 2024 · 9 comments
Open
4 tasks

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

tgross35 opened this issue Sep 25, 2024 · 9 comments
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-macros Working group: Macros

Comments

@tgross35
Copy link
Contributor

tgross35 commented Sep 25, 2024

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

@tgross35 tgross35 added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-macros Working group: Macros labels Sep 25, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 25, 2024
@tgross35
Copy link
Contributor Author

tgross35 commented Sep 25, 2024

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 tgross35 removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 25, 2024
@tgross35
Copy link
Contributor Author

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

@tgross35 tgross35 changed the title Make proc_macro usable in non-proc-macro crates Tracking issue for proc_macro in non-proc-macro crates Sep 25, 2024
@tgross35 tgross35 added E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. labels Sep 25, 2024
@programmerjake

This comment has been minimized.

@tgross35 tgross35 added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Sep 25, 2024
@tgross35
Copy link
Contributor Author

tgross35 commented Oct 1, 2024

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.

@AverseABFun
Copy link

I'd be interested in doing some work on this! I'm not super familiar with the rust internals however so it might take me a bit.

@AverseABFun
Copy link

Should I assign myself?

@jhpratt
Copy link
Member

jhpratt commented Dec 16, 2024

@AverseABFun I've done it for you. Best of luck! Certainly ask on Zulip if you have any questions.

@AverseABFun
Copy link

@rustbot label -E-help-wanted

@rustbot rustbot removed the E-help-wanted Call for participation: Help is requested to fix this issue. label Dec 16, 2024
@AverseABFun
Copy link

Working on first steps over in #134401!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-macros Working group: Macros
Projects
None yet
Development

No branches or pull requests

5 participants