zig/lib/std
Andrew Kelley 9501ea688f stage2: --autofix proof-of-concept
* Introduce the `--autofix` CLI flag when building an executable,
   object, or library.
 * Refactor std.zig.render to use a struct parameter to make it easier
   to add/remove fields from the struct.
 * Introduce a "Fixups" concept to std.zig.render which can perform
   edits while rendering code, while leaving the Ast read-only.
 * Add a fixup for adding a discard after a variable declaration.
 * Update the Module code to check for fixable errors after AstGen
   lowering.

Improvements that need to be made before this can be merged:

 * Introduce an error for "pointless discard" and a fixup for it so that
   --autofix can undo the effects of itself when a variable becomes
   used.
 * Support local variables as well as local constants.
 * Support captures in addition to local variables and constants.
 * Integrate properly with incremental compilation.
 * Integrate with the Zig build system.
 * Distinguish between AstGen errors that can be autofixed and those
   that cannot.
 * Remove std.debug.print statements.
 * Only perform fixups when all errors are autofixable errors. However,
   suppress all autofixable errors when reporting errors with --autofix.

The purpose of this feature is to satisfy two use cases that
traditionally have been at odds:

 * Some people want the guarantee that all Zig code they read has the
   property that there are no unused locals.
 * Some people find no value from such errors and want to not have to
   deal with them.

The problem with an `--allow-unused` flag is that people from the second
group will use it, and then some projects will fail to compile without
the flag enabled.

I like to think of Zig as having "inline warnings". The warnings are
there, inside your source code, next to the relevant lines, ready to be
noticed by diffs, code reviews, and when refactoring.

