From ac05ffd822bb1507aee660d678ad568194d22d87 Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Wed, 12 May 2021 15:48:44 -0400 Subject: [PATCH] Serialize Sets with Vecs (#270) * Remove non-determinism and use Vecs always instead of Sets * Remove special casing for sets --- .../smithy/rust/codegen/rustlang/RustTypes.kt | 4 ++-- .../generators/HttpProtocolTestGenerator.kt | 7 +------ .../codegen/smithy/generators/Instantiator.kt | 18 +----------------- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/RustTypes.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/RustTypes.kt index 8201363f0..45a630be9 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/RustTypes.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/RustTypes.kt @@ -68,8 +68,8 @@ sealed class RustType { override val namespace = Namespace companion object { - const val Type = "BTreeSet" - const val Namespace = "std::collections" + const val Type = "Vec" + const val Namespace = "std::vec" val RuntimeType = RuntimeType(name = Type, namespace = Namespace, dependency = null) } } diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/HttpProtocolTestGenerator.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/HttpProtocolTestGenerator.kt index 13b64e404..e9d1dca81 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/HttpProtocolTestGenerator.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/HttpProtocolTestGenerator.kt @@ -422,11 +422,6 @@ class HttpProtocolTestGenerator( // These tests are not even attempted to be compiled, either because they will not compile // or because they are flaky - private val DisableTests = setOf( - // This test is flaky because of set ordering serialization https://github.com/awslabs/smithy-rs/issues/37 - "AwsJson11Enums", - "RestJsonJsonEnums", - "RestJsonLists" - ) + private val DisableTests = setOf() } } diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/Instantiator.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/Instantiator.kt index 87abb00a7..085961666 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/Instantiator.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/Instantiator.kt @@ -162,23 +162,7 @@ class Instantiator( } private fun renderSet(writer: RustWriter, shape: SetShape, data: ArrayNode, ctx: Ctx) { - if (symbolProvider.toSymbol(shape).rustType() is RustType.HashSet) { - if (!data.isEmpty) { - writer.rustBlock("") { - write("let mut ret = #T::new();", RustType.HashSet.RuntimeType) - data.forEach { v -> - withBlock("ret.insert(", ");") { - renderMember(this, shape.member, v, ctx) - } - } - write("ret") - } - } else { - writer.write("#T::new()", RustType.HashSet.RuntimeType) - } - } else { - renderList(writer, shape, data, ctx) - } + renderList(writer, shape, data, ctx) } /** -- GitLab