Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uprustc: Stabilize the `proc_macro` feature #52081
Conversation
rust-highfive
assigned
aturon
Jul 5, 2018
This comment has been minimized.
This comment has been minimized.
|
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
rust-highfive
added
the
S-waiting-on-review
label
Jul 5, 2018
This comment has been minimized.
This comment has been minimized.
|
cc @petrochenkov, @dtolnay, @nrc |
rust-highfive
assigned
nikomatsakis
and unassigned
aturon
Jul 5, 2018
alexcrichton
referenced this pull request
Jul 5, 2018
Closed
Tracking issue for RFC 1566: Procedural macros #38356
petrochenkov
self-assigned this
Jul 5, 2018
petrochenkov
reviewed
Jul 5, 2018
| @@ -13,7 +13,7 @@ use Span; | |||
| use rustc_errors as rustc; | |||
|
|
|||
| /// An enum representing a diagnostic level. | |||
| #[unstable(feature = "proc_macro", issue = "38356")] | |||
| #[unstable(feature = "proc_macro_diagnostic", issue = "38356")] | |||
This comment has been minimized.
This comment has been minimized.
petrochenkov
Jul 5, 2018
Contributor
What's the point in renaming unstable library features?
This is only breaking all the code using them.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 5, 2018
Author
Member
The proc_macro feature at this point has been used-and-abused I think a bit too much. This PR is, afaik, the main thrust of proc_macro for stabilization. The renamings here aren't intended to purely break everyone else's code, but rather clearly singify different groupings of features instead of leaving them all in a perpetual singular proc_macro bucket
petrochenkov
reviewed
Jul 5, 2018
| @@ -93,13 +93,13 @@ impl !Sync for LexError {} | |||
|
|
|||
| impl TokenStream { | |||
| /// Returns an empty `TokenStream` containing no token trees. | |||
| #[unstable(feature = "proc_macro", issue = "38356")] | |||
| #[stable(feature = "proc_macro_lib2", since = "1.29.0")] | |||
This comment has been minimized.
This comment has been minimized.
petrochenkov
Jul 5, 2018
Contributor
Are you going to use proc_macro_lib3/4/5/... for the next portions of stabilized APIs? :)
I used proc_macro_12 in my PR (#50473 (comment)), because it's Macros 1.2.
(OK, it doesn't matter anyway.)
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 5, 2018
Author
Member
As I'm sure you know, the stable feature name doesn't actually matter. I initially changed these while the other unstable features were still proc_macro and then ended up later changing the other proc_macro features to different names. As a result this stuck. It's an arbitrary name.
This comment has been minimized.
This comment has been minimized.
Oh man, this is going to be painful. |
This comment has been minimized.
This comment has been minimized.
|
I don't see much use in landing this PR before stabilizing I plan to fix tool attributes in the next few weeks, so poor users of I think custom attributes could be restored in some form as well, e.g. if some attribute is "definitely unresolved" as a macro, then it can be kept in the source as a custom attribute (still under a feature gate) instead of producing a dummy expansion, like it's done now. |
This comment has been minimized.
This comment has been minimized.
|
While true that this PR isn't too useful landing by itself it does need to land eventually for proc-macro stabilization, and this was larger and more thorny than I thought it would be so I wanted to put it up for review and get it in soon to iron out all the CI issues. |
This comment has been minimized.
This comment has been minimized.
Does this also break |
This comment has been minimized.
This comment has been minimized.
|
FWIW, I have mentioned before that if the |
This comment has been minimized.
This comment has been minimized.
|
@eddyb Yes, it might be "just" a matter of someone familiar enough with what the lint does and the soundness of GC rooting to come up with a new design and implementing it. In the meantime, a lint is what we have. |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin yes it'd break that because those attributes aren't hooked into the normal resolver. You can rename them with a |
jebrosen
referenced this pull request
Jul 6, 2018
Merged
Merge `proc_macro_` expansion feature gates as `proc_macro_hygiene` #52121
LukasKalbertodt
referenced this pull request
Jul 7, 2018
Merged
Rewrite most of the crate with updated dependencies #9
ubnt-intrepid
referenced this pull request
Jul 8, 2018
Closed
Tracking issue for code generation #80
jebrosen
referenced this pull request
Jul 9, 2018
Closed
Tracking issue for proc_macro conversion #693
This comment has been minimized.
This comment has been minimized.
|
I think @nikomatsakis is out this week, so... r? @nrc |
rust-highfive
assigned
nrc
and unassigned
nikomatsakis and
petrochenkov
Jul 9, 2018
This comment has been minimized.
This comment has been minimized.
|
I have a major reservation about stabilizing that I brought up in the tracking issue. |
petrochenkov
referenced this pull request
Jul 10, 2018
Closed
Tracking issue for "macro naming and modularisation" (RFC #1561) #35896
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton I think we can land the proc macro library API part right now (it adds nothing fundamentally new compared to Could you leave this stabilization work to me? |
bors
added
S-waiting-on-bors
and removed
S-waiting-on-author
labels
Jul 16, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors retry GitHub outage causing the CIs not seeing the |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jul 16, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit 65f3007
into
rust-lang:master
Jul 16, 2018
This comment has been minimized.
This comment has been minimized.
|
Tested on commit 1ecf692.
|
alexcrichton commentedJul 5, 2018
•
edited
This commit stabilizes some of the
proc_macrolanguage feature as well as anumber of APIs in the
proc_macrocrate as previously discussed. Thismeans that on stable Rust you can now define custom procedural macros which
operate as attributes attached to items or
macro_rules!-like bang-styleinvocations. This extends the suite of currently stable procedural macros,
custom derives, with custom attributes and custom bang macros.
Note though that despite the stabilization in this commit procedural macros are
still not usable on stable Rust. To stabilize that we'll need to stabilize at
least part of the
use_extern_macrosfeature. Currently you can define aprocedural macro attribute but you can't import it to call it!
A summary of the changes made in this PR (as well as the various consequences)
is:
proc_macrolanguage and library features are now stable.proc_macrocrate are now named under adifferent feature, such as
proc_macro_diagnosticorproc_macro_span.proc_macrobeing enabled have switched overto
use_extern_macrosbeing enabled. This means that code using#![feature(proc_macro)]today will likely need to move to#![feature(use_extern_macros)].It's intended that this PR, once landed, will be followed up with an attempt to
stabilize a small slice of
use_extern_macrosjust for procedural macros tomake this feature 100% usable on stable.