-
Notifications
You must be signed in to change notification settings - Fork 214
Description
In #2256, we introduced RustCrateInlineModuleComposingWriter.kt
, containing utilities to render code in the same Rust module from different callsites in the code generator. This was done to enable constraint trait precedence, to render member shapes in the same module where the builder for the structure shape is hosted, all in the same model.rs
file:
structure A {
@length(max: 70)
member: LengthString
}
structure B {
@length(max: 70)
member: LengthString
}
@length(max: 69)
string LengthString
Yields in model.rs
:
struct A {
member: a::Member
}
struct B {
member: b::Member
}
pub mod a {
struct Builder { ... }
struct Member(pub(crate) String);
}
pub mod b {
struct Builder { ... }
struct Member(pub(crate) String);
}
In retrospect, this has had rippling effects throughout the codebase that make it more difficult to maintain. We could have dispensed with RustCrateInlineModuleComposingWriter
, and it would have been simpler if we had just rendered each module in separate files:
model.rs
:
struct A {
member: a::Member
}
struct B {
member: b::Member
}
a.rs
:
struct Builder { ... }
struct Member(pub(crate) String);
b.rs
:
struct Builder { ... }
struct Member(pub(crate) String);
This issue tracks the work needed to remove RustCrateInlineModuleComposingWriter
. Note that now builders will go in a builders
module as per #2455, so when tackling this issue one should keep that in mind.