aboutsummaryrefslogtreecommitdiff
path: root/lib/std/meta.zig
AgeCommit message (Collapse)Author
2025-10-16std: disable a few failing tests on hexagonAlex Rønne Petersen
2025-09-20coerce vectors to arrays rather than inline forAndrew Kelley
2025-09-20compiler: require comptime vector indexesAndrew Kelley
2025-09-19std.fmt: migrate bufPrintZ to bufPrintSentinel (#25260)John Benediktsson
2025-09-05std: update for new packed union rulesAndrew Kelley
2025-08-01remove usages of `.alignment = 0`David Rubin
2025-07-11Remove numerous things deprecated during the 0.14 release cycleLinus Groh
Basically everything that has a direct replacement or no uses left. Notable omissions: - std.ArrayHashMap: Too much fallout, needs a separate cleanup. - std.debug.runtime_safety: Too much fallout. - std.heap.GeneralPurposeAllocator: Lots of references to it remain, not a simple find and replace as "debug allocator" is not equivalent to "general purpose allocator". - std.io.Reader: Is being reworked at the moment. - std.unicode.utf8Decode(): No replacement, needs a new API first. - Manifest backwards compat options: Removal would break test data used by TestFetchBuilder. - panic handler needs to be a namespace: Many tests still rely on it being a function, needs a separate cleanup.
2025-05-14Revert "Work around stage1 not yet returning null-terminated `@typeInfo` ↵Isaac Freund
strings" This reverts commit c8fa767f083e610840cef688b709783c5ad66acc.
2025-05-13std.meta.intToEnum -> std.enums.fromIntwooster0
Also use an optional as the return type instead of an error code.
2025-03-24deprecate O(n) union field type helpers in std.metaCarter Snook
Users should be using @FieldType() instead.
2025-02-18docs: update old reference from builtin.Type.Struct to builtin.Type.@"struct"sidharta
2025-02-04std.meta.FieldType: use builtin and deprecateMeghan Denny
2025-01-26std.meta: handle `comptime` fields in `hasUniqueRepresentation` (#22132)Fri3dNstuff
2025-01-24compiler: yet more panic handler changesmlugg
* `std.builtin.Panic` -> `std.builtin.panic`, because it is a namespace. * `root.Panic` -> `root.panic` for the same reason. There are type checks so that we still allow the legacy `pub fn panic` strategy in the 0.14.0 release. * `std.debug.SimplePanic` -> `std.debug.simple_panic`, same reason. * `std.debug.NoPanic` -> `std.debug.no_panic`, same reason. * `std.debug.FormattedPanic` is now a function `std.debug.FullPanic` which takes as input a `panicFn` and returns a namespace with all the panic functions. This handles the incredibly common case of just wanting to override how the message is printed, whilst keeping nice formatted panics. * Remove `std.builtin.panic.messages`; now, every safety panic has its own function. This reduces binary bloat, as calls to these functions no longer need to prepare any arguments (aside from the error return trace). * Remove some legacy declarations, since a zig1.wasm update has happened. Most of these were related to the panic handler, but a quick grep for "zig1" brought up a couple more results too. Also, add some missing type checks to Sema. Resolves: #22584 formatted -> full
2025-01-16all: update to `std.builtin.Type.{Pointer,Array,StructField}` field renamesmlugg
2025-01-16all: update to `std.builtin.Type.Pointer.Size` field renamesmlugg
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!
2024-11-24`std.meta.eql`: use `==` directly when comparing `packed struct`s (#21982)Fri3dNstuff
2024-10-31compiler: remove anonymous struct types, unify all tuplesmlugg
This commit reworks how anonymous struct literals and tuples work. Previously, an untyped anonymous struct literal (e.g. `const x = .{ .a = 123 }`) was given an "anonymous struct type", which is a special kind of struct which coerces using structural equivalence. This mechanism was a holdover from before we used RLS / result types as the primary mechanism of type inference. This commit changes the language so that the type assigned here is a "normal" struct type. It uses a form of equivalence based on the AST node and the type's structure, much like a reified (`@Type`) type. Additionally, tuples have been simplified. The distinction between "simple" and "complex" tuple types is eliminated. All tuples, even those explicitly declared using `struct { ... }` syntax, use structural equivalence, and do not undergo staged type resolution. Tuples are very restricted: they cannot have non-`auto` layouts, cannot have aligned fields, and cannot have default values with the exception of `comptime` fields. Tuples currently do not have optimized layout, but this can be changed in the future. This change simplifies the language, and fixes some problematic coercions through pointers which led to unintuitive behavior. Resolves: #16865
2024-10-06Merge pull request #21331 from bobf/std-meta-DeclEnum-empty-structAlex Rønne Petersen
Prevent failure with empty struct in `std.meta.DeclEnum`
2024-10-04Remove old deprecated symbols in std (#21584)PauloCampana
Also, actually run tests inside std/tar/writer.zig
2024-09-07Prevent failure with empty struct in `std.meta.DeclEnum`Bob Farrell
2024-08-29std: avoid field/decl name conflictsmlugg
Most of these changes seem like improvements. The PDB thing had a TODO saying it used to crash; I anticipate it works now, we'll see what CI does. The `std.os.uefi` field renames are a notable breaking change.
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-07-28chore: correct non-standard comments.matt ettler
Comments throughout the codebase start with a space. This commit corrects comments that do not adhere to this norm.
2024-07-09std: fix typos (#20560)Jora Troosh
2024-06-23std.meta.hasUniqueRepresentation: Handle optional pointers correctly (#20366)Sean
std.meta.hasUniqueRepresentation should now return true for non-slice optional pointers. Additional checks were added to the test to reflect this.
2024-06-18fix std.meta.eql for comptime-only unionrohlem
switch from `inline for` with `std.mem.eql` to `inline else` and tag comparison. add previously-failing test code.
2024-06-02std.meta.hasUniqueRepresentation: better support packed structsMeghan Denny
2024-05-03Delete compile errors for deprecated declsRyan Liptak
2024-04-23std.meta: give TagPayloadByName unreachable a better @compileError messageclickingbuttons
2024-04-22ComptimeStringMap: return a regular struct and optimizeTravis Staloch
this patch renames ComptimeStringMap to StaticStringMap, makes it accept only a single type parameter, and return a known struct type instead of an anonymous struct. initial motivation for these changes was to reduce the 'very long type names' issue described here https://github.com/ziglang/zig/pull/19682. this breaks the previous API. users will now need to write: `const map = std.StaticStringMap(T).initComptime(kvs_list);` * move `kvs_list` param from type param to an `initComptime()` param * new public methods * `keys()`, `values()` helpers * `init(allocator)`, `deinit(allocator)` for runtime data * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure these belong but have left in for now incase they are deemed useful * performance notes: * i posted some benchmarking results here: https://github.com/travisstaloch/comptime-string-map-revised/issues/1 * i noticed a speedup reducing the size of the struct from 48 to 32 bytes and thus use u32s instead of usize for all length fields * i noticed speedup storing KVs as a struct of arrays * latest benchmark shows these wall_time improvements for debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full output in link above.
2024-03-25compiler: implement analysis-local comptime-mutable memorymlugg
This commit changes how we represent comptime-mutable memory (`comptime var`) in the compiler in order to implement the intended behavior that references to such memory can only exist at comptime. It does *not* clean up the representation of mutable values, improve the representation of comptime-known pointers, or fix the many bugs in the comptime pointer access code. These will be future enhancements. Comptime memory lives for the duration of a single Sema, and is not permitted to escape that one analysis, either by becoming runtime-known or by becoming comptime-known to other analyses. These restrictions mean that we can represent comptime allocations not via Decl, but with state local to Sema - specifically, the new `Sema.comptime_allocs` field. All comptime-mutable allocations, as well as any comptime-known const allocs containing references to such memory, live in here. This allows for relatively fast checking of whether a value references any comptime-mtuable memory, since we need only traverse values up to pointers: pointers to Decls can never reference comptime-mutable memory, and pointers into `Sema.comptime_allocs` always do. This change exposed some faulty pointer access logic in `Value.zig`. I've fixed the important cases, but there are some TODOs I've put in which are definitely possible to hit with sufficiently esoteric code. I plan to resolve these by auditing all direct accesses to pointers (most of them ought to use Sema to perform the pointer access!), but for now this is sufficient for all realistic code and to get tests passing. This change eliminates `Zcu.tmp_hack_arena`, instead using the Sema arena for comptime memory mutations, which is possible since comptime memory is now local to the current Sema. This change should allow `Decl` to store only an `InternPool.Index` rather than a full-blown `ty: Type, val: Value`. This commit does not perform this refactor.
2024-03-17AstGen: disallow alignment on function typesJacob Young
A pointer type already has an alignment, so this information does not need to be duplicated on the function type. This already has precedence with addrspace which is already disallowed on function types for this reason. Also fixes `@TypeOf(&func)` to have the correct addrspace and alignment.
2024-03-11std.builtin: make container layout fields lowercaseTristan Ross
2024-02-26Change many test blocks to doctests/decltestsRyan Liptak
2024-02-26Remove redundant test name prefixes now that test names are fully qualifiedRyan Liptak
Follow up to #19079, which made test names fully qualified. This fixes tests that now-redundant information in their test names. For example here's a fully qualified test name before the changes in this commit: "priority_queue.test.std.PriorityQueue: shrinkAndFree" and the same test's name after the changes in this commit: "priority_queue.test.shrinkAndFree"
2024-02-25x86_64: implement `@shuffle`Jacob Young
2024-02-22Builder: fix llvm ir value namesJacob Young
Hello world now verifies when not stripped.
2024-02-22Builder: support printing metadata in llvm irJacob Young
2024-02-03std.fmt: fix formatting slices of structs with custom formattingChadwain Holness
`hasMethod` doesn't make sense for pointers to more than one item.
2024-01-27std: remove meta.globalOptionVeikka Tuominen
2024-01-23std.fmt: fix unecessary deref on user-defined format functionKhang Nguyen Duy
When formatting a pointer to user type, currently it needs to be dereferenced first, then call `formatType` on the child type. Fix the problem by checking for "format" function on not only the type itself, but also the struct it points to. Add hasMethod to std.meta.
2024-01-07Fix failing type reificationsCarl Åstholm
2024-01-07Work around stage1 not yet returning null-terminated `@typeInfo` stringsCarl Åstholm
These changes can be reverted the next time stage1 is updated.
2023-12-08AstGen: add error for using inline loops in comptime only scopesVeikka Tuominen
2023-11-22std: remove meta.traitAndrew Kelley
In general, I don't like the idea of std.meta.trait, and so I am providing some guidance by deleting the entire namespace from the standard library and compiler codebase. My main criticism is that it's overcomplicated machinery that bloats compile times and is ultimately unnecessary given the existence of Zig's strong type system and reference traces. Users who want this can create a third party package that provides this functionality. closes #18051
2023-11-19std: correct faulty testmlugg
2023-11-19lib: correct unnecessary uses of 'var'mlugg
2023-11-18Faster implementation of intToEnum.Lucas Santos
2023-09-27Remove `@fabs`, fabs and absCast/Int from std libantlilja
Replaces occurences of @fabs absCast and absInt with new @abs builtin. Also removes the std.math.fabs alias from math.zig.