rustc_span

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ยง

  • 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.
  • A unique hash value associated to an expansion.
  • A unique ID associated with a macro invocation and expansion.
  • A unique ID associated with a macro invocation and expansion.
  • HygieneData ๐Ÿ”’
  • Additional information used to assist in decoding hygiene data
  • Additional information used to assist in decoding hygiene data
  • A unique ID associated with a macro invocation and expansion.
  • A SyntaxContext represents a chain of pairs (ExpnId, Transparency) named โ€œmarksโ€.

Enumsยง

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

Functionsยง

  • 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.
  • Decode an expansion from the metadata of a foreign crate.
  • for_all_ctxts_in ๐Ÿ”’
  • for_all_expns_in ๐Ÿ”’
  • Register an expansion which has been decoded from the metadata of a foreign crate.
  • Register an expansion which has been decoded from the on-disk-cache for the local crate.
  • Updates the disambiguator field of the corresponding ExpnData such that the Fingerprint of the ExpnData does not collide with any other ExpnIds.
  • 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.