Skip to content

An enum of values is a value (#2549); x86_64 Windows long double is windows-gnu's (#2771) - #2808

Merged
ehartford merged 3 commits into
mainfrom
enum-values
Oct 29, 2026
Merged

ehartford merged 3 commits into
mainfrom
enum-values

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Fixes #2549 (D111: identity is compositional; fields_all_copy walks enum payloads; codegen's enum copy glue already retains payloads). Fixes #2771 (TargetSpec follows the windows-gnu triple, #1915).

Battery GREEN on 5c564bc (verdict.w: rc=0 green).

Eric Hartford added 3 commits October 29, 2026 02:55
An enum of values was Copy only with `impl Copy` written ("an enum
instance stays opt-in"), so under D144 a match on a bare local observed it
and passing a payload on was refused: behav_generic_enum_nested_generic_
payload spelled `match move g` three times for G[i64] and H[i64], integers
in a tag. D111 decides copy-or-move by identity, and identity is
compositional (D120 stage 3 for structs): an enum is a value when every
payload is, unless it has a Drop impl or is a `resource type`.

fields_all_copy, which caches and cuts cycles for structs, walks an enum's
variant payloads too; is_copy asks it for a plain enum and a generic enum
instance. Codegen already carries the enum copy glue (each active payload
retained by tag): enums holding a str and a List copy and run clean under
the debug allocator.

Tests: behav_2549_enum_of_values_is_a_value (installed: use of moved
value; stage1: passes, audit:all clean); the fixture drops its three
`move`s.
…urce (#2549)

The derive-Clone diagnostics tests took `enum Status { Idle, Busy }` as a
type that is not Clone; under #2549 it is a value, so Copy and cloneable,
and the derive succeeded. Status keeps its variants and gains a Drop impl,
which gives it identity: neither Copy nor Clone, as the tests need. The
bundle interface of an enum of i32s now carries `impl Copy for Color`, as
the structs of values in the same interface already did.
…#2771)

TargetSpec.c_long_double_is_double said a double for every Windows target,
while the same file names x86_64 Windows's triple x86_64-w64-windows-gnu
(#1915: the GNU environment, mingw-w64 UCRT; the build links libc/windows/
<arch>-w64-mingw32), whose clang reports a 16-byte, 80-bit x87 long
double. c_import read the table and would import a MinGW function taking
long double as taking f64, while the migrator, parsing under the triple,
refused it (D51's hazard). One fact, two answers in one file.

The table follows the triple: a double on AArch64 macOS and AArch64
Windows, wider elsewhere. The strtoll-family migrate fixture asks for
strtold by the same rule (it had os() == "Macos", wrong on x86_64 macOS
too), and the unit test asserts x86_64 Windows is not a double.
@ehartford
ehartford merged commit d680eda into main Oct 29, 2026
@ehartford
ehartford deleted the enum-values branch October 29, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant