|
1 | 1 | # Macro expansion
|
2 | 2 |
|
3 |
| -> `libsyntax`, `librustc_expand`, and `librustc_builtin_macros` are all undergoing |
| 3 | +> `librustc_ast`, `librustc_expand`, and `librustc_builtin_macros` are all undergoing |
4 | 4 | > refactoring, so some of the links in this chapter may be broken.
|
5 | 5 |
|
6 | 6 | Macro expansion happens during parsing. `rustc` has two parsers, in fact: the
|
@@ -361,24 +361,24 @@ be accessed from any Ident without any context) librustc_span/lib.rs - some
|
361 | 361 | secondary methods like macro backtrace using primary methods from hygiene.rs
|
362 | 362 | librustc_builtin_macros - implementations of built-in macros (including macro attributes
|
363 | 363 | and derives) and some other early code generation facilities like injection of
|
364 |
| -standard library imports or generation of test harness. libsyntax/config.rs - |
| 364 | +standard library imports or generation of test harness. librustc_ast/config.rs - |
365 | 365 | implementation of cfg/cfg_attr (they treated specially from other macros),
|
366 |
| -should probably be moved into libsyntax/ext. libsyntax/tokenstream.rs + |
367 |
| -libsyntax/parse/token.rs - structures for compiler-side tokens, token trees, |
368 |
| -and token streams. libsyntax/ext - various expansion-related stuff |
369 |
| -libsyntax/ext/base.rs - basic structures used by expansion |
370 |
| -libsyntax/ext/expand.rs - some expansion structures and the bulk of expansion |
| 366 | +should probably be moved into librustc_ast/ext. librustc_ast/tokenstream.rs + |
| 367 | +librustc_ast/parse/token.rs - structures for compiler-side tokens, token trees, |
| 368 | +and token streams. librustc_ast/ext - various expansion-related stuff |
| 369 | +librustc_ast/ext/base.rs - basic structures used by expansion |
| 370 | +librustc_ast/ext/expand.rs - some expansion structures and the bulk of expansion |
371 | 371 | infrastructure code - collecting macro invocations, calling into resolve for
|
372 | 372 | them, calling their expanding functions, and integrating the results back into
|
373 |
| -AST libsyntax/ext/placeholder.rs - the part of expand.rs responsible for |
| 373 | +AST librustc_ast/ext/placeholder.rs - the part of expand.rs responsible for |
374 | 374 | "integrating the results back into AST" basicallly, "placeholder" is a
|
375 | 375 | temporary AST node replaced with macro expansion result nodes
|
376 |
| -libsyntax/ext/builer.rs - helper functions for building AST for built-in macros |
| 376 | +librustc_ast/ext/builer.rs - helper functions for building AST for built-in macros |
377 | 377 | in librustc_builtin_macros (and user-defined syntactic plugins previously), can probably
|
378 |
| -be moved into librustc_builtin_macros these days libsyntax/ext/proc_macro.rs + |
379 |
| -libsyntax/ext/proc_macro_server.rs - interfaces between the compiler and the |
| 378 | +be moved into librustc_builtin_macros these days librustc_ast/ext/proc_macro.rs + |
| 379 | +librustc_ast/ext/proc_macro_server.rs - interfaces between the compiler and the |
380 | 380 | stable proc_macro library, converting tokens and token streams between the two
|
381 |
| -representations and sending them through C ABI libsyntax/ext/tt - |
| 381 | +representations and sending them through C ABI librustc_ast/ext/tt - |
382 | 382 | implementation of macro_rules, turns macro_rules DSL into something with
|
383 | 383 | signature Fn(TokenStream) -> TokenStream that can eat and produce tokens,
|
384 | 384 | @mark-i-m knows more about this librustc_resolve/macros.rs - resolving macro
|
@@ -408,8 +408,8 @@ piece of AST, etc), this is an enum that lists them
|
408 | 408 | ProcMacro/TTMacroExpander/AttrProcMacro/MultiItemModifier - traits representing
|
409 | 409 | the expander signatures (TODO: change and rename the signatures into something
|
410 | 410 | more consistent) trait Resolver - a trait used to break crate dependencies (so
|
411 |
| -resolver services can be used in libsyntax, despite librustc_resolve and pretty |
412 |
| -much everything else depending on libsyntax) ExtCtxt/ExpansionData - various |
| 411 | +resolver services can be used in librustc_ast, despite librustc_resolve and pretty |
| 412 | +much everything else depending on librustc_ast) ExtCtxt/ExpansionData - various |
413 | 413 | intermediate data kept and used by expansion infra in the process of its work
|
414 | 414 | AstFragment - a piece of AST that can be produced by a macro (may include
|
415 | 415 | multiple homogeneous AST nodes, like e.g. a list of items) Annotatable - a
|
|
0 commit comments