pub fn module_init_unit<'a>(module: &'a Module<'a>) -> Option<FnUnit<'a>>Expand description
Build a synthetic FnUnit representing a module’s top-level initialisation
code — the statements that execute when the module is first imported.
The unit gets symbol "<module>", line = 1, col = 1, and
body = FnBody::Module(&module.body). is_root is always false at the
frontend level — the CLI sets the real value for explicit-file entries.
Own-body semantics are preserved: the own-body walker walks each top-level
statement but does NOT descend into nested def/class bodies (those are
separate units). Import statements (import, from … import) have no own-body
runtime effect and are simply skipped by the detectors’ walk_small
(Pass/Import/ImportFrom/Global/Nonlocal → no-op arm).
Returns None when the module has no top-level executable statements (e.g.
a module containing only import declarations and function/class definitions),
because the caller will score first and skip emission when there are no effects
— returning None early avoids building empty units. Callers should additionally
skip emitting the resulting Hotspot when hotspot.effects.is_empty().