-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
std.builtin.Type renames, and make it easier to modify std.builtin #22505
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
Conversation
This matches established naming conventions. Now is an opportune time to make this change, since we're already performing breaking changes to `std.builtin.Type`.
7a0804c to
1d886f9
Compare
|
https://github.com/ziglang/zig/wiki/How-and-When-to-Update-%60zig1.wasm%60 provides guidance on whether to and how to update |
|
I think this can be flagged as fixing #21842. |
This was done by regex substitution with `sed`. I then manually went over the entire diff and fixed any incorrect changes. This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since my regex happened to also trigger here. I opted to leave these changes in, since they *are* a correct migration, even if they're not the one I was trying to do!
Documentation for this will be on the wiki shortly. Resolves: ziglang#21842
The commit 2 after this will explain this diff.
Implementing the changes from the prior commit, to prepare for the following commit. This also means that zig1 now uses the new value interpret mode, so that adding and removing fields from `std.builtin` types is easier. Signed-off-by: mlugg <[email protected]>
For representing struct field default values and array/pointer type sentinel values, we use `*const anyopaque`, since there is no way for `std.builtin.Type.StructField` etc to refer back to its `type` field. However, when introspecting a type, this is quite awkward due to the pointer casts necessary. As such, this commit renames the `sentinel` fields to `sentinel_ptr`, and the `default_value` field to `default_value_ptr`, and introduces helper methods `sentinel()` and `defaultValue()` to load the values. These methods are marked as `inline` because their return value, which is always comptime-known, is very often required at comptime by use sites, so this avoids having to annotate such calls with `comptime`. This is a breaking change, although note that 0.14.0 is already a breaking release for all users of `std.builtin.Type` due to the union fields being renamed.
1d886f9 to
9804cc8
Compare
Good point, flagged on the relevant commit. |
|
@andrewrk just pinging you to note the existence of the above wiki page, in case you ever find yourself needing to update zig1 for an awkward change. |
|
Thanks for typing up the wiki page, that's some really nice documentation 👍 |
Release NotesThese should be placed directly after the notes for #21225.
|
Fixes builds using Zig master after ziglang/zig#22505 by using the updated field names in `std.builtin.Type`.
Fixes builds using Zig master after ziglang/zig#22505 was merged by using the updated field names in `std.builtin.Type`.
Hi, how should I interpret this sentence? |
The main goal of this branch was to make it easier to modify std.builtin by loosening how the compiler converts between comptime-known interned values, and actual
std.builtin.Xyzvalues known to the compiler. However, a zig1.wasm update is desirable for those changes, so I've bundled it together with #22496 to minimize zig1.wasm updates.For instance, this PR makes it trivial to add/remove fields to/from
std.builtin.CallingConvention(@alexrp), or to potentially removestd.builtin.AtomicOrder.unordered(@Rexicon226).I've written up some guidance on how to do these kinds of
std.builtinupdates, which I'll put on the wiki shortly.Supercedes #22496.