-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Begin reorganization of proc_macro crate #134401
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @tgross35 (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
This PR may fail because https://github.com/rust-lang/rust/blob/6d9f6ae36ae1299d6126ba40c15191f7aa3b79d8/compiler/rustc_expand/src/proc_macro.rs uses Edit: guess that already happened, see above. |
To clarify some of my thoughts here: the reason for this refactor would be to give most of ^ That should be captured in the module docs for For the above error, I think the cleanest way to fix this while keeping refactoring is to reexport the bridge code in #[doc(hidden)]
pub mod bridge {
pub use super::backend::bridge::*;
} |
After thinking about it a bit further, this naming convention seems like it would be more accurate:
So, suggestions for how this could be refactored a bit (each // lib.rs
mod backend { // backend/mod.rs
mod support { // backend/support/mod.rs
//! All data structures that support backends but aren't interface-specific.
// None of this should depend on `client`, `server`, or `bridge`.
mod fxhash; // backend/support/fxhash.rs
mod arena; // backend/support/arena.rs
mod buffer; // backend/support/buffer.rs
mod closure; // backend/support/closure.rs
mod handle; // backend/support/handle.rs
mod selfless_reify; // backend/support/selfless_reify.rs
}
/// Interfaces and types representing `proc_macro` as a client.
pub mod client; // backend/client.rs
/// Abstract interfaces for `proc_macro` servers.
pub mod server; // backend/server.rs
/// Serialization between a client and a server.
pub mod rpc; // backend/rpc.rs
/// Everything for a bridged backend to `rustc` or `rust-analyzer`.
pub mod bridge; // backend/bridge.rs
// Eventually there will be a `mod standalone` here
mod symbol; // backend/symbol.rs
pub use support::{fxhash::FxHashMap, arena::Arena, etc};
}
/// Public interfaces for use by the bridge backend
// This one can just be within lib.rs
#[doc(hidden)]
pub mod bridge {
pub use super::backend::bridge::{
DelimSpan, Diagnostic, ExpnGlobals, Group,
Ident, LitKind, Literal, Punct, TokenTree,
};
pub use super::backend::{client, server};
} |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7ab9d67
to
9ff52e8
Compare
One more thing that we should come up with a vocab for(not feeling very creative right now) is one of (bridge, standalone). EDIT: Whoops, wasn't thinking, the name is "servers" 😅 |
Separate from that, I think that under the server/client modules we should have separate files for bridge v. standalone and they'd be conditionally compiled while implementing the same interface. Thoughts? |
That might've been what you were saying, not sure. |
Also, thoughts on adding a module |
Annnd nevermind. I don't think that's actually necessary. |
This comment has been minimized.
This comment has been minimized.
Sorry for all of the pings, but I'm trying to decide where |
Aaand I do need to make a common directory. |
This comment has been minimized.
This comment has been minimized.
We can't have any conditional compilation in the final product. Formerly I thought that using
The data structure-type things like
Don't be, happy to work through this :)
Just rename this one to There will wind up being two modules called
I think this can just be at |
Okay I see, that would make sense. Actually, would we even need a standalone server? Since proc macros are meant to be compiled as a dynamic library, if we add a lint to prevent using proc macros as regular functions, then we should be able to just not have a standalone server as the proc macros would never get actually called. |
This comment has been minimized.
This comment has been minimized.
Why does github not have the option to force-push in the online thing 😭 |
6c99e3d
to
ddbe035
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
I am not sure I follow - the end goal is to make
Don't worry about the merge commit warning, I'll ask you to clean up history before merge. |
@rustbot author for the things discussed in #134401 (comment) (just comment |
Hey @AverseABFun, I know you were on the fence about continued macro work but are you interested in finishing this up? Changing this to reflect #134401 (comment) is still needed, I don't think there is too much more needed for that. |
Whoops, I completely forgot about this! I have some stuff I need to do
first but I'll finish it when I can.
…On Wed, Jan 8, 2025 at 4:53 PM Trevor Gross ***@***.***> wrote:
Hey @AverseABFun <https://github.com/AverseABFun> are you interested in
finishing this up? Changing this to reflect #134401 (comment)
<#134401 (comment)>
is still needed, I don't think there is too much more needed for that.
—
Reply to this email directly, view it on GitHub
<#134401 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATOOUFRQ7QH4A6DCOUYLM5L2JWUAFAVCNFSM6AAAAABTXHVFS6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNZYHAZTEOJRHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@AverseABFun |
Sorry! Can someone else pick this up? If not, I'll try to get around to
this ASAP.
…On Mon, Feb 17, 2025 at 2:10 AM alexey semenyuk ***@***.***> wrote:
@AverseABFun <https://github.com/AverseABFun>
Thanks for your contribution
From wg-triage. Do you have any updates on this PR
—
Reply to this email directly, view it on GitHub
<#134401 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATOOUFTRHSWBW3BKAIE7TSL2QGKPHAVCNFSM6AAAAABTXHVFS6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNRSGM2DGMZTGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: alex-semenyuk]*alex-semenyuk* left a comment
(rust-lang/rust#134401)
<#134401 (comment)>
@AverseABFun <https://github.com/AverseABFun>
Thanks for your contribution
From wg-triage. Do you have any updates on this PR
—
Reply to this email directly, view it on GitHub
<#134401 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATOOUFTRHSWBW3BKAIE7TSL2QGKPHAVCNFSM6AAAAABTXHVFS6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNRSGM2DGMZTGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@Aversefun |
Aw no, looks like I just arrived a few days too late. This PR was mentioned in this video (at 9:18):
Is there a concise TODO list of what is unfinished exactly? From reviewing the above I can see
|
@lmmx your description sounds accurate to me! If you are interested, feel free to put up a reorganization PR and request a review from me (either with this one as a base or from scratch). The reorg should be pretty easy, after that I think adding the abstractions / bridge should be straightforward. Happy to help if you have any questions! We also have a chat for dev-related things at https://rust-lang.zulipchat.com/. |
The tracking issue for this is #130856. This PR begins reorganizing the proc_macro crate as a prerequisite to beginning implementing the main portion of the linked issue.
r? @tgross35