Module ra_ap_hir_expand::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.

Also see https://rustc-dev-guide.rust-lang.org/macro-expansion.html#hygiene-and-hierarchies

§The Expansion Order Hierarchy

ExpnData in rustc, rust-analyzer’s version is [MacroCallLoc]. Traversing the hierarchy upwards can be achieved by walking up [MacroCallLoc::kind]’s contained file id, as [MacroFile]s are interned [MacroCallLoc]s.

§The Macro Definition Hierarchy

SyntaxContextData in rustc and rust-analyzer. Basically the same in both.

§The Call-site Hierarchy

ExpnData::call_site in rustc, [MacroCallLoc::call_site] in rust-analyzer.

Enums§

  • A property of a macro expansion that determines how identifiers produced by that expansion are resolved.

Traits§

Functions§