Skip to content

Commit 5169bd9

Browse files
committed
Add Eq for generated types that implement PartialEq
1 parent 3da634a commit 5169bd9

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ class StreamingShapeMetadataProvider(
7474
override fun structureMeta(structureShape: StructureShape): RustMetadata {
7575
val baseMetadata = base.toSymbol(structureShape).expectRustMetadata()
7676
return if (structureShape.hasStreamingMember(model)) {
77-
baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq)
77+
baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq, RuntimeType.Eq)
7878
} else baseMetadata
7979
}
8080

8181
override fun unionMeta(unionShape: UnionShape): RustMetadata {
8282
val baseMetadata = base.toSymbol(unionShape).expectRustMetadata()
8383
return if (unionShape.hasStreamingMember(model)) {
84-
baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq)
84+
baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq, RuntimeType.Eq)
8585
} else baseMetadata
8686
}
8787

codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n
198198
val From = RuntimeType("From", dependency = null, namespace = "std::convert")
199199
val TryFrom = RuntimeType("TryFrom", dependency = null, namespace = "std::convert")
200200
val PartialEq = std.member("cmp::PartialEq")
201+
val Eq = std.member("cmp::Eq")
201202
val StdError = RuntimeType("Error", dependency = null, namespace = "std::error")
202203
val String = RuntimeType("String", dependency = null, namespace = "std::string")
203204

codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class BaseSymbolMetadataProvider(
131131
companion object {
132132
private val defaultDerives by lazy {
133133
with(RuntimeType) {
134-
listOf(Debug, PartialEq, Clone)
134+
listOf(Debug, PartialEq, Eq, Clone)
135135
}
136136
}
137137
}

codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class BuilderGenerator(
160160
writer.docs("A builder for #D.", structureSymbol)
161161
// Matching derives to the main structure + `Default` since we are a builder and everything is optional.
162162
val baseDerives = structureSymbol.expectRustMetadata().derives
163-
val derives = baseDerives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Clone)) + RuntimeType.Default
163+
val derives = baseDerives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Eq, RuntimeType.Clone)) + RuntimeType.Default
164164
baseDerives.copy(derives = derives).render(writer)
165165
writer.rustBlock("pub struct $builderName") {
166166
for (member in members) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ class PythonStreamingShapeMetadataProvider(private val base: RustSymbolProvider,
9595
override fun structureMeta(structureShape: StructureShape): RustMetadata {
9696
val baseMetadata = base.toSymbol(structureShape).expectRustMetadata()
9797
return if (structureShape.hasStreamingMember(model)) {
98-
baseMetadata.withoutDerives(RuntimeType.PartialEq)
98+
baseMetadata.withoutDerives(RuntimeType.PartialEq, RuntimeType.Eq)
9999
} else baseMetadata
100100
}
101101

102102
override fun unionMeta(unionShape: UnionShape): RustMetadata {
103103
val baseMetadata = base.toSymbol(unionShape).expectRustMetadata()
104104
return if (unionShape.hasStreamingMember(model)) {
105-
baseMetadata.withoutDerives(RuntimeType.PartialEq)
105+
baseMetadata.withoutDerives(RuntimeType.PartialEq, RuntimeType.Eq)
106106
} else baseMetadata
107107
}
108108

0 commit comments

Comments
 (0)