You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the first enum generated has the @sensitive trait the opaque type
underlying the Unknown variant inherits that sensitivity. This means that
it does not derive Debug. Since the module is only generated once this
causes a problem for non-sensitive enums that rely on the type deriving
Debug so that they can also derive Debug.
Copy file name to clipboardExpand all lines: codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientEnumGenerator.kt
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -194,7 +194,12 @@ data class InfallibleEnumType(
194
194
This is not intended to be used directly.
195
195
""".trimIndent(),
196
196
)
197
-
context.enumMeta.render(this)
197
+
198
+
// The UnknownVariant's underlying opaque type should always derive `Debug`. If this isn't explicitly
199
+
// added and the first enum to render this module has the `@sensitive` trait then the UnknownVariant
200
+
// inherits that sensitivity and does not derive `Debug`. This leads to issues deriving `Debug` for
201
+
// all enum variants that are not marked `@sensitive`.
Copy file name to clipboardExpand all lines: codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientEnumGeneratorTest.kt
+49Lines changed: 49 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -106,6 +106,55 @@ class ClientEnumGeneratorTest {
106
106
project.compileAndTest()
107
107
}
108
108
109
+
// The idempotency of RustModules paired with Smithy's alphabetic order shape iteration meant that
110
+
// if an @sensitive enum was the first enum generated that the opaque type underlying the Unknown
111
+
// variant would not derive Debug, breaking all non-@sensitive enums
112
+
@Test
113
+
fun`sensitive enum in earlier alphabetic order does not break non-sensitive enums`() {
114
+
val model =
115
+
"""
116
+
namespace test
117
+
118
+
@sensitive
119
+
@enum([
120
+
{ name: "Foo", value: "Foo" },
121
+
{ name: "Bar", value: "Bar" },
122
+
])
123
+
string FooA
124
+
125
+
@enum([
126
+
{ name: "Baz", value: "Baz" },
127
+
{ name: "Ahh", value: "Ahh" },
128
+
])
129
+
string FooB
130
+
""".asSmithyModel()
131
+
132
+
val shapeA = model.lookup<StringShape>("test#FooA")
133
+
val shapeB = model.lookup<StringShape>("test#FooB")
134
+
val context = testClientCodegenContext(model)
135
+
val project =TestWorkspace.testProject(context.symbolProvider)
0 commit comments