[−][src]Module c2rust_refactor::collapse
Macro collapsing - the opposite of macro expansion.
There are four ASTs we care about:
- Unexpanded: the original AST before macro expansion
- Expanded: the immediate result of macro expansion, with no further edits
- Transformed: the result of applying an arbitrary AST transformation to
expanded
- Collapsed:
transformed
, but with macro-generated code turned back into macro invocations
The general idea here is to compute some kind of delta between unexpanded
and expanded
,
then apply that in reverse to turn transformed
into collapsed
, with some adjustments so we
don't lose all the changes that were made to turn expanded
into transformed
.
Though most of the code and comments talk about "macros", we really mean everything that gets
processed during macro expansion, which includes regular macros, proc macros (format!
, etc.),
certain attributes (#[derive]
, #[cfg]
), and std
/prelude injection.
Structs
CollapseInfo | |
MacInfo | |
MacTable |
Functions
collapse_injected | Reverse the effect of |
collapse_macros | |
collect_cfg_attrs | |
collect_deleted_nodes | Collect info on all nodes deleted from (unexpanded) |
collect_macro_invocations | |
match_nonterminal_ids | Match up IDs of pre-expansion |
restore_cfg_attrs | |
restore_deleted_nodes | Restore deleted nodes into the collapsed |