Module hygiene

Source
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§

ExpnData
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.
ExpnHash
A unique hash value associated to an expansion.
ExpnId
A unique ID associated with a macro invocation and expansion.
ExpnIndex
A unique ID associated with a macro invocation and expansion.
HygieneData 🔒
HygieneDecodeContext
Additional information used to assist in decoding hygiene data
HygieneDecodeContextInner 🔒
Additional information used to assist in decoding hygiene data
HygieneEncodeContext
LocalExpnId
A unique ID associated with a macro invocation and expansion.
SyntaxContext
A SyntaxContext represents a chain of pairs (ExpnId, Transparency) named “marks”.
SyntaxContextData

Enums§

AstPass
The kind of AST transform.
DesugaringKind
The kind of compiler desugaring.
ExpnKind
Expansion kind.
MacroKind
The kind of macro invocation or definition.
Transparency
A property of a macro expansion that determines how identifiers produced by that expansion are resolved.

Functions§

assert_default_hashing_controls 🔒
Assert that the provided HashStableContext is configured with the ‘default’ HashingControls. We should always have bailed out before getting to here with a non-default mode. With this check in place, we can avoid the need to maintain separate versions of ExpnData hashes for each permutation of HashingControls settings.
debug_hygiene_data
decode_expn_id
Decode an expansion from the metadata of a foreign crate.
decode_syntax_context
for_all_ctxts_in 🔒
for_all_expns_in 🔒
raw_encode_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 disambiguator field of the corresponding ExpnData such that the Fingerprint of the ExpnData does not collide with any other ExpnIds.
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.