-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Split libsyntax apart #65324
Split libsyntax apart #65324
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
👍 on the general direction.
|
Regarding use of cfg-expansion from |
Thanks for that :)
Yeah my goal with this PR was to propose a general direction and then split out smaller individual commits to merge first, especially for some of the larger or drive-by changes (like the one you referenced).
Hmm... Some of these small modules were pre-existing so if possible I'd like to avoid more drive-by changes in this PR. :)
Nice! I'll use that. Better than my naming. :)
Will do.
Hmm... I inserted a call to
By connecting them via e.g. |
I only theorized about the FFI hack. I think traits are better, generally speaking, and using |
48b8abf
to
a7b70d2
Compare
This comment has been minimized.
This comment has been minimized.
…h-ascription, r=davidtwco syntax: simplify maybe_annotate_with_ascription Split out from rust-lang#65324. r? @estebank
simplify maybe_stage_features Extracted from rust-lang#65324. r? @estebank
simplify integer_lit Extracted from rust-lang#65324. r? @davidtwco
mbe: reduce panictry! uses. Extracted from rust-lang#65324. r? @petrochenkov
syntax: consolidate function parsing in item.rs Extracted from rust-lang#65324. r? @estebank
This comment has been minimized.
This comment has been minimized.
a7b70d2
to
cd2c610
Compare
also move MACRO_ARGUMENTS -> librustc_parse
aea1fad
to
4ae2728
Compare
Done. I would propose |
@bors r+ |
📌 Commit 4ae2728 has been approved by |
The crate consists of:
|
👍 |
Split libsyntax apart In this PR the general idea is to separate the AST, parser, and friends by a more data / logic structure (tho not fully realized!) by separating out the parser and macro expansion code from libsyntax. Specifically have now three crates instead of one (libsyntax): - libsyntax: - concrete syntax tree (`syntax::ast`) - definition of tokens and token-streams (`syntax::{token, tokenstream}`) -- used by `syntax::ast` - visitors (`syntax::visit`, `syntax::mut_visit`) - shared definitions between `libsyntax_expand` - feature gating (`syntax::feature_gate`) -- we could possibly move this out to its own crater later. - attribute and meta item utilities, including used-marking (`syntax::attr`) - pretty printer (`syntax::print`) -- this should possibly be moved out later. For now I've reduced down the dependencies to a single essential one which could be broken via `ParseSess`. This entails that e.g. `Debug` impls for `Path` cannot reference the pretty printer. - definition of `ParseSess` (`syntax::sess`) -- this is used by `syntax::{attr, print, feature_gate}` and is a common definition used by the parser and other things like librustc. - the `syntax::source_map` -- this includes definitions used by `syntax::ast` and other things but could ostensibly be moved `syntax_pos` since that is more related to this module. - a smattering of misc utilities not sufficiently important to itemize -- some of these could be moved to where they are used (often a single place) but I wanted to limit the scope of this PR. - librustc_parse: - parser (`rustc_parse::parser`) -- reading a file and such are defined in the crate root tho. - lexer (`rustc_parse::lexer`) - validation of meta grammar (post-expansion) in (`rustc_parse::validate_attr`) - libsyntax_expand -- this defines the infra for macro expansion and conditional compilation but this is not libsyntax_ext; we might want to merge them later but currently libsyntax_expand is depended on by librustc_metadata which libsyntax_ext is not. - conditional compilation (`syntax_expand::config`) -- moved from `syntax::config` to here - the bulk of this crate is made up of the old `syntax::ext` r? @estebank
☀️ Test successful - checks-azure |
Fix breakage due to rust-lang/rust#65324 changelog: none
Rename some crates and modules in the frontend Migrate from `syntax_*` naming scheme to `rustc_*`. See #65324 (comment) and several comments below. Renamed crates: `syntax_expand` -> `rustc_expand` `syntax_pos` -> `rustc_span` ([motivation](#65324 (comment))) `syntax_ext` -> `rustc_builtin_macros` Also one module in resolve is renamed for consistency and to avoid tautology. r? @Centril
several mods from libsyntax have been split out into separate crates, including the `parse` mod rust-lang/rust#65324
In this PR the general idea is to separate the AST, parser, and friends by a more data / logic structure (tho not fully realized!) by separating out the parser and macro expansion code from libsyntax. Specifically have now three crates instead of one (libsyntax):
libsyntax:
concrete syntax tree (
syntax::ast
)definition of tokens and token-streams (
syntax::{token, tokenstream}
) -- used bysyntax::ast
visitors (
syntax::visit
,syntax::mut_visit
)shared definitions between
libsyntax_expand
feature gating (
syntax::feature_gate
) -- we could possibly move this out to its own crater later.attribute and meta item utilities, including used-marking (
syntax::attr
)pretty printer (
syntax::print
) -- this should possibly be moved out later. For now I've reduced down the dependencies to a single essential one which could be broken viaParseSess
. This entails that e.g.Debug
impls forPath
cannot reference the pretty printer.definition of
ParseSess
(syntax::sess
) -- this is used bysyntax::{attr, print, feature_gate}
and is a common definition used by the parser and other things like librustc.the
syntax::source_map
-- this includes definitions used bysyntax::ast
and other things but could ostensibly be movedsyntax_pos
since that is more related to this module.a smattering of misc utilities not sufficiently important to itemize -- some of these could be moved to where they are used (often a single place) but I wanted to limit the scope of this PR.
librustc_parse:
parser (
rustc_parse::parser
) -- reading a file and such are defined in the crate root tho.lexer (
rustc_parse::lexer
)validation of meta grammar (post-expansion) in (
rustc_parse::validate_attr
)libsyntax_expand -- this defines the infra for macro expansion and conditional compilation but this is not libsyntax_ext; we might want to merge them later but currently libsyntax_expand is depended on by librustc_metadata which libsyntax_ext is not.
conditional compilation (
syntax_expand::config
) -- moved fromsyntax::config
to herethe bulk of this crate is made up of the old
syntax::ext
r? @estebank