Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generation of constrained shapes reaching @sensitive shapes #2585

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ message = "`aws_smithy_types::date_time::Format` has been re-exported in service
references = ["smithy-rs#2534"]
meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" }
author = "ysaito1001"

[[smithy-rs]]
message = "Fix generation of constrained shapes reaching `@sensitive` shapes"
references = ["smithy-rs#2582", "smithy-rs#2585"]
meta = { "breaking" = false, "tada" = false, "bug" = true, "target" = "server" }
author = "david-perez"
9 changes: 9 additions & 0 deletions codegen-core/common-test-models/constraints.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ structure ConA {

conBList: ConBList,
lengthList: LengthList,
sensitiveLengthList: SensitiveLengthList,

conBSet: ConBSet,

Expand Down Expand Up @@ -866,6 +867,14 @@ list LengthList {
member: String
}

@length(max: 69)
list SensitiveLengthList {
member: SensitiveStructure
}

@sensitive
structure SensitiveStructure { }

set ConBSet {
member: ConBSetInner
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import software.amazon.smithy.model.shapes.StructureShape
import software.amazon.smithy.model.shapes.UnionShape
import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata
import software.amazon.smithy.rust.codegen.core.rustlang.Visibility
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType
import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider
import software.amazon.smithy.rust.codegen.core.smithy.SymbolMetadataProvider
import software.amazon.smithy.rust.codegen.core.smithy.containerDefaultMetadata
Expand Down Expand Up @@ -47,6 +48,11 @@ class ConstrainedShapeSymbolMetadataProvider(
derives += containerDefaultMetadata(shape, model).derives
}

// We should _always_ be able to `#[derive(Debug)]`: all constrained shapes' types are simply tuple newtypes
// wrapping a single type which always implements `Debug`.
// The wrapped type may not _derive_ `Debug` though, hence why this line is required; see https://github.com/awslabs/smithy-rs/issues/2582.
derives += RuntimeType.Debug

val visibility = Visibility.publicIf(constrainedTypes, Visibility.PUBCRATE)
return RustMetadata(derives, additionalAttributes, visibility)
}
Expand Down