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

Derive Eq and Hash wherever possible #2223

Merged
merged 17 commits into from
Jan 19, 2023
Merged

Commits on Jan 17, 2023

  1. Derive Eq and Hash

    david-perez committed Jan 17, 2023
    Configuration menu
    Copy the full SHA
    885eb9d View commit details
    Browse the repository at this point in the history

Commits on Jan 18, 2023

  1. Configuration menu
    Copy the full SHA
    cb1cd73 View commit details
    Browse the repository at this point in the history
  2. Cleanup

    david-perez committed Jan 18, 2023
    Configuration menu
    Copy the full SHA
    2a0f67c View commit details
    Browse the repository at this point in the history
  3. Cleanup

    david-perez committed Jan 18, 2023
    Configuration menu
    Copy the full SHA
    7fb08a6 View commit details
    Browse the repository at this point in the history
  4. More cleanup

    david-perez committed Jan 18, 2023
    Configuration menu
    Copy the full SHA
    e478aef View commit details
    Browse the repository at this point in the history
  5. ./gradlew ktlintFormat

    david-perez committed Jan 18, 2023
    Configuration menu
    Copy the full SHA
    40aa12f View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    e754681 View commit details
    Browse the repository at this point in the history
  7. Derive Eq and Hash wherever possible

    In server SDKs, these traits can be implemented by any shape _except_ if
    the shape's closure contains:
    
    1. A `float`, `double`, or `document` shape: floating point types in
       Rust do not implement `Eq`. Similarly, [`document` shapes] may
       contain arbitrary JSON-like data containing floating point values.
    2. A [@streaming] shape: all the streaming data would need to be
       buffered first to compare it.
    
    Additionally, the `Hash` trait cannot be implemented by shapes whose
    closure contains:
    
    1. A `map` shape: we render `map` shapes as `std::collections::HashMap`,
       which _do not_ implement `Hash`. See
       smithy-lang/smithy#1567.
    
    In **client SDKs, these traits cannot be derived on any code-generated
    Rust types corresponding to Smithy shapes**, since e.g. adding new
    optional members to a structure [is a backwards-compatible change], and
    doing so alters the semantics of these traits.
    
    However, this commit does implement these traits for the
    `aws_smithy_types::date_time::DateTime` and `aws_smithy_types::Blob`
    runtime types.
    
    This change is necessary to efficiently implement the `@uniqueItems`
    constraint trait in server SDKs.
    
    [`Eq`]: https://doc.rust-lang.org/std/cmp/trait.Eq.html
    [`Hash`]: https://doc.rust-lang.org/std/hash/trait.Hash.html
    [`document` shapes]: https://smithy.io/2.0/spec/simple-types.html#document
    [@streaming]: https://smithy.io/2.0/spec/streaming.html
    [is a backwards-compatible change]: https://smithy.io/2.0/guides/evolving-models.html#updating-structures
    david-perez committed Jan 18, 2023
    Configuration menu
    Copy the full SHA
    373a1ec View commit details
    Browse the repository at this point in the history
  8. Fix tests

    david-perez committed Jan 18, 2023
    Configuration menu
    Copy the full SHA
    f1f5f8f View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    8e24132 View commit details
    Browse the repository at this point in the history
  10. Update changelog

    david-perez committed Jan 18, 2023
    Configuration menu
    Copy the full SHA
    fa929a6 View commit details
    Browse the repository at this point in the history
  11. Derive Eq and Hash wherever possible

    In server SDKs, these traits can be implemented by any shape _except_ if
    the shape's closure contains:
    
    1. A `float`, `double`, or `document` shape: floating point types in
       Rust do not implement `Eq`. Similarly, [`document` shapes] may
       contain arbitrary JSON-like data containing floating point values.
    2. A [@streaming] shape: all the streaming data would need to be
       buffered first to compare it.
    
    Additionally, the `Hash` trait cannot be implemented by shapes whose
    closure contains:
    
    1. A `map` shape: we render `map` shapes as `std::collections::HashMap`,
       which _do not_ implement `Hash`. See
       smithy-lang/smithy#1567.
    
    In **client SDKs, these traits cannot be derived on any code-generated
    Rust types corresponding to Smithy shapes**, since e.g. adding new
    optional members to a structure [is a backwards-compatible change], and
    doing so alters the semantics of these traits.
    
    However, this commit does implement these traits for the
    `aws_smithy_types::date_time::DateTime` and `aws_smithy_types::Blob`
    runtime types.
    
    This change is necessary to efficiently implement the `@uniqueItems`
    constraint trait in server SDKs.
    
    This commit also introduces a constrained shape symbol metadata provider
    (`ConstrainedShapeSymbolMetadataProvider.kt`), to centralize generation
    of Rust metadata (derives, visibility) in one place, instead of each
    constrained type generator having to manually adjust metadata. Some
    constrained type methods are now conditionally generated based on
    visibility, instead of relying on `#[allow(dead_code)]`.
    
    [`Eq`]: https://doc.rust-lang.org/std/cmp/trait.Eq.html
    [`Hash`]: https://doc.rust-lang.org/std/hash/trait.Hash.html
    [`document` shapes]: https://smithy.io/2.0/spec/simple-types.html#document
    [@streaming]: https://smithy.io/2.0/spec/streaming.html
    [is a backwards-compatible change]: https://smithy.io/2.0/guides/evolving-models.html#updating-structures
    david-perez committed Jan 18, 2023
    Configuration menu
    Copy the full SHA
    d926b14 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    dd6c32e View commit details
    Browse the repository at this point in the history
  13. Adjust Python

    david-perez committed Jan 18, 2023
    Configuration menu
    Copy the full SHA
    f1f0b3d View commit details
    Browse the repository at this point in the history
  14. Fix Python

    david-perez committed Jan 18, 2023
    Configuration menu
    Copy the full SHA
    ad47354 View commit details
    Browse the repository at this point in the history

Commits on Jan 19, 2023

  1. Configuration menu
    Copy the full SHA
    8078964 View commit details
    Browse the repository at this point in the history
  2. ./gradlew ktlintFormat

    david-perez committed Jan 19, 2023
    Configuration menu
    Copy the full SHA
    d677059 View commit details
    Browse the repository at this point in the history