diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt index cd362acccf..3b0c090e9b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt @@ -74,14 +74,14 @@ class StreamingShapeMetadataProvider( override fun structureMeta(structureShape: StructureShape): RustMetadata { val baseMetadata = base.toSymbol(structureShape).expectRustMetadata() return if (structureShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq) + baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq, RuntimeType.Eq) } else baseMetadata } override fun unionMeta(unionShape: UnionShape): RustMetadata { val baseMetadata = base.toSymbol(unionShape).expectRustMetadata() return if (unionShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq) + baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq, RuntimeType.Eq) } else baseMetadata } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt index 781014bd85..e67d1cf460 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt @@ -198,6 +198,7 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n val From = RuntimeType("From", dependency = null, namespace = "std::convert") val TryFrom = RuntimeType("TryFrom", dependency = null, namespace = "std::convert") val PartialEq = std.member("cmp::PartialEq") + val Eq = std.member("cmp::Eq") val StdError = RuntimeType("Error", dependency = null, namespace = "std::error") val String = RuntimeType("String", dependency = null, namespace = "std::string") diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt index 8c5a56b577..4781c44b52 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt @@ -131,7 +131,7 @@ class BaseSymbolMetadataProvider( companion object { private val defaultDerives by lazy { with(RuntimeType) { - listOf(Debug, PartialEq, Clone) + listOf(Debug, PartialEq, Eq, Clone) } } } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt index c561b04c39..7d77a00b46 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt @@ -160,7 +160,7 @@ class BuilderGenerator( writer.docs("A builder for #D.", structureSymbol) // Matching derives to the main structure + `Default` since we are a builder and everything is optional. val baseDerives = structureSymbol.expectRustMetadata().derives - val derives = baseDerives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Clone)) + RuntimeType.Default + val derives = baseDerives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Eq, RuntimeType.Clone)) + RuntimeType.Default baseDerives.copy(derives = derives).render(writer) writer.rustBlock("pub struct $builderName") { for (member in members) { diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt index 1e6f2b7ea8..dc9ca9f153 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt @@ -95,14 +95,14 @@ class PythonStreamingShapeMetadataProvider(private val base: RustSymbolProvider, override fun structureMeta(structureShape: StructureShape): RustMetadata { val baseMetadata = base.toSymbol(structureShape).expectRustMetadata() return if (structureShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.PartialEq) + baseMetadata.withoutDerives(RuntimeType.PartialEq, RuntimeType.Eq) } else baseMetadata } override fun unionMeta(unionShape: UnionShape): RustMetadata { val baseMetadata = base.toSymbol(unionShape).expectRustMetadata() return if (unionShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.PartialEq) + baseMetadata.withoutDerives(RuntimeType.PartialEq, RuntimeType.Eq) } else baseMetadata }