Crate ra_ap_hir_expand
source ·Expand description
hir_expand deals with macro expansion.
Specifically, it implements a concept of MacroFile – a file whose syntax
tree originates not from the text of some FileId, but from some macro
expansion.
Re-exports
pub use crate::ast_id_map::AstId;pub use crate::ast_id_map::ErasedAstId;pub use crate::files::InFile;pub use crate::files::InMacroFile;pub use crate::files::InRealFile;
Modules
AstIdMapallows to create stable IDs for “large” syntax nodes like items and macro calls.- A higher level attributes based on TokenTree, with also some shortcuts.
- Builtin attributes.
- Builtin derives.
- Builtin macro
- Defines a unit of change that can applied to the database to get the next state. Changes are transactional.
- Defines database & queries for macro expansion.
- Eager expansion related utils
- Things to wrap other things in file ids.
- This modules handles hygiene information.
- A lowering for
use-paths (more generally, paths without angle-bracketed segments). - See
Name. - Proc Macro Expander stub
- A simplified version of quote-crate like quasi quote macro
- Span maps for real files and macro expansions.
Macros
- FIXME: It probably should implement in proc-macro
Structs
- ExpansionInfo mainly describes how to map text range between src and expanded macro
- Input to the analyzer is a set of files, where each file is identified by
FileIdand contains source code. However, another source of source code in Rust are macros: each macro can be thought of as producing a “temporary file”. To assign an id to such a file, we use the id of the macro call that produced the file. So, aHirFileIdis either aFileId(source code written by user), or aMacroCallId(source code produced by macro). MacroCallIdidentifies a particular macro invocation, likeprintln!("Hello, {}", world).
Enums
- In Rust, macros expand token trees to token trees. When we want to turn a token tree into an AST node, we need to figure out what kind of AST node we want: something like
foocan be a type, an expression, or a pattern.