Skip to content

Commit abd6e8c

Browse files
author
Fahad Zubair
committed
Some issues fixed for non-public constrained types
1 parent 1c3edd7 commit abd6e8c

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ConstrainedShapeSymbolProvider.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,15 @@ class ConstrainedShapeSymbolProvider(
168168
} else {
169169
// For List, Union and Map, the new shape defined for a constrained member shape
170170
// need to be placed into an inline module named `pub {container_name_in_snake_case}`
171-
val innerModuleName = RustReservedWords.escapeIfNeeded(container.id.name.toSnakeCase())
171+
val innerModuleName = RustReservedWords.escapeIfNeeded(container.id.name.toSnakeCase()) + if (pubCrateServerBuilder) {
172+
"_internal"
173+
} else {
174+
""
175+
}
176+
172177
val innerModule = RustModule.new(
173178
innerModuleName,
174-
visibility = if (pubCrateServerBuilder) Visibility.PUBLIC else Visibility.PUBCRATE,
179+
visibility = Visibility.publicIf(!pubCrateServerBuilder, Visibility.PUBCRATE),
175180
parent = defaultModule,
176181
inline = true,
177182
)

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/Constraints.kt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fun Shape.getParentAndInlineModuleForConstrainedMember(symbolProvider: SymbolPro
199199
else {
200200
// For constrained member shapes, the ConstraintViolation code needs to go in an inline rust module
201201
// that is a descendant of the module that contains the extracted shape itself.
202-
if (!pubCrateServerBuilder) {
202+
return if (!pubCrateServerBuilder) {
203203
// List, union and map types need to go into their own module
204204
val shapeSymbol = symbolProvider.toSymbol(this)
205205
val shapeModule = shapeSymbol.module()
@@ -209,18 +209,15 @@ fun Shape.getParentAndInlineModuleForConstrainedMember(symbolProvider: SymbolPro
209209
Pair(shapeModule.parent as RustModule.LeafModule, shapeModule)
210210
}
211211
else {
212-
TODO()
212+
val name = RustReservedWords.escapeIfNeeded(overriddenTrait.container.id.name).toSnakeCase() + "_internal"
213+
val innerModule = RustModule.new(
214+
name = name,
215+
visibility = Visibility.PUBCRATE,
216+
parent = ModelsModule,
217+
inline = true,
218+
)
219+
220+
Pair(ModelsModule, innerModule)
213221
}
214-
// else {
215-
// val name = RustReservedWords.escapeIfNeeded(overriddenTrait.container.contextName(serviceShape)).toSnakeCase()
216-
// val innerModule = RustModule.new(
217-
// name = name,
218-
// visibility = Visibility.PUBCRATE,
219-
// parent = ModelsModule,
220-
// inline = true,
221-
// )
222-
//
223-
// Pair(ModelsModule, innerModule)
224-
// }
225222
}
226223
}

0 commit comments

Comments
 (0)