Commit graph

189 commits

Author SHA1 Message Date
Ali Chraghi
3db3cf7790 std.sort: add pdqsort and heapsort 2023-05-23 17:55:59 -07:00
Meghan
7077e90b3f std.meta: allow ArgsTuple to be used on functions with comptime parameters
any comptime parameter sets `.is_generic` to be true but in many cases these will still be discrete types available in `.params`
2023-05-20 11:21:06 +03:00
Meghan
0972196f4d std.meta: remove tagName
not used by Zig itself anywhere
2023-05-10 16:00:14 +03:00
Mason Remaley
e963793e37
Updates std.meta.intToEnum to support non-exhaustive enums (#15491)
This was preventing `std.json` from deserializing non-exhaustive enums.
2023-05-01 05:03:46 +00:00
Jacob Young
3f1c51ca90 std: remove names from incorrectly named tests
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-21 23:08:48 -04:00
mlugg
ccf670c2b0 Zir: implement explicit block_comptime instruction
Resolves: #7056
2023-04-12 12:06:19 -04:00
Andrew Kelley
aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
Jonathan Marler
1876eaec51 mark deprecated assumeSentinel as pub
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-02-04 23:19:00 +02:00
Isaac Freund
9eeae556cc std: remove meta.assumeSentinel
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-24 15:39:52 -05:00
mlugg
8094fa5d48 std: add meta.FieldType
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-03 12:47:48 +02:00
Andrew Kelley
942b5b468f std.crypto.tls: implement the rest of the cipher suites
Also:
 * Use KeyPair.create() function
 * Don't bother with CCM
2023-01-02 16:57:15 -07:00
r00ster91
ceff03f3e9 std.builtin: remove layout field from Type.Enum 2022-12-18 13:31:38 +01:00
r00ster91
aac2d6b56f std.builtin: rename Type.UnionField and Type.StructField's field_type to type 2022-12-17 14:11:33 +01:00
r00ster91
7350ea3e2d std.builtin: rename Type.Fn's args to params
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-17 14:11:33 +01:00
r00ster91
20d3fd901e std.builtin: rename Type.Fn.Param's arg_type to type
It's the type of a parameter, not an argument, but the prefix is redundant either way.
2022-12-17 14:11:33 +01:00
zooster
8da9cc85af std.meta: remove bitCount 2022-12-17 00:15:47 +02:00
r00ster91
7826e28bd3 Re-apply: "std.ComptimeStringMap: use tuple types"
096d3efae5 was not the cause of the
CI failure.
2022-12-08 22:21:46 +02:00
Andrew Kelley
225ed65ed2 Revert "std.ComptimeStringMap: use tuple types"
This reverts commit 096d3efae5.

This commit is not passing a very important CI test that was recently
added.
2022-12-08 02:23:17 -08:00
r00ster91
096d3efae5 std.ComptimeStringMap: use tuple types
This is now possible due to #13627.
2022-12-07 14:56:55 +02:00
Andrew Kelley
50eb7983cd remove most conditional compilation based on stage1
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-06 20:38:54 -07:00
Gregory Oakes
8d17e90fcd std: add a special case for empty structs in meta.FieldEnum.
Empty structs would previously result in a compilation error.
2022-12-04 14:22:16 +02:00
Veikka Tuominen
8c4faa5f3f
Merge pull request #13338 from Vexu/stage2-compile-errors
Improve some error messages
2022-11-04 16:04:31 +02:00
Yujiri
b19161ba9c Add docstrings to some functions in std.meta 2022-11-03 17:37:38 +02:00
Veikka Tuominen
d7314555f2 Sema: improve compile error for casting double pointer to anyopaque pointer
Closes #12042
2022-10-29 14:55:43 +03:00
Evin Yulo
b346d48572 Simplify code in std.meta.isTag 2022-10-16 11:35:27 -04:00
Isaac Yonemoto
99c3578f69
adds isTag function to std.meta (#11895) 2022-10-15 14:32:05 -04:00
Silver
f3a1b5c481 std/meta: make FieldEnum(T) == Tag(T) for tagged unions when values match field indices 2022-09-27 18:42:20 +03:00
Veikka Tuominen
541b3e3a31 Sema: check pointer qualifiers before implicit cast
Closes #12881
2022-09-20 00:50:13 +03:00
antlilja
ae8d26a6a0 Sema: add error for non-comptime param in comptime func
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-27 11:17:48 +03:00
Felix "xq" Queißner
5696cc8ab6 Adds std.meta.FnPtr for easier stage1/stage2 compatibility 2022-08-24 03:13:44 -04:00
Felix "xq" Queißner
263b5933d2 Makes std.meta.Tuple and std.meta.ArgsTuple generate a unique type instead of generating one per invocation. 2022-08-05 15:39:53 +03:00
Veikka Tuominen
6d44c0a16c std: update tests to stage2 semantics 2022-06-03 20:21:20 +03:00
Erik Arvstedt
8b8e57c670 std.meta.TrailerFlags: include in std tests
Previously, TrailerFlags was unreferenced in std,
so its tests were never run.

Also, fix the use of `default_value` whose type was changed in
f4a249325e (#10766).
2022-05-04 20:01:48 +02:00
Isaac Freund
6c0719fd5f std.meta: deprecate bitCount() for @bitSizeOf() 2022-04-27 11:10:52 +02:00
Jimmi Holst Christensen
cea310c908 Remove usage of inline for from print_targets.cmdTargets
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-04-26 17:52:21 -04:00
Andrew Kelley
f5f5b9373d std.meta: fix unit tests depending on unstable behavior
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-24 17:47:39 -07:00
Andrew Kelley
2af69710a7 stage2: fix some generics issues
* 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-23 23:28:05 -07:00
Andrew Kelley
d42d31f72f basic language features do not belong in std.meta 2022-03-14 00:11:46 -07:00
Jonathan Marler
d805adddd6 deprecated TypeInfo in favor of Type
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-03-08 20:38:12 +02:00
Andrew Kelley
f4a249325e stage1: avoid anytype fields for type info
prerequisite for #10705
2022-02-01 18:10:19 -07:00
Andrew Kelley
75bbc74d56 a small crusade against std.meta.declarations 2022-01-31 22:25:49 -07:00
Meghan Denny
b7ba728929 std: add meta.DeclEnum 2022-01-20 10:54:45 +02:00
Andrew Kelley
902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
Lewis Gaul
bc3e86c4b7 Add std.meta.Float, alongside std.meta.Int 2021-11-22 21:30:20 -05:00
InKryption
eeb8629bea Use debug.assert instead of testing.expect.
`testing.expect` and friends are intended to be used only in tests; this change reflects that intention.
2021-10-29 20:01:59 +00:00
Andrew Kelley
6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Robin Voetter
c5945467ac Address Spaces: Pointer and function info in @Type 2021-09-20 02:29:04 +02:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Jacob G-W
641ecc260f std, src, doc, test: remove unused variables 2021-06-21 17:03:03 -07:00