Skip to content

sync main with upstream/main#1

Merged
johncarmack1984 merged 3 commits into
mainfrom
john/sync-upstream-main
May 24, 2026
Merged

sync main with upstream/main#1
johncarmack1984 merged 3 commits into
mainfrom
john/sync-upstream-main

Conversation

@johncarmack1984
Copy link
Copy Markdown
Collaborator

@johncarmack1984 johncarmack1984 commented May 24, 2026

No description provided.

johncarmack1984 and others added 3 commits May 11, 2026 08:49
…y-tagged shape + flatten on struct variants) (specta-rs#489)

* fix: recognize widened-tag and intersection-payload variants in repr-rewrite guard

`variant_repr_already_rewritten` decides whether `rewrite_enum_repr_for_phase`
should re-process an enum during a subsequent pass. The first pass clears the
enum's attributes (line 1412), so any second pass sees `e.attributes.is_empty()`
and `EnumRepr::from_attrs` falls through to `EnumRepr::External`. If the guard
fails for any variant, the enum gets re-processed under the wrong representation,
wrapping each variant in `{ VariantName: payload }` (externally-tagged shape)
when the original wire format is internally-tagged.

Two variant shapes produced by `transform_internal_variant` were not recognized:

1. The `widen_tag` case (deserialize phase + `#[serde(other)]` variant) leaves
   the tag as `Primitive::str` rather than a generated string-literal enum.
2. The tuple-variant case wraps the payload in
   `Intersection<{tag-struct}, payload>` rather than a string-literal field.

Both shapes are now recognized as already-rewritten, so the second-pass guard
trips correctly and the enum keeps its internally-tagged TS shape across
rewrite passes.

Snapshot updates reflect the corrected output: variants no longer get
externally-tagged wrapping, and the `?: never` exclusion markers are gone for
internally-tagged enums.

Adds `internally_tagged_enum_with_content_variants_renders_correctly` test
that asserts both regression conditions (no `?: never` exclusions, tag
literals present).

* fix: honor #[serde(flatten)] on struct-variant fields in internally-tagged enums

A struct-variant whose field carries #[serde(flatten)] serializes
to a top-level merged JSON object alongside the discriminator tag.
The TS bindings should mirror that:

  enum E { A { #[serde(flatten)] inner: T } }    // serde wire format
                                                 // { type: "A", ...T_fields }
  type E = ({ type: "A" } & T)                  // correct TS shape

In rc.25, transform_internal_variant for Fields::Named cloned the
variant's fields verbatim into the result. The flatten attribute on
'inner' survived to the typescript exporter, but the exporter no
longer respects flatten on bare named-field collections (only on
DataType::Struct, via lower_flattened_struct). Result: the inner
type was kept under an 'inner:' key instead of merged.

Mirror the unnamed-payload path: when any named field is flattened,
build an Intersection of the tag struct, the leftover named fields,
and each flattened field's payload type. Returns an unnamed-field
variant whose single field is that Intersection -- the same shape
the unnamed-payload arm produces.

Snapshot diffs across 11 serde-format snapshots all show the same
expected change: { type: "X"; inner: T } -> ({ type: "X" } & T).
The MyEnumTagged test fixture (issue specta-rs#393) now renders correctly.
…specta-rs#490)

Bumps the specta-deps group with 3 updates: [rust_decimal](https://github.com/paupino/rust-decimal), [tokio](https://github.com/tokio-rs/tokio) and [serde_with](https://github.com/jonasbb/serde_with).


Updates `rust_decimal` from 1.41.0 to 1.42.0
- [Release notes](https://github.com/paupino/rust-decimal/releases)
- [Changelog](https://github.com/paupino/rust-decimal/blob/master/CHANGELOG.md)
- [Commits](paupino/rust-decimal@1.41.0...1.42.0)

Updates `tokio` from 1.52.2 to 1.52.3
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](tokio-rs/tokio@tokio-1.52.2...tokio-1.52.3)

Updates `serde_with` from 3.19.0 to 3.20.0
- [Release notes](https://github.com/jonasbb/serde_with/releases)
- [Commits](jonasbb/serde_with@v3.19.0...v3.20.0)

---
updated-dependencies:
- dependency-name: rust_decimal
  dependency-version: 1.42.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: specta-deps
- dependency-name: tokio
  dependency-version: 1.52.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: specta-deps
- dependency-name: serde_with
  dependency-version: 3.20.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: specta-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@johncarmack1984 johncarmack1984 merged commit f18d196 into main May 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants