pub fn collect_public_symbol_modules(
modules: &[(&AIRModule, &Path)],
) -> HashMap<String, String>Expand description
Build a map from every public top-level symbol name declared across
modules to the dotted declared module-path that declares it (e.g.
Iterable → core.iter). Covers functions, records, enums (the type
name), traits, classes, effects, type aliases, and consts.
The per-module native-module path needs this for implicit imports: a
§18.2-prelude trait used as an impl base (impl Iterable for Bag, with
Iterable auto-imported per §18.2) is referenced without an explicit use.
Emitting one file per module means the consuming main.rs must
use crate::core::iter::Iterable; even though Iterable never appears in
an explicit use. (Go keeps one package across files, so a same-package
symbol is visible without an import; Go uses this map only to know which
names are cross-module, not to emit anything.) The map lets the backend add
exactly those Rust uses for names a module references but neither declares
locally nor imports explicitly.
Enum variants are intentionally not recorded as separate symbols:
Rust accesses a variant through its type (Ordering::Less), so importing
the enum type suffices, and a synthetic Ordering_Less is not a real Rust
item to use. Go (same-package) needs no imports at all.
The first declarer wins for a name declared in several modules (the
dependency order modules arrives in is deterministic — see
reachable_modules).