expand_module_with

Function expand_module_with 

Source
pub fn expand_module_with(
    module: &Node,
    imported: &[&Node],
    diags: &mut Diagnostics,
) -> Node
Expand description

The same, with the macros of the modules this one imports in scope.

docs/02 §2.4: a macro is a declaration like any other, and a module that imports another gets its declarations. Until this existed a macro was usable in the file that declared it and nowhere else — not refused, simply absent — which is what kept §2.4’s derive and §2.5’s sql"…" out of lib/ and made every macro an example rather than a facility.

imported are the parsed modules, in any order: a macro body is compile-time callable as it was written, before expansion, so what a macro needs from another module is its source and not its interface. That is also the limit — an import that is an interface and no implementation publishes signatures, and a macro has none.

Names are merged flat, which is the language’s own model rather than a shortcut here: Beck links modules into one namespace with no qualified reference (B0601), so a macro imported from one module and a macro declared in this one collide exactly as two defs of one name do, and B0200 is what says so.