Expand description
Machinery for hygienic macros.
Inspired by Matthew Flatt et al., “Macros That Work Together: Compile-Time Bindings, Partial Expansion, and Definition Contexts,” Journal of Functional Programming 22, no. 2 (March 1, 2012): 181–216, https://doi.org/10.1017/S0956796812000093.
Structs§
- Expn
Data - A subset of properties from both macro definition and macro call available through global data. Avoid using this if you have access to the original definition or call structures.
- Expn
Hash - A unique hash value associated to an expansion.
- ExpnId
- A unique ID associated with a macro invocation and expansion.
- Expn
Index - A unique ID associated with a macro invocation and expansion.
- Hygiene
Data 🔒 - Hygiene
Decode Context - Additional information used to assist in decoding hygiene data
- Hygiene
Encode Context - Hygiene
Remapping Results - Local
Expn Id - A unique ID associated with a macro invocation and expansion.
- Local
Expn IdRemapper - Syntax
Context - A
SyntaxContextrepresents a chain of pairs(ExpnId, Transparency)named “marks”. - Syntax
Context 🔒Data - Syntax
Context Remapper
Enums§
- AstPass
- The kind of AST transform.
- Desugaring
Kind - The kind of compiler desugaring.
- Expn
Kind - Expansion kind.
- Macro
Kind - The kind of macro invocation or definition.
- Transparency
- A property of a macro expansion that determines how identifiers produced by that expansion are resolved.
Traits§
- Hygiene
Remapper - Includes common logic for remapping both expansion ids and syntax contexts. FIXME: this solution does not take into account syntax contexts and expansion ids that are allocated during metadata encoding, if we will have non-determinism there this remapping will not help as it is constructed before metadata encoding.
Functions§
- debug_
hygiene_ data - decode_
expn_ id - Decode an expansion from the metadata of a foreign crate.
- decode_
syntax_ context - register_
expn_ id - Register an expansion which has been decoded from the metadata of a foreign crate.
- register_
local_ expn_ id - Register an expansion which has been decoded from the on-disk-cache for the local crate.
- update_
disambiguator 🔒 - Updates the
disambiguatorfield of the correspondingExpnDatasuch that theFingerprintof theExpnDatadoes not collide with any otherExpnIds. - update_
dollar_ crate_ names - walk_
chain - walk_
chain_ collapsed - In order to have good line stepping behavior in debugger, for the given span we return its
outermost macro call site that still has a
#[collapse_debuginfo(yes)]property on it. We also stop walking call sites at the function body level because no line stepping can occur at the level above that. The returned span can then be used in emitted debuginfo.
Type Aliases§
- Syntax
Context Key - If this part of two syntax contexts is equal, then the whole syntax contexts should be equal. The other fields are only for caching.