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::files::AstId;
pub use crate::files::ErasedAstId;
pub use crate::files::FileRange;
pub use crate::files::InFile;
pub use crate::files::InMacroFile;
pub use crate::files::InRealFile;
pub use intern;
Modules§
- attrs
- A higher level attributes based on TokenTree, with also some shortcuts.
- builtin
- Builtin macros and attributes
- change
- Defines a unit of change that can applied to the database to get the next state. Changes are transactional.
- db
- Defines database & queries for macro expansion.
- declarative
- Compiled declarative macro expanders (
macro_rules!
andmacro
) - eager
- Eager expansion related utils
- files
- Things to wrap other things in file ids.
- hygiene
- Machinery for hygienic macros.
- inert_
attr_ macro - Builtin attributes resolved by nameres.
- mod_
path - A lowering for
use
-paths (more generally, paths without angle-bracketed segments). - name
- See
Name
. - proc_
macro - Proc Macro Expander stuff
- span_
map - Span maps for real files and macro expansions.
- tt
Macros§
- __
known_ path - __path
- __
tool_ path - impl_
intern_ lookup - quote
- FIXME: It probably should implement in proc-macro
Structs§
- Declarative
Macro - This struct contains AST for a single
macro_rules
definition. What might be very confusing is that AST has almost exactly the same shape astt::TokenTree
, but there’s a crucial difference: in macro rules,$ident
and$()*
have special meaning (seeVar
andRepeat
data structures) - Eager
Call Info - Editioned
File Id - Expand
Error - Expansion
Info - ExpansionInfo mainly describes how to map text range between src and expanded macro
- Macro
Call Id - Macro
Call Loc - Macro
DefId - Rendered
Expand Error - Value
Result
Enums§
- Expand
Error Kind - Expand
To - 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
foo
can be a type, an expression, or a pattern. - HirFile
Id - Macro
Call Kind - Macro
DefKind - Macro
Kind
Traits§
Functions§
- check_
cfg_ attr_ value - map_
node_ range_ up - Maps up the text range out of the expansion hierarchy back into the original file its from.
- map_
node_ range_ up_ aggregated - Maps up the text range out of the expansion hierarchy back into the original file its from. This version will aggregate the ranges of all spans with the same anchor and syntax context.
- map_
node_ range_ up_ rooted - Maps up the text range out of the expansion hierarchy back into the original file its from only
considering the root spans contained.
Unlike
map_node_range_up
, this will not returnNone
if any anchors or syntax contexts differ. - prettify_
macro_ expansion - Inserts whitespace and replaces
$crate
in macro expansions. - span_
for_ offset - Looks up the span at the given offset.