`--autofix` is a way for Zig to automatically insert inline warnings for
those who wish to iterate quickly on a messy codebase.
2022-09-09 18:49:05 -07:00
..
atomic std: replace usage of std.meta.bitCount() with @bitSizeOf() 2022-04-27 11:10:52 +02:00
build std.zig.system.NativeTargetInfo: detection ignores self exe 2022-09-08 20:52:49 -07:00
c openbsd: fix sigcontext struct and avoid defining fxsave64 2022-08-26 17:30:07 +02:00
compress stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
crypto stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
dwarf wasm: Implement debug info for parameters 2022-05-09 18:51:46 +02:00
event stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
fmt stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
fs std.fs.File.setEndPos: add the word "truncate" to doc comments 2022-09-09 18:48:39 -07:00
hash stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
heap Move sys_can_stack_trace from GPA to std.debug so that it can be re-used as needed 2022-06-25 21:27:56 -07:00
http std: add http definitions for Method and Status (#10661) 2022-05-11 15:43:18 -04:00
io Sema: add error for non-comptime param in comptime func 2022-08-27 11:17:48 +03:00
json std.json: Fix parsing of large numbers 2022-07-23 13:52:16 +03:00
math Fix #12440: std.math.big.Rational order/orderAbs 2022-09-04 18:45:20 +03:00
mem Revert "std.mem.Allocator: add alignedCreate" 2022-07-23 15:30:12 +03:00
meta std.meta.TrailerFlags: improve init type 2022-05-04 21:26:48 +02:00
net AstGen: fix loop control flow applying to wrong loop 2022-07-13 16:10:41 -07:00
os std.os.uefi: mark BlockIoProtocol and EfiBlockMedia as public 2022-09-09 16:48:54 +03:00
rand std.rand: make weightedIndex proportions param a const slice 2022-08-30 13:02:17 +03:00
target std: rename std.Target.systemz to .s390x 2022-07-28 23:22:44 -07:00
testing Move sys_can_stack_trace from GPA to std.debug so that it can be re-used as needed 2022-06-25 21:27:56 -07:00
Thread stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
time std.time.epoch: fix issue in documentation 2021-12-16 19:08:58 -08:00
tz Support legacy TZ format, expose header struct to a potential writer 2022-01-01 12:47:08 +00:00
unicode migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
valgrind std.valgrind.callgrind: fix string type 2022-08-22 13:55:00 +03:00
x std.fmt: require specifier for unwrapping ?T and E!T 2022-07-26 11:25:49 -07:00
zig stage2: --autofix proof-of-concept 2022-09-09 18:49:05 -07:00
array_hash_map.zig Sema: solve a false positive "depends on itself" 2022-05-06 22:40:57 -07:00
array_list.zig link.MachO: use accurate alignment attribute on pointers 2022-08-10 22:28:05 -07:00
ascii.zig allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
atomic.zig std.Thread.Futex improvements (#11464) 2022-04-19 19:42:15 -05:00
base64.zig std.base64: upgrade to new function pointer semantics 2022-03-30 20:38:01 -07:00
bit_set.zig stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
bounded_array.zig AstGen: detect declarations shadowing locals 2022-08-16 20:35:03 +03:00
buf_map.zig reverse some of the now unneeded changes from squeek 2022-05-11 18:41:23 -06:00
buf_set.zig std.BufSet.clone: fix key ownership 2022-03-01 13:28:47 -05:00
build.zig std.zig.system.NativeTargetInfo: detection ignores self exe 2022-09-08 20:52:49 -07:00
builtin.zig make self-hosted the default compiler 2022-08-19 16:45:15 -07:00
c.zig Sema: add error for non-comptime param in comptime func 2022-08-27 11:17:48 +03:00
child_process.zig math: make cast return optional instead of an error 2022-05-27 16:43:33 -04:00
coff.zig coff: add import table definitions 2022-08-31 19:30:51 +02:00
compress.zig stage2: small fixes + adjustments to std tests 2022-06-11 23:49:33 +03:00
comptime_string_map.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
crypto.zig crypto: add the Xoodoo permutation, prepare for Gimli deprecation (#11866) 2022-07-01 13:18:08 +02:00
cstr.zig allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
debug.zig std.debug: DWARFv5 fixes 2022-08-23 21:11:02 -07:00
dwarf.zig std.debug: DWARFv5 fixes 2022-08-23 21:11:02 -07:00
dynamic_library.zig math: make cast return optional instead of an error 2022-05-27 16:43:33 -04:00
elf.zig Sema: add error for non-comptime param in comptime func 2022-08-27 11:17:48 +03:00
enums.zig std.enums: make directEnumArrayLen public 2022-08-05 15:41:03 +03:00
event.zig std, compiler-rt: remove test names where applicable 2021-09-01 17:54:06 -07:00
fifo.zig allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
fmt.zig stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
fs.zig std.fs: Fix WalkerEntry.dir not always being the containing dir 2022-08-15 11:25:51 +03:00
hash.zig lint: duplicate import (#10519) 2022-01-07 00:06:06 -05:00
hash_map.zig std: fix missing hash map safety 2022-04-20 17:18:06 -07:00
heap.zig stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
http.zig std: add http definitions for Method and Status (#10661) 2022-05-11 15:43:18 -04:00
io.zig libstd: use windows.GetStdHandle() with stage2_x86_64 backend for now 2022-09-07 22:42:57 +02:00
json.zig std.json: expose encodeJsonString and encodeJsonStringChars 2022-07-24 11:51:59 +03:00
leb128.zig stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
linked_list.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
log.zig Using comptime level.asText() in log example 2022-08-31 16:01:35 +03:00
macho.zig macho: add missing align cast in LoadCommandIterator 2022-08-03 21:19:41 +02:00
math.zig Merge pull request #12574 from Vexu/remove-bit-op-type-param 2022-08-24 15:57:44 -04:00
mem.zig docs: remove confusion about align[For|Back]ward 2022-08-24 17:18:29 -04:00
meta.zig Sema: add error for non-comptime param in comptime func 2022-08-27 11:17:48 +03:00
multi_array_list.zig Sema: add error for non-comptime param in comptime func 2022-08-27 11:17:48 +03:00
net.zig std.mem: add first method to SplitIterator and SplitBackwardsIterator 2022-07-25 22:04:30 +03:00
once.zig std.Thread.Mutex: change API to lock() and unlock() 2021-11-09 18:31:03 -07:00
os.zig Add AFNOSUPPORT error to bind (#12560) 2022-09-01 15:13:07 -05:00
packed_int_array.zig stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
pdb.zig libstd: fix off-by-one error in def of ProcSym in pdb 2022-08-17 16:36:02 -04:00
priority_dequeue.zig stage2+stage1: remove type parameter from bit builtins 2022-08-22 11:19:20 +03:00
priority_queue.zig PriorityQueue: use compareFn in update() 2022-07-22 19:25:38 +03:00
process.zig std.mem: add first method to SplitIterator and SplitBackwardsIterator 2022-07-25 22:04:30 +03:00
Progress.zig std.Progress.log: adjust API 2022-05-26 21:58:19 -07:00
rand.zig std.rand: make weightedIndex proportions param a const slice 2022-08-30 13:02:17 +03:00
segmented_list.zig std: disable tests that crash stage2 2022-06-03 20:21:20 +03:00
SemanticVersion.zig std.mem: add first method to SplitIterator and SplitBackwardsIterator 2022-07-25 22:04:30 +03:00
simd.zig std.simd: change T to u16 2022-09-07 15:22:30 +03:00
sort.zig std: add sort method to ArrayHashMap and MultiArrayList 2022-03-10 13:13:17 -05:00
start.zig coff: re-enable default entrypoint for Windows 2022-09-07 22:42:55 +02:00
start_windows_tls.zig stage1, stage2: rename c_void to anyopaque (#10316) 2021-12-19 00:24:45 -05:00
std.zig std: add http definitions for Method and Status (#10661) 2022-05-11 15:43:18 -04:00
target.zig improved ABI alignment/size for >= 128-bit integers 2022-08-18 20:34:36 -07:00
testing.zig std.testing: make the caret indicator line more helpful 2022-07-25 15:51:22 +03:00
Thread.zig std.Thread: fix freeAndExit on x86_64-linux (#12693) 2022-08-30 22:31:47 -04:00
time.zig math: make cast return optional instead of an error 2022-05-27 16:43:33 -04:00
treap.zig treap: zig fmt 2022-04-15 17:01:01 -05:00
tz.zig std.tz: fix function returning pointer to local variable 2022-06-17 21:04:21 +03:00
unicode.zig Sema: handle tuple and anon_struct in resolveTypeFully 2022-06-11 11:02:56 +03:00
valgrind.zig lint: duplicate import (#10519) 2022-01-07 00:06:06 -05:00
wasm.zig wasm: Implement memset, and sret arguments. 2022-01-04 17:59:05 +01:00
x.zig stage2: small fixes + adjustments to std tests 2022-06-11 23:49:33 +03:00
zig.zig std.Target gains ObjectFormat field 2022-08-18 18:58:28 -07:00