aboutsummaryrefslogtreecommitdiff
path: root/lib/std/meta.zig
AgeCommit message (Collapse)Author
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.
2023-09-19write function types consistently with a space before `fn` keywordr00ster91
Currently, the compiler (like @typeName) writes it `fn(...) Type` but zig fmt writes it `fn (...) Type` (notice the space after `fn`). This inconsistency is now resolved and function types are consistently written the zig fmt way. Before this there were more `fn (...) Type` occurrences than `fn(...) Type` already.
2023-08-22compiler: move unions into InternPoolAndrew Kelley
There are a couple concepts here worth understanding: Key.UnionType - This type is available *before* resolving the union's fields. The enum tag type, number of fields, and field names, field types, and field alignments are not available with this. InternPool.UnionType - This one can be obtained from the above type with `InternPool.loadUnionType` which asserts that the union's enum tag type has been resolved. This one has all the information available. Additionally: * ZIR: Turn an unused bit into `any_aligned_fields` flag to help semantic analysis know whether a union has explicit alignment on any fields (usually not). * Sema: delete `resolveTypeRequiresComptime` which had the same type signature and near-duplicate logic to `typeRequiresComptime`. - Make opaque types not report comptime-only (this was inconsistent between the two implementations of this function). * Implement accepted proposal #12556 which is a breaking change.
2023-07-25make `@typeInfo` not return private declsJacob G-W
fixes #10731 Thanks @nektro for previous work in #14878 This change creates a small breaking change: It removes the `is_pub` field of a decl in `@typeInfo`
2023-07-12Remove len parameter from splat in standard libantlilja
2023-07-10std.meta: remove isTag (#15584)Meghan
This is not used by Zig itself anywhere and not using the function is more idiomatic.
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13all: replace `comptime try` with `try comptime`Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13std.meta: remove `TagType` (deprecated in 0.9)Eric Joldasov
Followup to 902df103c6151c257c90de9ba5f29f7f4b9dbea2. Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13std.meta: remove `Vector` (deprecated in 0.10)Eric Joldasov
Followup to d42d31f72f38165f70c2850e9cc63da44b3b470c. Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-05-23std.sort: add pdqsort and heapsortAli Chraghi
2023-05-20std.meta: allow ArgsTuple to be used on functions with comptime parametersMeghan
any comptime parameter sets `.is_generic` to be true but in many cases these will still be discrete types available in `.params`
2023-05-10std.meta: remove tagNameMeghan
not used by Zig itself anywhere
2023-05-01Updates std.meta.intToEnum to support non-exhaustive enums (#15491)Mason Remaley
This was preventing `std.json` from deserializing non-exhaustive enums.
2023-04-21std: remove names from incorrectly named testsJacob Young
Tests that only reference decls for the purpose of analyzing more tests should be unnamed, otherwise trying to filter for just a referenced test can become impossible depending on the names.
2023-04-12Zir: implement explicit block_comptime instructionmlugg
Resolves: #7056
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2023-02-04mark deprecated assumeSentinel as pubJonathan Marler
assumeSentinel was removed and replaced with a compileError, but it's not pub, so the error message indicates it's private rather than providing the compileError message.
2023-01-24std: remove meta.assumeSentinelIsaac Freund
All but 3 callsites of this function in the standard library and compiler were unnecessary and were removed in faf2fd18. In this commit, the remaining 3 callsites are removed. One of them turned out to also be unnecessary and has been replaced by slicing directly with the length.. The 2 remaining callsites were in the very pointer-math heavy std/os/linux/vdso.zig code which should perhaps be refactored to better utilize slices. These 2 callsites are replaced with a plain @ptrCast([*:0]u8, ptr) though could likely use std.mem.sliceTo() if the surrounding code was refactored.
2023-01-03std: add meta.FieldTypemlugg
This is simply a small convenience wrapper around 'meta.fieldInfo(T, .field).type'. However, this operation is common enough that it makes sense to have its own function for.
2023-01-02std.crypto.tls: implement the rest of the cipher suitesAndrew Kelley
Also: * Use KeyPair.create() function * Don't bother with CCM
2022-12-18std.builtin: remove layout field from Type.Enumr00ster91
2022-12-17std.builtin: rename Type.UnionField and Type.StructField's field_type to typer00ster91
2022-12-17std.builtin: rename Type.Fn's args to paramsr00ster91
This was a poor naming choice; these are parameters, not arguments. Parameters specify what kind of arguments are expected, whereas the arguments are the actual values passed.
2022-12-17std.builtin: rename Type.Fn.Param's arg_type to typer00ster91
It's the type of a parameter, not an argument, but the prefix is redundant either way.
2022-12-17std.meta: remove bitCountzooster
2022-12-08Re-apply: "std.ComptimeStringMap: use tuple types"r00ster91
096d3efae5fcaa5640f4acb2f9be2d7f93f7fdb2 was not the cause of the CI failure.
2022-12-08Revert "std.ComptimeStringMap: use tuple types"Andrew Kelley
This reverts commit 096d3efae5fcaa5640f4acb2f9be2d7f93f7fdb2. This commit is not passing a very important CI test that was recently added.
2022-12-07std.ComptimeStringMap: use tuple typesr00ster91
This is now possible due to #13627.
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
2022-12-04std: add a special case for empty structs in meta.FieldEnum.Gregory Oakes
Empty structs would previously result in a compilation error.
2022-11-04Merge pull request #13338 from Vexu/stage2-compile-errorsVeikka Tuominen
Improve some error messages
2022-11-03Add docstrings to some functions in std.metaYujiri
2022-10-29Sema: improve compile error for casting double pointer to anyopaque pointerVeikka Tuominen
Closes #12042
2022-10-16Simplify code in std.meta.isTagEvin Yulo
2022-10-15adds isTag function to std.meta (#11895)Isaac Yonemoto
2022-09-27std/meta: make FieldEnum(T) == Tag(T) for tagged unions when values match ↵Silver
field indices
2022-09-20Sema: check pointer qualifiers before implicit castVeikka Tuominen
Closes #12881
2022-08-27Sema: add error for non-comptime param in comptime funcantlilja
Adds error for taking a non comptime parameter in a function returning a comptime-only type but not when that type is dependent on a parameter. Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-24Adds std.meta.FnPtr for easier stage1/stage2 compatibilityFelix "xq" Queißner
2022-08-05Makes std.meta.Tuple and std.meta.ArgsTuple generate a unique type instead ↵Felix "xq" Queißner
of generating one per invocation.
2022-06-03std: update tests to stage2 semanticsVeikka Tuominen
2022-05-04std.meta.TrailerFlags: include in std testsErik Arvstedt
Previously, TrailerFlags was unreferenced in std, so its tests were never run. Also, fix the use of `default_value` whose type was changed in f4a249325e8e3741a6294462ae37a79cb9089c56 (#10766).
2022-04-27std.meta: deprecate bitCount() for @bitSizeOf()Isaac Freund
2022-04-26Remove usage of inline for from print_targets.cmdTargetsJimmi Holst Christensen
This function was one of the biggest zig functions in a debug build of the compiler. $ bloaty stage3-debug/bin/zig -d symbols --tsv -n 10000000 | rg -v '(llvm|clang|std|lld|\(anonymous namespace\))::|\[section ' | sort -h -k 3 ... translate_c.ast.renderNode 86168 86219 main.buildOutputType 177959 178004 InfoTable 184832 184870 AArch64SVEIntrinsicMap 188544 188596 print_targets.cmdTargets__anon_4735 319156 319216 __static_initialization_and_destruction_0() 486666 489582 MatchTable1 621884 621997 OperandMatchTable 1139622 1139861 MatchTable0 1899764 1900141
2022-03-24std.meta: fix unit tests depending on unstable behaviorAndrew Kelley
The unit tests of std.meta depended on `@typeInfo` for the same type returning a slice of declarations and fields with the same pointer address. This is not something guaranteed by the language specification.
2022-03-23stage2: fix some generics issuesAndrew Kelley
* std.meta: correct use of `default_value` in reification. stage1 accepted a wrong type for `null`. * Sema: after instantiating a generic function, if the return type ends up being a comptime-known type, then we return an error, undoing the generic function instantiation, and making a comptime function call instead. - We also needed to clean up the dependency graph in this case. * Sema: reified enums set tag_ty_inferred to false since an integer tag type is provided. This is a limitation of the `@Type` builtin which will be addressed with #10710. * Sema: fix resolveInferredErrorSet incorrectly calling ensureFuncBodyAnalyzed on generic functions.
2022-03-14basic language features do not belong in std.metaAndrew Kelley