Skip to main content

Module rename

Module rename 

Source
Expand description

Resolution of top-level type names across the lowered IR.

A generated type name differs from the plain to_ident(schema_name) for two reasons. The schema carries an x-rust-name override, or two schema names collapse onto one Rust identifier and the config supplies a suffix. Every reference to a schema lowers to a RustType::Named that holds the original schema name. Name resolution therefore must also rewrite those references to point at the final identifier. Lowering sets the item names from the same resolution map. See crate::lower::schema. This pass rewrites the Named references that still point at the original name.

An unresolved collision is not reported here. Default pruning drops a schema that no operation uses, and a collision between two dropped schemas never reaches the output. type_renames therefore returns the collisions it found, and the caller reports them when the set of emitted models is final.

Structs§

TypeNames
The final Rust type name of every top-level schema, together with each collision that still needs a decision from the author.

Functions§

check_duplicate_models
Fail generation if two items of module take one Rust type name.
check_prelude_shadowing
Fail generation if an emitted item takes the name of a prelude type that the file names without a path.
check_type_name_collisions
Fail generation if two items that the file holds take one Rust type name.
rewrite_module
Rewrite every Named reference in module’s items to honour renames.
rewrite_service
Rewrite every Named reference in service’s operations to honour renames.
type_renames
Resolve the Rust type name of every top-level schema in spec.