1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Identifier-shape helpers shared across the WIT emitter and the
//! core-module exporter.
//!
//! Both surfaces need the same source-level → wire-level rewriting for
//! identifiers so a function exported under `my_helper` in the IR
//! lines up with `my-helper` in the emitted WIT and the wasm export
//! section. Centralising the rewrite keeps the two paths in sync.
/// Convert a name to lower-kebab-case suitable as a WIT identifier
/// and as a wasm export name that wit-component will resolve against
/// the WIT.
///
/// Splits on existing case transitions: `MyType` → `my-type`,
/// `Pair` → `pair`, `XMLParser` → `x-m-l-parser`. Underscores collapse
/// into a single hyphen so `my_helper` → `my-helper`. Module-qualified
/// names (`colors::Rgb` produced by formalang's IR-lowering for
/// `pub mod` items) flatten to a single hyphen — `colors-rgb` — so
/// the result is a valid WIT identifier.
pub