| author | |
| committer | |
| log | dbb4c8d1514f351bbef4a6977a0b188a3c6b81dc |
| tree | 729996c74031c30dd7c721fc5bf460eb27f5207d |
| parent | d41c16930df6fad85f2a63fec2e8e02b128cb1ed |
| parent | 39fa8319478e4843d5384e81935520be2dbbadef |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/3001830 files changed, 53 insertions(+), 711 deletions(-)
lib/compiler/aro/assembly_backend/x86_64.zig+2-2| ... | @@ -58,7 +58,7 @@ fn serializeFloat(comptime T: type, value: T, w: *std.Io.Writer) !void { | ... | @@ -58,7 +58,7 @@ fn serializeFloat(comptime T: type, value: T, w: *std.Io.Writer) !void { |
| 58 | }, | 58 | }, |
| 59 | else => { | 59 | else => { |
| 60 | const size = @bitSizeOf(T); | 60 | const size = @bitSizeOf(T); |
| 61 | const storage_unit = std.meta.intToEnum(StorageUnit, size) catch unreachable; | 61 | const storage_unit = std.enums.fromInt(StorageUnit, size).?; |
| 62 | const IntTy = @Int(.unsigned, size); | 62 | const IntTy = @Int(.unsigned, size); |
| 63 | const int_val: IntTy = @bitCast(value); | 63 | const int_val: IntTy = @bitCast(value); |
| 64 | return serializeInt(int_val, storage_unit, w); | 64 | return serializeInt(int_val, storage_unit, w); |
| ... | @@ -95,7 +95,7 @@ fn emitSingleValue(c: *AsmCodeGen, qt: QualType, node: Node.Index) !void { | ... | @@ -95,7 +95,7 @@ fn emitSingleValue(c: *AsmCodeGen, qt: QualType, node: Node.Index) !void { |
| 95 | if (!scalar_kind.isReal()) { | 95 | if (!scalar_kind.isReal()) { |
| 96 | return c.todo("Codegen _Complex values", node.tok(c.tree)); | 96 | return c.todo("Codegen _Complex values", node.tok(c.tree)); |
| 97 | } else if (scalar_kind.isInt()) { | 97 | } else if (scalar_kind.isInt()) { |
| 98 | const storage_unit = std.meta.intToEnum(StorageUnit, bit_size) catch return c.todo("Codegen _BitInt values", node.tok(c.tree)); | 98 | const storage_unit = std.enums.fromInt(StorageUnit, bit_size) orelse return c.todo("Codegen _BitInt values", node.tok(c.tree)); |
| 99 | try c.data.print(" .{s} ", .{@tagName(storage_unit)}); | 99 | try c.data.print(" .{s} ", .{@tagName(storage_unit)}); |
| 100 | _ = try value.print(qt, c.comp, c.data); | 100 | _ = try value.print(qt, c.comp, c.data); |
| 101 | try c.data.writeByte('\n'); | 101 | try c.data.writeByte('\n'); |
lib/compiler/reduce/Walk.zig-9| ... | @@ -501,10 +501,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void { | ... | @@ -501,10 +501,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void { |
| 501 | .@"asm", | 501 | .@"asm", |
| 502 | => return walkAsm(w, ast.fullAsm(node).?), | 502 | => return walkAsm(w, ast.fullAsm(node).?), |
| 503 | 503 | ||
| 504 | .asm_legacy => { | ||
| 505 | return walkAsmLegacy(w, ast.legacyAsm(node).?); | ||
| 506 | }, | ||
| 507 | |||
| 508 | .enum_literal => { | 504 | .enum_literal => { |
| 509 | return walkIdentifier(w, ast.nodeMainToken(node)); // name | 505 | return walkIdentifier(w, ast.nodeMainToken(node)); // name |
| 510 | }, | 506 | }, |
| ... | @@ -881,11 +877,6 @@ fn walkAsm(w: *Walk, asm_node: Ast.full.Asm) Error!void { | ... | @@ -881,11 +877,6 @@ fn walkAsm(w: *Walk, asm_node: Ast.full.Asm) Error!void { |
| 881 | try walkExpressions(w, asm_node.ast.items); | 877 | try walkExpressions(w, asm_node.ast.items); |
| 882 | } | 878 | } |
| 883 | 879 | ||
| 884 | fn walkAsmLegacy(w: *Walk, asm_node: Ast.full.AsmLegacy) Error!void { | ||
| 885 | try walkExpression(w, asm_node.ast.template); | ||
| 886 | try walkExpressions(w, asm_node.ast.items); | ||
| 887 | } | ||
| 888 | |||
| 889 | /// Check if it is already gutted (i.e. its body replaced with `@trap()`). | 880 | /// Check if it is already gutted (i.e. its body replaced with `@trap()`). |
| 890 | fn isFnBodyGutted(ast: *const Ast, body_node: Ast.Node.Index) bool { | 881 | fn isFnBodyGutted(ast: *const Ast, body_node: Ast.Node.Index) bool { |
| 891 | // skip over discards | 882 | // skip over discards |
lib/docs/wasm/Walk.zig-2| ... | @@ -791,8 +791,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index) | ... | @@ -791,8 +791,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index) |
| 791 | try expr(w, scope, parent_decl, full.ast.template); | 791 | try expr(w, scope, parent_decl, full.ast.template); |
| 792 | }, | 792 | }, |
| 793 | 793 | ||
| 794 | .asm_legacy => {}, | ||
| 795 | |||
| 796 | .builtin_call_two, | 794 | .builtin_call_two, |
| 797 | .builtin_call_two_comma, | 795 | .builtin_call_two_comma, |
| 798 | .builtin_call, | 796 | .builtin_call, |
lib/docs/wasm/markdown.zig+1-1| ... | @@ -149,7 +149,7 @@ fn mainImpl() !void { | ... | @@ -149,7 +149,7 @@ fn mainImpl() !void { |
| 149 | var stdin_reader = std.fs.File.stdin().reader(&stdin_buffer); | 149 | var stdin_reader = std.fs.File.stdin().reader(&stdin_buffer); |
| 150 | 150 | ||
| 151 | while (stdin_reader.takeDelimiterExclusive('\n')) |line| { | 151 | while (stdin_reader.takeDelimiterExclusive('\n')) |line| { |
| 152 | const trimmed = std.mem.trimRight(u8, line, '\r'); | 152 | const trimmed = std.mem.trimEnd(u8, line, '\r'); |
| 153 | try parser.feedLine(trimmed); | 153 | try parser.feedLine(trimmed); |
| 154 | } else |err| switch (err) { | 154 | } else |err| switch (err) { |
| 155 | error.EndOfStream => {}, | 155 | error.EndOfStream => {}, |
lib/std/Build/Step/Compile.zig+2-135| ... | @@ -188,9 +188,6 @@ force_undefined_symbols: std.StringHashMap(void), | ... | @@ -188,9 +188,6 @@ force_undefined_symbols: std.StringHashMap(void), |
| 188 | /// Overrides the default stack size | 188 | /// Overrides the default stack size |
| 189 | stack_size: ?u64 = null, | 189 | stack_size: ?u64 = null, |
| 190 | 190 | ||
| 191 | /// Deprecated; prefer using `lto`. | ||
| 192 | want_lto: ?bool = null, | ||
| 193 | |||
| 194 | use_llvm: ?bool, | 191 | use_llvm: ?bool, |
| 195 | use_lld: ?bool, | 192 | use_lld: ?bool, |
| 196 | use_new_linker: ?bool, | 193 | use_new_linker: ?bool, |
| ... | @@ -540,7 +537,7 @@ pub fn installHeadersDirectory( | ... | @@ -540,7 +537,7 @@ pub fn installHeadersDirectory( |
| 540 | /// When a module links with this artifact, all headers marked for installation are added to that | 537 | /// When a module links with this artifact, all headers marked for installation are added to that |
| 541 | /// module's include search path. | 538 | /// module's include search path. |
| 542 | pub fn installConfigHeader(cs: *Compile, config_header: *Step.ConfigHeader) void { | 539 | pub fn installConfigHeader(cs: *Compile, config_header: *Step.ConfigHeader) void { |
| 543 | cs.installHeader(config_header.getOutput(), config_header.include_path); | 540 | cs.installHeader(config_header.getOutputFile(), config_header.include_path); |
| 544 | } | 541 | } |
| 545 | 542 | ||
| 546 | /// Forwards all headers marked for installation from `lib` to this artifact. | 543 | /// Forwards all headers marked for installation from `lib` to this artifact. |
| ... | @@ -683,18 +680,6 @@ pub fn producesImplib(compile: *Compile) bool { | ... | @@ -683,18 +680,6 @@ pub fn producesImplib(compile: *Compile) bool { |
| 683 | return compile.isDll(); | 680 | return compile.isDll(); |
| 684 | } | 681 | } |
| 685 | 682 | ||
| 686 | /// Deprecated; use `compile.root_module.link_libc = true` instead. | ||
| 687 | /// To be removed after 0.15.0 is tagged. | ||
| 688 | pub fn linkLibC(compile: *Compile) void { | ||
| 689 | compile.root_module.link_libc = true; | ||
| 690 | } | ||
| 691 | |||
| 692 | /// Deprecated; use `compile.root_module.link_libcpp = true` instead. | ||
| 693 | /// To be removed after 0.15.0 is tagged. | ||
| 694 | pub fn linkLibCpp(compile: *Compile) void { | ||
| 695 | compile.root_module.link_libcpp = true; | ||
| 696 | } | ||
| 697 | |||
| 698 | const PkgConfigResult = struct { | 683 | const PkgConfigResult = struct { |
| 699 | cflags: []const []const u8, | 684 | cflags: []const []const u8, |
| 700 | libs: []const []const u8, | 685 | libs: []const []const u8, |
| ... | @@ -808,46 +793,6 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult { | ... | @@ -808,46 +793,6 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult { |
| 808 | }; | 793 | }; |
| 809 | } | 794 | } |
| 810 | 795 | ||
| 811 | /// Deprecated; use `compile.root_module.linkSystemLibrary(name, .{})` instead. | ||
| 812 | /// To be removed after 0.15.0 is tagged. | ||
| 813 | pub fn linkSystemLibrary(compile: *Compile, name: []const u8) void { | ||
| 814 | return compile.root_module.linkSystemLibrary(name, .{}); | ||
| 815 | } | ||
| 816 | |||
| 817 | /// Deprecated; use `compile.root_module.linkSystemLibrary(name, options)` instead. | ||
| 818 | /// To be removed after 0.15.0 is tagged. | ||
| 819 | pub fn linkSystemLibrary2( | ||
| 820 | compile: *Compile, | ||
| 821 | name: []const u8, | ||
| 822 | options: Module.LinkSystemLibraryOptions, | ||
| 823 | ) void { | ||
| 824 | return compile.root_module.linkSystemLibrary(name, options); | ||
| 825 | } | ||
| 826 | |||
| 827 | /// Deprecated; use `c.root_module.linkFramework(name, .{})` instead. | ||
| 828 | /// To be removed after 0.15.0 is tagged. | ||
| 829 | pub fn linkFramework(c: *Compile, name: []const u8) void { | ||
| 830 | c.root_module.linkFramework(name, .{}); | ||
| 831 | } | ||
| 832 | |||
| 833 | /// Deprecated; use `compile.root_module.addCSourceFiles(options)` instead. | ||
| 834 | /// To be removed after 0.15.0 is tagged. | ||
| 835 | pub fn addCSourceFiles(compile: *Compile, options: Module.AddCSourceFilesOptions) void { | ||
| 836 | compile.root_module.addCSourceFiles(options); | ||
| 837 | } | ||
| 838 | |||
| 839 | /// Deprecated; use `compile.root_module.addCSourceFile(source)` instead. | ||
| 840 | /// To be removed after 0.15.0 is tagged. | ||
| 841 | pub fn addCSourceFile(compile: *Compile, source: Module.CSourceFile) void { | ||
| 842 | compile.root_module.addCSourceFile(source); | ||
| 843 | } | ||
| 844 | |||
| 845 | /// Deprecated; use `compile.root_module.addWin32ResourceFile(source)` instead. | ||
| 846 | /// To be removed after 0.15.0 is tagged. | ||
| 847 | pub fn addWin32ResourceFile(compile: *Compile, source: Module.RcSourceFile) void { | ||
| 848 | compile.root_module.addWin32ResourceFile(source); | ||
| 849 | } | ||
| 850 | |||
| 851 | pub fn setVerboseLink(compile: *Compile, value: bool) void { | 796 | pub fn setVerboseLink(compile: *Compile, value: bool) void { |
| 852 | compile.verbose_link = value; | 797 | compile.verbose_link = value; |
| 853 | } | 798 | } |
| ... | @@ -929,84 +874,6 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath { | ... | @@ -929,84 +874,6 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath { |
| 929 | return compile.getEmittedFileGeneric(&compile.generated_llvm_bc); | 874 | return compile.getEmittedFileGeneric(&compile.generated_llvm_bc); |
| 930 | } | 875 | } |
| 931 | 876 | ||
| 932 | /// Deprecated; use `compile.root_module.addAssemblyFile(source)` instead. | ||
| 933 | /// To be removed after 0.15.0 is tagged. | ||
| 934 | pub fn addAssemblyFile(compile: *Compile, source: LazyPath) void { | ||
| 935 | compile.root_module.addAssemblyFile(source); | ||
| 936 | } | ||
| 937 | |||
| 938 | /// Deprecated; use `compile.root_module.addObjectFile(source)` instead. | ||
| 939 | /// To be removed after 0.15.0 is tagged. | ||
| 940 | pub fn addObjectFile(compile: *Compile, source: LazyPath) void { | ||
| 941 | compile.root_module.addObjectFile(source); | ||
| 942 | } | ||
| 943 | |||
| 944 | /// Deprecated; use `compile.root_module.addObject(object)` instead. | ||
| 945 | /// To be removed after 0.15.0 is tagged. | ||
| 946 | pub fn addObject(compile: *Compile, object: *Compile) void { | ||
| 947 | compile.root_module.addObject(object); | ||
| 948 | } | ||
| 949 | |||
| 950 | /// Deprecated; use `compile.root_module.linkLibrary(library)` instead. | ||
| 951 | /// To be removed after 0.15.0 is tagged. | ||
| 952 | pub fn linkLibrary(compile: *Compile, library: *Compile) void { | ||
| 953 | compile.root_module.linkLibrary(library); | ||
| 954 | } | ||
| 955 | |||
| 956 | /// Deprecated; use `compile.root_module.addAfterIncludePath(lazy_path)` instead. | ||
| 957 | /// To be removed after 0.15.0 is tagged. | ||
| 958 | pub fn addAfterIncludePath(compile: *Compile, lazy_path: LazyPath) void { | ||
| 959 | compile.root_module.addAfterIncludePath(lazy_path); | ||
| 960 | } | ||
| 961 | |||
| 962 | /// Deprecated; use `compile.root_module.addSystemIncludePath(lazy_path)` instead. | ||
| 963 | /// To be removed after 0.15.0 is tagged. | ||
| 964 | pub fn addSystemIncludePath(compile: *Compile, lazy_path: LazyPath) void { | ||
| 965 | compile.root_module.addSystemIncludePath(lazy_path); | ||
| 966 | } | ||
| 967 | |||
| 968 | /// Deprecated; use `compile.root_module.addIncludePath(lazy_path)` instead. | ||
| 969 | /// To be removed after 0.15.0 is tagged. | ||
| 970 | pub fn addIncludePath(compile: *Compile, lazy_path: LazyPath) void { | ||
| 971 | compile.root_module.addIncludePath(lazy_path); | ||
| 972 | } | ||
| 973 | |||
| 974 | /// Deprecated; use `compile.root_module.addConfigHeader(config_header)` instead. | ||
| 975 | /// To be removed after 0.15.0 is tagged. | ||
| 976 | pub fn addConfigHeader(compile: *Compile, config_header: *Step.ConfigHeader) void { | ||
| 977 | compile.root_module.addConfigHeader(config_header); | ||
| 978 | } | ||
| 979 | |||
| 980 | /// Deprecated; use `compile.root_module.addEmbedPath(lazy_path)` instead. | ||
| 981 | /// To be removed after 0.15.0 is tagged. | ||
| 982 | pub fn addEmbedPath(compile: *Compile, lazy_path: LazyPath) void { | ||
| 983 | compile.root_module.addEmbedPath(lazy_path); | ||
| 984 | } | ||
| 985 | |||
| 986 | /// Deprecated; use `compile.root_module.addLibraryPath(directory_path)` instead. | ||
| 987 | /// To be removed after 0.15.0 is tagged. | ||
| 988 | pub fn addLibraryPath(compile: *Compile, directory_path: LazyPath) void { | ||
| 989 | compile.root_module.addLibraryPath(directory_path); | ||
| 990 | } | ||
| 991 | |||
| 992 | /// Deprecated; use `compile.root_module.addRPath(directory_path)` instead. | ||
| 993 | /// To be removed after 0.15.0 is tagged. | ||
| 994 | pub fn addRPath(compile: *Compile, directory_path: LazyPath) void { | ||
| 995 | compile.root_module.addRPath(directory_path); | ||
| 996 | } | ||
| 997 | |||
| 998 | /// Deprecated; use `compile.root_module.addSystemFrameworkPath(directory_path)` instead. | ||
| 999 | /// To be removed after 0.15.0 is tagged. | ||
| 1000 | pub fn addSystemFrameworkPath(compile: *Compile, directory_path: LazyPath) void { | ||
| 1001 | compile.root_module.addSystemFrameworkPath(directory_path); | ||
| 1002 | } | ||
| 1003 | |||
| 1004 | /// Deprecated; use `compile.root_module.addFrameworkPath(directory_path)` instead. | ||
| 1005 | /// To be removed after 0.15.0 is tagged. | ||
| 1006 | pub fn addFrameworkPath(compile: *Compile, directory_path: LazyPath) void { | ||
| 1007 | compile.root_module.addFrameworkPath(directory_path); | ||
| 1008 | } | ||
| 1009 | |||
| 1010 | pub fn setExecCmd(compile: *Compile, args: []const ?[]const u8) void { | 877 | pub fn setExecCmd(compile: *Compile, args: []const ?[]const u8) void { |
| 1011 | const b = compile.step.owner; | 878 | const b = compile.step.owner; |
| 1012 | assert(compile.kind == .@"test"); | 879 | assert(compile.kind == .@"test"); |
| ... | @@ -1763,7 +1630,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { | ... | @@ -1763,7 +1630,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { |
| 1763 | .thin => "-flto=thin", | 1630 | .thin => "-flto=thin", |
| 1764 | .none => "-fno-lto", | 1631 | .none => "-fno-lto", |
| 1765 | }); | 1632 | }); |
| 1766 | } else try addFlag(&zig_args, "lto", compile.want_lto); | 1633 | } |
| 1767 | 1634 | ||
| 1768 | try addFlag(&zig_args, "sanitize-coverage-trace-pc-guard", compile.sanitize_coverage_trace_pc_guard); | 1635 | try addFlag(&zig_args, "sanitize-coverage-trace-pc-guard", compile.sanitize_coverage_trace_pc_guard); |
| 1769 | 1636 |
lib/std/Build/Step/ConfigHeader.zig-3| ... | @@ -124,9 +124,6 @@ pub fn getOutputFile(ch: *ConfigHeader) std.Build.LazyPath { | ... | @@ -124,9 +124,6 @@ pub fn getOutputFile(ch: *ConfigHeader) std.Build.LazyPath { |
| 124 | return ch.getOutputDir().path(ch.step.owner, ch.include_path); | 124 | return ch.getOutputDir().path(ch.step.owner, ch.include_path); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | /// Deprecated; use `getOutputFile`. | ||
| 128 | pub const getOutput = getOutputFile; | ||
| 129 | |||
| 130 | fn addValueInner(config_header: *ConfigHeader, name: []const u8, comptime T: type, value: T) !void { | 127 | fn addValueInner(config_header: *ConfigHeader, name: []const u8, comptime T: type, value: T) !void { |
| 131 | switch (@typeInfo(T)) { | 128 | switch (@typeInfo(T)) { |
| 132 | .null => { | 129 | .null => { |
lib/std/Build/Step/Run.zig-5| ... | @@ -88,9 +88,6 @@ skip_foreign_checks: bool, | ... | @@ -88,9 +88,6 @@ skip_foreign_checks: bool, |
| 88 | /// external executor (such as qemu) but not fail if the executor is unavailable. | 88 | /// external executor (such as qemu) but not fail if the executor is unavailable. |
| 89 | failing_to_execute_foreign_is_an_error: bool, | 89 | failing_to_execute_foreign_is_an_error: bool, |
| 90 | 90 | ||
| 91 | /// Deprecated in favor of `stdio_limit`. | ||
| 92 | max_stdio_size: usize, | ||
| 93 | |||
| 94 | /// If stderr or stdout exceeds this amount, the child process is killed and | 91 | /// If stderr or stdout exceeds this amount, the child process is killed and |
| 95 | /// the step fails. | 92 | /// the step fails. |
| 96 | stdio_limit: std.Io.Limit, | 93 | stdio_limit: std.Io.Limit, |
| ... | @@ -223,7 +220,6 @@ pub fn create(owner: *std.Build, name: []const u8) *Run { | ... | @@ -223,7 +220,6 @@ pub fn create(owner: *std.Build, name: []const u8) *Run { |
| 223 | .rename_step_with_output_arg = true, | 220 | .rename_step_with_output_arg = true, |
| 224 | .skip_foreign_checks = false, | 221 | .skip_foreign_checks = false, |
| 225 | .failing_to_execute_foreign_is_an_error = true, | 222 | .failing_to_execute_foreign_is_an_error = true, |
| 226 | .max_stdio_size = 10 * 1024 * 1024, | ||
| 227 | .stdio_limit = .unlimited, | 223 | .stdio_limit = .unlimited, |
| 228 | .captured_stdout = null, | 224 | .captured_stdout = null, |
| 229 | .captured_stderr = null, | 225 | .captured_stderr = null, |
| ... | @@ -2217,7 +2213,6 @@ fn evalGeneric(run: *Run, child: *std.process.Child) !EvalGenericResult { | ... | @@ -2217,7 +2213,6 @@ fn evalGeneric(run: *Run, child: *std.process.Child) !EvalGenericResult { |
| 2217 | var stdout_bytes: ?[]const u8 = null; | 2213 | var stdout_bytes: ?[]const u8 = null; |
| 2218 | var stderr_bytes: ?[]const u8 = null; | 2214 | var stderr_bytes: ?[]const u8 = null; |
| 2219 | 2215 | ||
| 2220 | run.stdio_limit = run.stdio_limit.min(.limited(run.max_stdio_size)); | ||
| 2221 | if (child.stdout) |stdout| { | 2216 | if (child.stdout) |stdout| { |
| 2222 | if (child.stderr) |stderr| { | 2217 | if (child.stderr) |stderr| { |
| 2223 | var poller = std.Io.poll(arena, enum { stdout, stderr }, .{ | 2218 | var poller = std.Io.poll(arena, enum { stdout, stderr }, .{ |
lib/std/Io/Reader.zig+1-1| ... | @@ -1252,7 +1252,7 @@ pub const TakeEnumError = Error || error{InvalidEnumTag}; | ... | @@ -1252,7 +1252,7 @@ pub const TakeEnumError = Error || error{InvalidEnumTag}; |
| 1252 | pub fn takeEnum(r: *Reader, comptime Enum: type, endian: std.builtin.Endian) TakeEnumError!Enum { | 1252 | pub fn takeEnum(r: *Reader, comptime Enum: type, endian: std.builtin.Endian) TakeEnumError!Enum { |
| 1253 | const Tag = @typeInfo(Enum).@"enum".tag_type; | 1253 | const Tag = @typeInfo(Enum).@"enum".tag_type; |
| 1254 | const int = try r.takeInt(Tag, endian); | 1254 | const int = try r.takeInt(Tag, endian); |
| 1255 | return std.meta.intToEnum(Enum, int); | 1255 | return std.enums.fromInt(Enum, int) orelse return error.InvalidEnumTag; |
| 1256 | } | 1256 | } |
| 1257 | 1257 | ||
| 1258 | /// Reads an integer with the same size as the given nonexhaustive enum's tag type. | 1258 | /// Reads an integer with the same size as the given nonexhaustive enum's tag type. |
lib/std/Io/Writer.zig+1-5| ... | @@ -1211,10 +1211,6 @@ pub fn printValue( | ... | @@ -1211,10 +1211,6 @@ pub fn printValue( |
| 1211 | } | 1211 | } |
| 1212 | 1212 | ||
| 1213 | const is_any = comptime std.mem.eql(u8, fmt, ANY); | 1213 | const is_any = comptime std.mem.eql(u8, fmt, ANY); |
| 1214 | if (!is_any and std.meta.hasMethod(T, "format") and fmt.len == 0) { | ||
| 1215 | // after 0.15.0 is tagged, delete this compile error and its condition | ||
| 1216 | @compileError("ambiguous format string; specify {f} to call format method, or {any} to skip it"); | ||
| 1217 | } | ||
| 1218 | 1214 | ||
| 1219 | switch (@typeInfo(T)) { | 1215 | switch (@typeInfo(T)) { |
| 1220 | .float, .comptime_float => { | 1216 | .float, .comptime_float => { |
| ... | @@ -1702,7 +1698,7 @@ pub fn printFloatHex(w: *Writer, value: anytype, case: std.fmt.Case, opt_precisi | ... | @@ -1702,7 +1698,7 @@ pub fn printFloatHex(w: *Writer, value: anytype, case: std.fmt.Case, opt_precisi |
| 1702 | 1698 | ||
| 1703 | try w.writeAll("0x"); | 1699 | try w.writeAll("0x"); |
| 1704 | try w.writeByte(buf[0]); | 1700 | try w.writeByte(buf[0]); |
| 1705 | const trimmed = std.mem.trimRight(u8, buf[1..], "0"); | 1701 | const trimmed = std.mem.trimEnd(u8, buf[1..], "0"); |
| 1706 | if (opt_precision) |precision| { | 1702 | if (opt_precision) |precision| { |
| 1707 | if (precision > 0) try w.writeAll("."); | 1703 | if (precision > 0) try w.writeAll("."); |
| 1708 | } else if (trimmed.len > 0) { | 1704 | } else if (trimmed.len > 0) { |
lib/std/Io/tty.zig-5| ... | @@ -5,11 +5,6 @@ const process = std.process; | ... | @@ -5,11 +5,6 @@ const process = std.process; |
| 5 | const windows = std.os.windows; | 5 | const windows = std.os.windows; |
| 6 | const native_os = builtin.os.tag; | 6 | const native_os = builtin.os.tag; |
| 7 | 7 | ||
| 8 | /// Deprecated in favor of `Config.detect`. | ||
| 9 | pub fn detectConfig(file: File) Config { | ||
| 10 | return .detect(file); | ||
| 11 | } | ||
| 12 | |||
| 13 | pub const Color = enum { | 8 | pub const Color = enum { |
| 14 | black, | 9 | black, |
| 15 | red, | 10 | red, |
lib/std/crypto/tls/Client.zig+1-1| ... | @@ -1158,7 +1158,7 @@ fn readIndirect(c: *Client) Reader.Error!usize { | ... | @@ -1158,7 +1158,7 @@ fn readIndirect(c: *Client) Reader.Error!usize { |
| 1158 | P.AEAD.decrypt(cleartext, ciphertext, auth_tag, ad, nonce, pv.server_key) catch | 1158 | P.AEAD.decrypt(cleartext, ciphertext, auth_tag, ad, nonce, pv.server_key) catch |
| 1159 | return failRead(c, error.TlsBadRecordMac); | 1159 | return failRead(c, error.TlsBadRecordMac); |
| 1160 | // TODO use scalar, non-slice version | 1160 | // TODO use scalar, non-slice version |
| 1161 | const msg = mem.trimRight(u8, cleartext, "\x00"); | 1161 | const msg = mem.trimEnd(u8, cleartext, "\x00"); |
| 1162 | break :cleartext .{ msg.len - 1, @enumFromInt(msg[msg.len - 1]) }; | 1162 | break :cleartext .{ msg.len - 1, @enumFromInt(msg[msg.len - 1]) }; |
| 1163 | }, | 1163 | }, |
| 1164 | .tls_1_2 => { | 1164 | .tls_1_2 => { |
lib/std/debug.zig+4-4| ... | @@ -329,16 +329,16 @@ pub fn dumpHex(bytes: []const u8) void { | ... | @@ -329,16 +329,16 @@ pub fn dumpHex(bytes: []const u8) void { |
| 329 | } | 329 | } |
| 330 | 330 | ||
| 331 | /// Prints a hexadecimal view of the bytes, returning any error that occurs. | 331 | /// Prints a hexadecimal view of the bytes, returning any error that occurs. |
| 332 | pub fn dumpHexFallible(bw: *Writer, ttyconf: tty.Config, bytes: []const u8) !void { | 332 | pub fn dumpHexFallible(bw: *Writer, tty_config: tty.Config, bytes: []const u8) !void { |
| 333 | var chunks = mem.window(u8, bytes, 16, 16); | 333 | var chunks = mem.window(u8, bytes, 16, 16); |
| 334 | while (chunks.next()) |window| { | 334 | while (chunks.next()) |window| { |
| 335 | // 1. Print the address. | 335 | // 1. Print the address. |
| 336 | const address = (@intFromPtr(bytes.ptr) + 0x10 * (std.math.divCeil(usize, chunks.index orelse bytes.len, 16) catch unreachable)) - 0x10; | 336 | const address = (@intFromPtr(bytes.ptr) + 0x10 * (std.math.divCeil(usize, chunks.index orelse bytes.len, 16) catch unreachable)) - 0x10; |
| 337 | try ttyconf.setColor(bw, .dim); | 337 | try tty_config.setColor(bw, .dim); |
| 338 | // We print the address in lowercase and the bytes in uppercase hexadecimal to distinguish them more. | 338 | // We print the address in lowercase and the bytes in uppercase hexadecimal to distinguish them more. |
| 339 | // Also, make sure all lines are aligned by padding the address. | 339 | // Also, make sure all lines are aligned by padding the address. |
| 340 | try bw.print("{x:0>[1]} ", .{ address, @sizeOf(usize) * 2 }); | 340 | try bw.print("{x:0>[1]} ", .{ address, @sizeOf(usize) * 2 }); |
| 341 | try ttyconf.setColor(bw, .reset); | 341 | try tty_config.setColor(bw, .reset); |
| 342 | 342 | ||
| 343 | // 2. Print the bytes. | 343 | // 2. Print the bytes. |
| 344 | for (window, 0..) |byte, index| { | 344 | for (window, 0..) |byte, index| { |
| ... | @@ -358,7 +358,7 @@ pub fn dumpHexFallible(bw: *Writer, ttyconf: tty.Config, bytes: []const u8) !voi | ... | @@ -358,7 +358,7 @@ pub fn dumpHexFallible(bw: *Writer, ttyconf: tty.Config, bytes: []const u8) !voi |
| 358 | try bw.writeByte(byte); | 358 | try bw.writeByte(byte); |
| 359 | } else { | 359 | } else { |
| 360 | // Related: https://github.com/ziglang/zig/issues/7600 | 360 | // Related: https://github.com/ziglang/zig/issues/7600 |
| 361 | if (ttyconf == .windows_api) { | 361 | if (tty_config == .windows_api) { |
| 362 | try bw.writeByte('.'); | 362 | try bw.writeByte('.'); |
| 363 | continue; | 363 | continue; |
| 364 | } | 364 | } |
lib/std/enums.zig-42| ... | @@ -202,48 +202,6 @@ test "directEnumArrayDefault slice" { | ... | @@ -202,48 +202,6 @@ test "directEnumArrayDefault slice" { |
| 202 | try testing.expectEqualSlices(u8, "default", array[2]); | 202 | try testing.expectEqualSlices(u8, "default", array[2]); |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | /// Deprecated: Use @field(E, @tagName(tag)) or @field(E, string) | ||
| 206 | pub fn nameCast(comptime E: type, comptime value: anytype) E { | ||
| 207 | return comptime blk: { | ||
| 208 | const V = @TypeOf(value); | ||
| 209 | if (V == E) break :blk value; | ||
| 210 | const name: ?[]const u8 = switch (@typeInfo(V)) { | ||
| 211 | .enum_literal, .@"enum" => @tagName(value), | ||
| 212 | .pointer => value, | ||
| 213 | else => null, | ||
| 214 | }; | ||
| 215 | if (name) |n| { | ||
| 216 | if (@hasField(E, n)) { | ||
| 217 | break :blk @field(E, n); | ||
| 218 | } | ||
| 219 | @compileError("Enum " ++ @typeName(E) ++ " has no field named " ++ n); | ||
| 220 | } | ||
| 221 | @compileError("Cannot cast from " ++ @typeName(@TypeOf(value)) ++ " to " ++ @typeName(E)); | ||
| 222 | }; | ||
| 223 | } | ||
| 224 | |||
| 225 | test nameCast { | ||
| 226 | const A = enum(u1) { a = 0, b = 1 }; | ||
| 227 | const B = enum(u1) { a = 1, b = 0 }; | ||
| 228 | try testing.expectEqual(A.a, nameCast(A, .a)); | ||
| 229 | try testing.expectEqual(A.a, nameCast(A, A.a)); | ||
| 230 | try testing.expectEqual(A.a, nameCast(A, B.a)); | ||
| 231 | try testing.expectEqual(A.a, nameCast(A, "a")); | ||
| 232 | try testing.expectEqual(A.a, nameCast(A, @as(*const [1]u8, "a"))); | ||
| 233 | try testing.expectEqual(A.a, nameCast(A, @as([:0]const u8, "a"))); | ||
| 234 | try testing.expectEqual(A.a, nameCast(A, @as([]const u8, "a"))); | ||
| 235 | |||
| 236 | try testing.expectEqual(B.a, nameCast(B, .a)); | ||
| 237 | try testing.expectEqual(B.a, nameCast(B, A.a)); | ||
| 238 | try testing.expectEqual(B.a, nameCast(B, B.a)); | ||
| 239 | try testing.expectEqual(B.a, nameCast(B, "a")); | ||
| 240 | |||
| 241 | try testing.expectEqual(B.b, nameCast(B, .b)); | ||
| 242 | try testing.expectEqual(B.b, nameCast(B, A.b)); | ||
| 243 | try testing.expectEqual(B.b, nameCast(B, B.b)); | ||
| 244 | try testing.expectEqual(B.b, nameCast(B, "b")); | ||
| 245 | } | ||
| 246 | |||
| 247 | test fromInt { | 205 | test fromInt { |
| 248 | const E1 = enum { | 206 | const E1 = enum { |
| 249 | A, | 207 | A, |
lib/std/heap/debug_allocator.zig+8-8| ... | @@ -460,7 +460,7 @@ pub fn DebugAllocator(comptime config: Config) type { | ... | @@ -460,7 +460,7 @@ pub fn DebugAllocator(comptime config: Config) type { |
| 460 | pub fn detectLeaks(self: *Self) usize { | 460 | pub fn detectLeaks(self: *Self) usize { |
| 461 | var leaks: usize = 0; | 461 | var leaks: usize = 0; |
| 462 | 462 | ||
| 463 | const tty_config = std.Io.tty.detectConfig(.stderr()); | 463 | const tty_config: std.Io.tty.Config = .detect(.stderr()); |
| 464 | 464 | ||
| 465 | for (self.buckets, 0..) |init_optional_bucket, size_class_index| { | 465 | for (self.buckets, 0..) |init_optional_bucket, size_class_index| { |
| 466 | var optional_bucket = init_optional_bucket; | 466 | var optional_bucket = init_optional_bucket; |
| ... | @@ -536,7 +536,7 @@ pub fn DebugAllocator(comptime config: Config) type { | ... | @@ -536,7 +536,7 @@ pub fn DebugAllocator(comptime config: Config) type { |
| 536 | fn reportDoubleFree(ret_addr: usize, alloc_stack_trace: StackTrace, free_stack_trace: StackTrace) void { | 536 | fn reportDoubleFree(ret_addr: usize, alloc_stack_trace: StackTrace, free_stack_trace: StackTrace) void { |
| 537 | var addr_buf: [stack_n]usize = undefined; | 537 | var addr_buf: [stack_n]usize = undefined; |
| 538 | const second_free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf); | 538 | const second_free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf); |
| 539 | const tty_config = std.Io.tty.detectConfig(.stderr()); | 539 | const tty_config: std.Io.tty.Config = .detect(.stderr()); |
| 540 | log.err("Double free detected. Allocation: {f} First free: {f} Second free: {f}", .{ | 540 | log.err("Double free detected. Allocation: {f} First free: {f} Second free: {f}", .{ |
| 541 | std.debug.FormatStackTrace{ | 541 | std.debug.FormatStackTrace{ |
| 542 | .stack_trace = alloc_stack_trace, | 542 | .stack_trace = alloc_stack_trace, |
| ... | @@ -590,7 +590,7 @@ pub fn DebugAllocator(comptime config: Config) type { | ... | @@ -590,7 +590,7 @@ pub fn DebugAllocator(comptime config: Config) type { |
| 590 | if (config.safety and old_mem.len != entry.value_ptr.bytes.len) { | 590 | if (config.safety and old_mem.len != entry.value_ptr.bytes.len) { |
| 591 | var addr_buf: [stack_n]usize = undefined; | 591 | var addr_buf: [stack_n]usize = undefined; |
| 592 | const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf); | 592 | const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf); |
| 593 | const tty_config = std.Io.tty.detectConfig(.stderr()); | 593 | const tty_config: std.Io.tty.Config = .detect(.stderr()); |
| 594 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ | 594 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ |
| 595 | entry.value_ptr.bytes.len, | 595 | entry.value_ptr.bytes.len, |
| 596 | old_mem.len, | 596 | old_mem.len, |
| ... | @@ -703,7 +703,7 @@ pub fn DebugAllocator(comptime config: Config) type { | ... | @@ -703,7 +703,7 @@ pub fn DebugAllocator(comptime config: Config) type { |
| 703 | if (config.safety and old_mem.len != entry.value_ptr.bytes.len) { | 703 | if (config.safety and old_mem.len != entry.value_ptr.bytes.len) { |
| 704 | var addr_buf: [stack_n]usize = undefined; | 704 | var addr_buf: [stack_n]usize = undefined; |
| 705 | const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf); | 705 | const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf); |
| 706 | const tty_config = std.Io.tty.detectConfig(.stderr()); | 706 | const tty_config: std.Io.tty.Config = .detect(.stderr()); |
| 707 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ | 707 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ |
| 708 | entry.value_ptr.bytes.len, | 708 | entry.value_ptr.bytes.len, |
| 709 | old_mem.len, | 709 | old_mem.len, |
| ... | @@ -935,7 +935,7 @@ pub fn DebugAllocator(comptime config: Config) type { | ... | @@ -935,7 +935,7 @@ pub fn DebugAllocator(comptime config: Config) type { |
| 935 | var addr_buf: [stack_n]usize = undefined; | 935 | var addr_buf: [stack_n]usize = undefined; |
| 936 | const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = return_address }, &addr_buf); | 936 | const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = return_address }, &addr_buf); |
| 937 | if (old_memory.len != requested_size) { | 937 | if (old_memory.len != requested_size) { |
| 938 | const tty_config = std.Io.tty.detectConfig(.stderr()); | 938 | const tty_config: std.Io.tty.Config = .detect(.stderr()); |
| 939 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ | 939 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ |
| 940 | requested_size, | 940 | requested_size, |
| 941 | old_memory.len, | 941 | old_memory.len, |
| ... | @@ -950,7 +950,7 @@ pub fn DebugAllocator(comptime config: Config) type { | ... | @@ -950,7 +950,7 @@ pub fn DebugAllocator(comptime config: Config) type { |
| 950 | }); | 950 | }); |
| 951 | } | 951 | } |
| 952 | if (alignment != slot_alignment) { | 952 | if (alignment != slot_alignment) { |
| 953 | const tty_config = std.Io.tty.detectConfig(.stderr()); | 953 | const tty_config: std.Io.tty.Config = .detect(.stderr()); |
| 954 | log.err("Allocation alignment {d} does not match free alignment {d}. Allocation: {f} Free: {f}", .{ | 954 | log.err("Allocation alignment {d} does not match free alignment {d}. Allocation: {f} Free: {f}", .{ |
| 955 | slot_alignment.toByteUnits(), | 955 | slot_alignment.toByteUnits(), |
| 956 | alignment.toByteUnits(), | 956 | alignment.toByteUnits(), |
| ... | @@ -1044,7 +1044,7 @@ pub fn DebugAllocator(comptime config: Config) type { | ... | @@ -1044,7 +1044,7 @@ pub fn DebugAllocator(comptime config: Config) type { |
| 1044 | var addr_buf: [stack_n]usize = undefined; | 1044 | var addr_buf: [stack_n]usize = undefined; |
| 1045 | const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = return_address }, &addr_buf); | 1045 | const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = return_address }, &addr_buf); |
| 1046 | if (memory.len != requested_size) { | 1046 | if (memory.len != requested_size) { |
| 1047 | const tty_config = std.Io.tty.detectConfig(.stderr()); | 1047 | const tty_config: std.Io.tty.Config = .detect(.stderr()); |
| 1048 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ | 1048 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ |
| 1049 | requested_size, | 1049 | requested_size, |
| 1050 | memory.len, | 1050 | memory.len, |
| ... | @@ -1059,7 +1059,7 @@ pub fn DebugAllocator(comptime config: Config) type { | ... | @@ -1059,7 +1059,7 @@ pub fn DebugAllocator(comptime config: Config) type { |
| 1059 | }); | 1059 | }); |
| 1060 | } | 1060 | } |
| 1061 | if (alignment != slot_alignment) { | 1061 | if (alignment != slot_alignment) { |
| 1062 | const tty_config = std.Io.tty.detectConfig(.stderr()); | 1062 | const tty_config: std.Io.tty.Config = .detect(.stderr()); |
| 1063 | log.err("Allocation alignment {d} does not match free alignment {d}. Allocation: {f} Free: {f}", .{ | 1063 | log.err("Allocation alignment {d} does not match free alignment {d}. Allocation: {f} Free: {f}", .{ |
| 1064 | slot_alignment.toByteUnits(), | 1064 | slot_alignment.toByteUnits(), |
| 1065 | alignment.toByteUnits(), | 1065 | alignment.toByteUnits(), |
lib/std/http/Client.zig+1-1| ... | @@ -529,7 +529,7 @@ pub const Response = struct { | ... | @@ -529,7 +529,7 @@ pub const Response = struct { |
| 529 | }; | 529 | }; |
| 530 | if (first_line[8] != ' ') return error.HttpHeadersInvalid; | 530 | if (first_line[8] != ' ') return error.HttpHeadersInvalid; |
| 531 | const status: http.Status = @enumFromInt(parseInt3(first_line[9..12])); | 531 | const status: http.Status = @enumFromInt(parseInt3(first_line[9..12])); |
| 532 | const reason = mem.trimLeft(u8, first_line[12..], " "); | 532 | const reason = mem.trimStart(u8, first_line[12..], " "); |
| 533 | 533 | ||
| 534 | res.version = version; | 534 | res.version = version; |
| 535 | res.status = status; | 535 | res.status = status; |
lib/std/mem.zig-6| ... | @@ -1221,9 +1221,6 @@ test trimStart { | ... | @@ -1221,9 +1221,6 @@ test trimStart { |
| 1221 | try testing.expectEqualSlices(u8, "foo\n ", trimStart(u8, " foo\n ", " \n")); | 1221 | try testing.expectEqualSlices(u8, "foo\n ", trimStart(u8, " foo\n ", " \n")); |
| 1222 | } | 1222 | } |
| 1223 | 1223 | ||
| 1224 | /// Deprecated: use `trimStart` instead. | ||
| 1225 | pub const trimLeft = trimStart; | ||
| 1226 | |||
| 1227 | /// Remove a set of values from the end of a slice. | 1224 | /// Remove a set of values from the end of a slice. |
| 1228 | pub fn trimEnd(comptime T: type, slice: []const T, values_to_strip: []const T) []const T { | 1225 | pub fn trimEnd(comptime T: type, slice: []const T, values_to_strip: []const T) []const T { |
| 1229 | var end: usize = slice.len; | 1226 | var end: usize = slice.len; |
| ... | @@ -1235,9 +1232,6 @@ test trimEnd { | ... | @@ -1235,9 +1232,6 @@ test trimEnd { |
| 1235 | try testing.expectEqualSlices(u8, " foo", trimEnd(u8, " foo\n ", " \n")); | 1232 | try testing.expectEqualSlices(u8, " foo", trimEnd(u8, " foo\n ", " \n")); |
| 1236 | } | 1233 | } |
| 1237 | 1234 | ||
| 1238 | /// Deprecated: use `trimEnd` instead. | ||
| 1239 | pub const trimRight = trimEnd; | ||
| 1240 | |||
| 1241 | /// Remove a set of values from the beginning and end of a slice. | 1235 | /// Remove a set of values from the beginning and end of a slice. |
| 1242 | pub fn trim(comptime T: type, slice: []const T, values_to_strip: []const T) []const T { | 1236 | pub fn trim(comptime T: type, slice: []const T, values_to_strip: []const T) []const T { |
| 1243 | var begin: usize = 0; | 1237 | var begin: usize = 0; |
lib/std/meta.zig-40| ... | @@ -614,38 +614,6 @@ test activeTag { | ... | @@ -614,38 +614,6 @@ test activeTag { |
| 614 | try testing.expect(activeTag(u) == UE.Float); | 614 | try testing.expect(activeTag(u) == UE.Float); |
| 615 | } | 615 | } |
| 616 | 616 | ||
| 617 | /// Deprecated: Use @FieldType(U, tag_name) | ||
| 618 | const TagPayloadType = TagPayload; | ||
| 619 | |||
| 620 | /// Deprecated: Use @FieldType(U, tag_name) | ||
| 621 | pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type { | ||
| 622 | const info = @typeInfo(U).@"union"; | ||
| 623 | |||
| 624 | inline for (info.fields) |field_info| { | ||
| 625 | if (comptime mem.eql(u8, field_info.name, tag_name)) | ||
| 626 | return field_info.type; | ||
| 627 | } | ||
| 628 | |||
| 629 | @compileError("no field '" ++ tag_name ++ "' in union '" ++ @typeName(U) ++ "'"); | ||
| 630 | } | ||
| 631 | |||
| 632 | /// Deprecated: Use @FieldType(U, @tagName(tag)) | ||
| 633 | pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type { | ||
| 634 | return TagPayloadByName(U, @tagName(tag)); | ||
| 635 | } | ||
| 636 | |||
| 637 | test TagPayload { | ||
| 638 | const Event = union(enum) { | ||
| 639 | Moved: struct { | ||
| 640 | from: i32, | ||
| 641 | to: i32, | ||
| 642 | }, | ||
| 643 | }; | ||
| 644 | const MovedEvent = TagPayload(Event, Event.Moved); | ||
| 645 | const e: Event = .{ .Moved = undefined }; | ||
| 646 | try testing.expect(MovedEvent == @TypeOf(e.Moved)); | ||
| 647 | } | ||
| 648 | |||
| 649 | /// Compares two of any type for equality. Containers that do not support comparison | 617 | /// Compares two of any type for equality. Containers that do not support comparison |
| 650 | /// on their own are compared on a field-by-field basis. Pointers are not followed. | 618 | /// on their own are compared on a field-by-field basis. Pointers are not followed. |
| 651 | pub fn eql(a: anytype, b: @TypeOf(a)) bool { | 619 | pub fn eql(a: anytype, b: @TypeOf(a)) bool { |
| ... | @@ -774,14 +742,6 @@ test eql { | ... | @@ -774,14 +742,6 @@ test eql { |
| 774 | try testing.expect(!eql(v1, v3)); | 742 | try testing.expect(!eql(v1, v3)); |
| 775 | } | 743 | } |
| 776 | 744 | ||
| 777 | /// Deprecated: use `std.enums.fromInt` instead and handle null. | ||
| 778 | pub const IntToEnumError = error{InvalidEnumTag}; | ||
| 779 | |||
| 780 | /// Deprecated: use `std.enums.fromInt` instead and handle null instead of an error. | ||
| 781 | pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTag { | ||
| 782 | return std.enums.fromInt(EnumTag, tag_int) orelse return error.InvalidEnumTag; | ||
| 783 | } | ||
| 784 | |||
| 785 | /// Given a type and a name, return the field index according to source order. | 745 | /// Given a type and a name, return the field index according to source order. |
| 786 | /// Returns `null` if the field is not found. | 746 | /// Returns `null` if the field is not found. |
| 787 | pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int { | 747 | pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int { |
lib/std/os/linux/test.zig+7-7| ... | @@ -138,23 +138,23 @@ test "sigset_t" { | ... | @@ -138,23 +138,23 @@ test "sigset_t" { |
| 138 | // See that none are set, then set each one, see that they're all set, then | 138 | // See that none are set, then set each one, see that they're all set, then |
| 139 | // remove them all, and then see that none are set. | 139 | // remove them all, and then see that none are set. |
| 140 | for (1..linux.NSIG) |i| { | 140 | for (1..linux.NSIG) |i| { |
| 141 | const sig = std.meta.intToEnum(SIG, i) catch continue; | 141 | const sig = std.enums.fromInt(SIG, i) orelse continue; |
| 142 | try expectEqual(false, linux.sigismember(&sigset, sig)); | 142 | try expectEqual(false, linux.sigismember(&sigset, sig)); |
| 143 | } | 143 | } |
| 144 | for (1..linux.NSIG) |i| { | 144 | for (1..linux.NSIG) |i| { |
| 145 | const sig = std.meta.intToEnum(SIG, i) catch continue; | 145 | const sig = std.enums.fromInt(SIG, i) orelse continue; |
| 146 | linux.sigaddset(&sigset, sig); | 146 | linux.sigaddset(&sigset, sig); |
| 147 | } | 147 | } |
| 148 | for (1..linux.NSIG) |i| { | 148 | for (1..linux.NSIG) |i| { |
| 149 | const sig = std.meta.intToEnum(SIG, i) catch continue; | 149 | const sig = std.enums.fromInt(SIG, i) orelse continue; |
| 150 | try expectEqual(true, linux.sigismember(&sigset, sig)); | 150 | try expectEqual(true, linux.sigismember(&sigset, sig)); |
| 151 | } | 151 | } |
| 152 | for (1..linux.NSIG) |i| { | 152 | for (1..linux.NSIG) |i| { |
| 153 | const sig = std.meta.intToEnum(SIG, i) catch continue; | 153 | const sig = std.enums.fromInt(SIG, i) orelse continue; |
| 154 | linux.sigdelset(&sigset, sig); | 154 | linux.sigdelset(&sigset, sig); |
| 155 | } | 155 | } |
| 156 | for (1..linux.NSIG) |i| { | 156 | for (1..linux.NSIG) |i| { |
| 157 | const sig = std.meta.intToEnum(SIG, i) catch continue; | 157 | const sig = std.enums.fromInt(SIG, i) orelse continue; |
| 158 | try expectEqual(false, linux.sigismember(&sigset, sig)); | 158 | try expectEqual(false, linux.sigismember(&sigset, sig)); |
| 159 | } | 159 | } |
| 160 | } | 160 | } |
| ... | @@ -163,7 +163,7 @@ test "sigfillset" { | ... | @@ -163,7 +163,7 @@ test "sigfillset" { |
| 163 | // unlike the C library, all the signals are set in the kernel-level fillset | 163 | // unlike the C library, all the signals are set in the kernel-level fillset |
| 164 | const sigset = linux.sigfillset(); | 164 | const sigset = linux.sigfillset(); |
| 165 | for (1..linux.NSIG) |i| { | 165 | for (1..linux.NSIG) |i| { |
| 166 | const sig = std.meta.intToEnum(linux.SIG, i) catch continue; | 166 | const sig = std.enums.fromInt(linux.SIG, i) orelse continue; |
| 167 | try expectEqual(true, linux.sigismember(&sigset, sig)); | 167 | try expectEqual(true, linux.sigismember(&sigset, sig)); |
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| ... | @@ -171,7 +171,7 @@ test "sigfillset" { | ... | @@ -171,7 +171,7 @@ test "sigfillset" { |
| 171 | test "sigemptyset" { | 171 | test "sigemptyset" { |
| 172 | const sigset = linux.sigemptyset(); | 172 | const sigset = linux.sigemptyset(); |
| 173 | for (1..linux.NSIG) |i| { | 173 | for (1..linux.NSIG) |i| { |
| 174 | const sig = std.meta.intToEnum(linux.SIG, i) catch continue; | 174 | const sig = std.enums.fromInt(linux.SIG, i) orelse continue; |
| 175 | try expectEqual(false, linux.sigismember(&sigset, sig)); | 175 | try expectEqual(false, linux.sigismember(&sigset, sig)); |
| 176 | } | 176 | } |
| 177 | } | 177 | } |
lib/std/os/uefi/protocol/ip6_config.zig+3-3| ... | @@ -44,7 +44,7 @@ pub const Ip6Config = extern struct { | ... | @@ -44,7 +44,7 @@ pub const Ip6Config = extern struct { |
| 44 | pub fn setData( | 44 | pub fn setData( |
| 45 | self: *const Ip6Config, | 45 | self: *const Ip6Config, |
| 46 | comptime data_type: std.meta.Tag(DataType), | 46 | comptime data_type: std.meta.Tag(DataType), |
| 47 | payload: *const std.meta.TagPayload(DataType, data_type), | 47 | payload: *const @FieldType(DataType, @tagName(data_type)), |
| 48 | ) SetDataError!void { | 48 | ) SetDataError!void { |
| 49 | const data_size = @sizeOf(@TypeOf(payload)); | 49 | const data_size = @sizeOf(@TypeOf(payload)); |
| 50 | switch (self._set_data(self, data_type, data_size, @ptrCast(payload))) { | 50 | switch (self._set_data(self, data_type, data_size, @ptrCast(payload))) { |
| ... | @@ -64,8 +64,8 @@ pub const Ip6Config = extern struct { | ... | @@ -64,8 +64,8 @@ pub const Ip6Config = extern struct { |
| 64 | pub fn getData( | 64 | pub fn getData( |
| 65 | self: *const Ip6Config, | 65 | self: *const Ip6Config, |
| 66 | comptime data_type: std.meta.Tag(DataType), | 66 | comptime data_type: std.meta.Tag(DataType), |
| 67 | ) GetDataError!std.meta.TagPayload(DataType, data_type) { | 67 | ) GetDataError!@FieldType(DataType, @tagName(data_type)) { |
| 68 | const DataPayload = std.meta.TagPayload(DataType, data_type); | 68 | const DataPayload = @FieldType(DataType, @tagName(data_type)); |
| 69 | 69 | ||
| 70 | var payload: DataPayload = undefined; | 70 | var payload: DataPayload = undefined; |
| 71 | var payload_size: usize = @sizeOf(DataPayload); | 71 | var payload_size: usize = @sizeOf(DataPayload); |
lib/std/posix/test.zig+6-6| ... | @@ -536,7 +536,7 @@ test "sigset empty/full" { | ... | @@ -536,7 +536,7 @@ test "sigset empty/full" { |
| 536 | 536 | ||
| 537 | var set: posix.sigset_t = posix.sigemptyset(); | 537 | var set: posix.sigset_t = posix.sigemptyset(); |
| 538 | for (1..posix.NSIG) |i| { | 538 | for (1..posix.NSIG) |i| { |
| 539 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | 539 | const sig = std.enums.fromInt(posix.SIG, i) orelse continue; |
| 540 | try expectEqual(false, posix.sigismember(&set, sig)); | 540 | try expectEqual(false, posix.sigismember(&set, sig)); |
| 541 | } | 541 | } |
| 542 | 542 | ||
| ... | @@ -565,29 +565,29 @@ test "sigset add/del" { | ... | @@ -565,29 +565,29 @@ test "sigset add/del" { |
| 565 | // See that none are set, then set each one, see that they're all set, then | 565 | // See that none are set, then set each one, see that they're all set, then |
| 566 | // remove them all, and then see that none are set. | 566 | // remove them all, and then see that none are set. |
| 567 | for (1..posix.NSIG) |i| { | 567 | for (1..posix.NSIG) |i| { |
| 568 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | 568 | const sig = std.enums.fromInt(posix.SIG, i) orelse continue; |
| 569 | try expectEqual(false, posix.sigismember(&sigset, sig)); | 569 | try expectEqual(false, posix.sigismember(&sigset, sig)); |
| 570 | } | 570 | } |
| 571 | for (1..posix.NSIG) |i| { | 571 | for (1..posix.NSIG) |i| { |
| 572 | if (!reserved_signo(i)) { | 572 | if (!reserved_signo(i)) { |
| 573 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | 573 | const sig = std.enums.fromInt(posix.SIG, i) orelse continue; |
| 574 | posix.sigaddset(&sigset, sig); | 574 | posix.sigaddset(&sigset, sig); |
| 575 | } | 575 | } |
| 576 | } | 576 | } |
| 577 | for (1..posix.NSIG) |i| { | 577 | for (1..posix.NSIG) |i| { |
| 578 | if (!reserved_signo(i)) { | 578 | if (!reserved_signo(i)) { |
| 579 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | 579 | const sig = std.enums.fromInt(posix.SIG, i) orelse continue; |
| 580 | try expectEqual(true, posix.sigismember(&sigset, sig)); | 580 | try expectEqual(true, posix.sigismember(&sigset, sig)); |
| 581 | } | 581 | } |
| 582 | } | 582 | } |
| 583 | for (1..posix.NSIG) |i| { | 583 | for (1..posix.NSIG) |i| { |
| 584 | if (!reserved_signo(i)) { | 584 | if (!reserved_signo(i)) { |
| 585 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | 585 | const sig = std.enums.fromInt(posix.SIG, i) orelse continue; |
| 586 | posix.sigdelset(&sigset, sig); | 586 | posix.sigdelset(&sigset, sig); |
| 587 | } | 587 | } |
| 588 | } | 588 | } |
| 589 | for (1..posix.NSIG) |i| { | 589 | for (1..posix.NSIG) |i| { |
| 590 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | 590 | const sig = std.enums.fromInt(posix.SIG, i) orelse continue; |
| 591 | try expectEqual(false, posix.sigismember(&sigset, sig)); | 591 | try expectEqual(false, posix.sigismember(&sigset, sig)); |
| 592 | } | 592 | } |
| 593 | } | 593 | } |
lib/std/testing.zig+1-1| ... | @@ -1160,7 +1160,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime | ... | @@ -1160,7 +1160,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime |
| 1160 | } else |err| switch (err) { | 1160 | } else |err| switch (err) { |
| 1161 | error.OutOfMemory => { | 1161 | error.OutOfMemory => { |
| 1162 | if (failing_allocator_inst.allocated_bytes != failing_allocator_inst.freed_bytes) { | 1162 | if (failing_allocator_inst.allocated_bytes != failing_allocator_inst.freed_bytes) { |
| 1163 | const tty_config = std.Io.tty.detectConfig(.stderr()); | 1163 | const tty_config: std.Io.tty.Config = .detect(.stderr()); |
| 1164 | print( | 1164 | print( |
| 1165 | "\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\nallocation that was made to fail: {f}", | 1165 | "\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\nallocation that was made to fail: {f}", |
| 1166 | .{ | 1166 | .{ |
lib/std/zig/Ast.zig-118| ... | @@ -636,7 +636,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex { | ... | @@ -636,7 +636,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex { |
| 636 | .@"nosuspend", | 636 | .@"nosuspend", |
| 637 | .asm_simple, | 637 | .asm_simple, |
| 638 | .@"asm", | 638 | .@"asm", |
| 639 | .asm_legacy, | ||
| 640 | .array_type, | 639 | .array_type, |
| 641 | .array_type_sentinel, | 640 | .array_type_sentinel, |
| 642 | .error_value, | 641 | .error_value, |
| ... | @@ -1050,11 +1049,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex { | ... | @@ -1050,11 +1049,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex { |
| 1050 | n = @enumFromInt(tree.extra_data[@intFromEnum(members.end) - 1]); // last parameter | 1049 | n = @enumFromInt(tree.extra_data[@intFromEnum(members.end) - 1]); // last parameter |
| 1051 | } | 1050 | } |
| 1052 | }, | 1051 | }, |
| 1053 | .asm_legacy => { | ||
| 1054 | _, const extra_index = tree.nodeData(n).node_and_extra; | ||
| 1055 | const extra = tree.extraData(extra_index, Node.AsmLegacy); | ||
| 1056 | return extra.rparen + end_offset; | ||
| 1057 | }, | ||
| 1058 | .@"asm" => { | 1052 | .@"asm" => { |
| 1059 | _, const extra_index = tree.nodeData(n).node_and_extra; | 1053 | _, const extra_index = tree.nodeData(n).node_and_extra; |
| 1060 | const extra = tree.extraData(extra_index, Node.Asm); | 1054 | const extra = tree.extraData(extra_index, Node.Asm); |
| ... | @@ -1900,18 +1894,6 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm { | ... | @@ -1900,18 +1894,6 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm { |
| 1900 | }); | 1894 | }); |
| 1901 | } | 1895 | } |
| 1902 | 1896 | ||
| 1903 | pub fn asmLegacy(tree: Ast, node: Node.Index) full.AsmLegacy { | ||
| 1904 | const template, const extra_index = tree.nodeData(node).node_and_extra; | ||
| 1905 | const extra = tree.extraData(extra_index, Node.AsmLegacy); | ||
| 1906 | const items = tree.extraDataSlice(.{ .start = extra.items_start, .end = extra.items_end }, Node.Index); | ||
| 1907 | return tree.legacyAsmComponents(.{ | ||
| 1908 | .asm_token = tree.nodeMainToken(node), | ||
| 1909 | .template = template, | ||
| 1910 | .items = items, | ||
| 1911 | .rparen = extra.rparen, | ||
| 1912 | }); | ||
| 1913 | } | ||
| 1914 | |||
| 1915 | pub fn asmFull(tree: Ast, node: Node.Index) full.Asm { | 1897 | pub fn asmFull(tree: Ast, node: Node.Index) full.Asm { |
| 1916 | const template, const extra_index = tree.nodeData(node).node_and_extra; | 1898 | const template, const extra_index = tree.nodeData(node).node_and_extra; |
| 1917 | const extra = tree.extraData(extra_index, Node.Asm); | 1899 | const extra = tree.extraData(extra_index, Node.Asm); |
| ... | @@ -2217,67 +2199,6 @@ fn fullSwitchCaseComponents(tree: Ast, info: full.SwitchCase.Components, node: N | ... | @@ -2217,67 +2199,6 @@ fn fullSwitchCaseComponents(tree: Ast, info: full.SwitchCase.Components, node: N |
| 2217 | return result; | 2199 | return result; |
| 2218 | } | 2200 | } |
| 2219 | 2201 | ||
| 2220 | fn legacyAsmComponents(tree: Ast, info: full.AsmLegacy.Components) full.AsmLegacy { | ||
| 2221 | var result: full.AsmLegacy = .{ | ||
| 2222 | .ast = info, | ||
| 2223 | .volatile_token = null, | ||
| 2224 | .inputs = &.{}, | ||
| 2225 | .outputs = &.{}, | ||
| 2226 | .first_clobber = null, | ||
| 2227 | }; | ||
| 2228 | if (tree.tokenTag(info.asm_token + 1) == .keyword_volatile) { | ||
| 2229 | result.volatile_token = info.asm_token + 1; | ||
| 2230 | } | ||
| 2231 | const outputs_end: usize = for (info.items, 0..) |item, i| { | ||
| 2232 | switch (tree.nodeTag(item)) { | ||
| 2233 | .asm_output => continue, | ||
| 2234 | else => break i, | ||
| 2235 | } | ||
| 2236 | } else info.items.len; | ||
| 2237 | |||
| 2238 | result.outputs = info.items[0..outputs_end]; | ||
| 2239 | result.inputs = info.items[outputs_end..]; | ||
| 2240 | |||
| 2241 | if (info.items.len == 0) { | ||
| 2242 | // asm ("foo" ::: "a", "b"); | ||
| 2243 | const template_token = tree.lastToken(info.template); | ||
| 2244 | if (tree.tokenTag(template_token + 1) == .colon and | ||
| 2245 | tree.tokenTag(template_token + 2) == .colon and | ||
| 2246 | tree.tokenTag(template_token + 3) == .colon and | ||
| 2247 | tree.tokenTag(template_token + 4) == .string_literal) | ||
| 2248 | { | ||
| 2249 | result.first_clobber = template_token + 4; | ||
| 2250 | } | ||
| 2251 | } else if (result.inputs.len != 0) { | ||
| 2252 | // asm ("foo" :: [_] "" (y) : "a", "b"); | ||
| 2253 | const last_input = result.inputs[result.inputs.len - 1]; | ||
| 2254 | const rparen = tree.lastToken(last_input); | ||
| 2255 | var i = rparen + 1; | ||
| 2256 | // Allow a (useless) comma right after the closing parenthesis. | ||
| 2257 | if (tree.tokenTag(i) == .comma) i = i + 1; | ||
| 2258 | if (tree.tokenTag(i) == .colon and | ||
| 2259 | tree.tokenTag(i + 1) == .string_literal) | ||
| 2260 | { | ||
| 2261 | result.first_clobber = i + 1; | ||
| 2262 | } | ||
| 2263 | } else { | ||
| 2264 | // asm ("foo" : [_] "" (x) :: "a", "b"); | ||
| 2265 | const last_output = result.outputs[result.outputs.len - 1]; | ||
| 2266 | const rparen = tree.lastToken(last_output); | ||
| 2267 | var i = rparen + 1; | ||
| 2268 | // Allow a (useless) comma right after the closing parenthesis. | ||
| 2269 | if (tree.tokenTag(i) == .comma) i = i + 1; | ||
| 2270 | if (tree.tokenTag(i) == .colon and | ||
| 2271 | tree.tokenTag(i + 1) == .colon and | ||
| 2272 | tree.tokenTag(i + 2) == .string_literal) | ||
| 2273 | { | ||
| 2274 | result.first_clobber = i + 2; | ||
| 2275 | } | ||
| 2276 | } | ||
| 2277 | |||
| 2278 | return result; | ||
| 2279 | } | ||
| 2280 | |||
| 2281 | fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm { | 2202 | fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm { |
| 2282 | var result: full.Asm = .{ | 2203 | var result: full.Asm = .{ |
| 2283 | .ast = info, | 2204 | .ast = info, |
| ... | @@ -2495,14 +2416,6 @@ pub fn fullAsm(tree: Ast, node: Node.Index) ?full.Asm { | ... | @@ -2495,14 +2416,6 @@ pub fn fullAsm(tree: Ast, node: Node.Index) ?full.Asm { |
| 2495 | }; | 2416 | }; |
| 2496 | } | 2417 | } |
| 2497 | 2418 | ||
| 2498 | /// To be deleted after 0.15.0 is tagged | ||
| 2499 | pub fn legacyAsm(tree: Ast, node: Node.Index) ?full.AsmLegacy { | ||
| 2500 | return switch (tree.nodeTag(node)) { | ||
| 2501 | .asm_legacy => tree.asmLegacy(node), | ||
| 2502 | else => null, | ||
| 2503 | }; | ||
| 2504 | } | ||
| 2505 | |||
| 2506 | pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call { | 2419 | pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call { |
| 2507 | return switch (tree.nodeTag(node)) { | 2420 | return switch (tree.nodeTag(node)) { |
| 2508 | .call, .call_comma => tree.callFull(node), | 2421 | .call, .call_comma => tree.callFull(node), |
| ... | @@ -2897,21 +2810,6 @@ pub const full = struct { | ... | @@ -2897,21 +2810,6 @@ pub const full = struct { |
| 2897 | }; | 2810 | }; |
| 2898 | }; | 2811 | }; |
| 2899 | 2812 | ||
| 2900 | pub const AsmLegacy = struct { | ||
| 2901 | ast: Components, | ||
| 2902 | volatile_token: ?TokenIndex, | ||
| 2903 | first_clobber: ?TokenIndex, | ||
| 2904 | outputs: []const Node.Index, | ||
| 2905 | inputs: []const Node.Index, | ||
| 2906 | |||
| 2907 | pub const Components = struct { | ||
| 2908 | asm_token: TokenIndex, | ||
| 2909 | template: Node.Index, | ||
| 2910 | items: []const Node.Index, | ||
| 2911 | rparen: TokenIndex, | ||
| 2912 | }; | ||
| 2913 | }; | ||
| 2914 | |||
| 2915 | pub const Call = struct { | 2813 | pub const Call = struct { |
| 2916 | ast: Components, | 2814 | ast: Components, |
| 2917 | 2815 | ||
| ... | @@ -3908,14 +3806,6 @@ pub const Node = struct { | ... | @@ -3908,14 +3806,6 @@ pub const Node = struct { |
| 3908 | /// | 3806 | /// |
| 3909 | /// The `main_token` field is the `asm` token. | 3807 | /// The `main_token` field is the `asm` token. |
| 3910 | asm_simple, | 3808 | asm_simple, |
| 3911 | /// `asm(lhs, a)`. | ||
| 3912 | /// | ||
| 3913 | /// The `data` field is a `.node_and_extra`: | ||
| 3914 | /// 1. a `Node.Index` to lhs. | ||
| 3915 | /// 2. a `ExtraIndex` to `AsmLegacy`. | ||
| 3916 | /// | ||
| 3917 | /// The `main_token` field is the `asm` token. | ||
| 3918 | asm_legacy, | ||
| 3919 | /// `asm(a, b)`. | 3809 | /// `asm(a, b)`. |
| 3920 | /// | 3810 | /// |
| 3921 | /// The `data` field is a `.node_and_extra`: | 3811 | /// The `data` field is a `.node_and_extra`: |
| ... | @@ -4092,14 +3982,6 @@ pub const Node = struct { | ... | @@ -4092,14 +3982,6 @@ pub const Node = struct { |
| 4092 | callconv_expr: OptionalIndex, | 3982 | callconv_expr: OptionalIndex, |
| 4093 | }; | 3983 | }; |
| 4094 | 3984 | ||
| 4095 | /// To be removed after 0.15.0 is tagged | ||
| 4096 | pub const AsmLegacy = struct { | ||
| 4097 | items_start: ExtraIndex, | ||
| 4098 | items_end: ExtraIndex, | ||
| 4099 | /// Needed to make lastToken() work. | ||
| 4100 | rparen: TokenIndex, | ||
| 4101 | }; | ||
| 4102 | |||
| 4103 | pub const Asm = struct { | 3985 | pub const Asm = struct { |
| 4104 | items_start: ExtraIndex, | 3986 | items_start: ExtraIndex, |
| 4105 | items_end: ExtraIndex, | 3987 | items_end: ExtraIndex, |
lib/std/zig/Ast/Render.zig-182| ... | @@ -896,9 +896,6 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void { | ... | @@ -896,9 +896,6 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void { |
| 896 | .@"asm", | 896 | .@"asm", |
| 897 | => return renderAsm(r, tree.fullAsm(node).?, space), | 897 | => return renderAsm(r, tree.fullAsm(node).?, space), |
| 898 | 898 | ||
| 899 | // To be removed after 0.15.0 is tagged | ||
| 900 | .asm_legacy => return renderAsmLegacy(r, tree.legacyAsm(node).?, space), | ||
| 901 | |||
| 902 | .enum_literal => { | 899 | .enum_literal => { |
| 903 | try renderToken(r, tree.nodeMainToken(node) - 1, .none); // . | 900 | try renderToken(r, tree.nodeMainToken(node) - 1, .none); // . |
| 904 | return renderIdentifier(r, tree.nodeMainToken(node), space, .eagerly_unquote); // name | 901 | return renderIdentifier(r, tree.nodeMainToken(node), space, .eagerly_unquote); // name |
| ... | @@ -2413,185 +2410,6 @@ fn renderContainerDecl( | ... | @@ -2413,185 +2410,6 @@ fn renderContainerDecl( |
| 2413 | return renderToken(r, rbrace, space); // rbrace | 2410 | return renderToken(r, rbrace, space); // rbrace |
| 2414 | } | 2411 | } |
| 2415 | 2412 | ||
| 2416 | fn renderAsmLegacy( | ||
| 2417 | r: *Render, | ||
| 2418 | asm_node: Ast.full.AsmLegacy, | ||
| 2419 | space: Space, | ||
| 2420 | ) Error!void { | ||
| 2421 | const tree = r.tree; | ||
| 2422 | const ais = r.ais; | ||
| 2423 | |||
| 2424 | try renderToken(r, asm_node.ast.asm_token, .space); // asm | ||
| 2425 | |||
| 2426 | if (asm_node.volatile_token) |volatile_token| { | ||
| 2427 | try renderToken(r, volatile_token, .space); // volatile | ||
| 2428 | try renderToken(r, volatile_token + 1, .none); // lparen | ||
| 2429 | } else { | ||
| 2430 | try renderToken(r, asm_node.ast.asm_token + 1, .none); // lparen | ||
| 2431 | } | ||
| 2432 | |||
| 2433 | if (asm_node.ast.items.len == 0) { | ||
| 2434 | try ais.forcePushIndent(.normal); | ||
| 2435 | if (asm_node.first_clobber) |first_clobber| { | ||
| 2436 | // asm ("foo" ::: "a", "b") | ||
| 2437 | // asm ("foo" ::: "a", "b",) | ||
| 2438 | try renderExpression(r, asm_node.ast.template, .space); | ||
| 2439 | // Render the three colons. | ||
| 2440 | try renderToken(r, first_clobber - 3, .none); | ||
| 2441 | try renderToken(r, first_clobber - 2, .none); | ||
| 2442 | try renderToken(r, first_clobber - 1, .space); | ||
| 2443 | |||
| 2444 | try ais.writeAll(".{ "); | ||
| 2445 | |||
| 2446 | var tok_i = first_clobber; | ||
| 2447 | while (true) : (tok_i += 1) { | ||
| 2448 | try ais.writeByte('.'); | ||
| 2449 | _ = try writeStringLiteralAsIdentifier(r, tok_i); | ||
| 2450 | try ais.writeAll(" = true"); | ||
| 2451 | |||
| 2452 | tok_i += 1; | ||
| 2453 | switch (tree.tokenTag(tok_i)) { | ||
| 2454 | .r_paren => { | ||
| 2455 | try ais.writeAll(" }"); | ||
| 2456 | ais.popIndent(); | ||
| 2457 | return renderToken(r, tok_i, space); | ||
| 2458 | }, | ||
| 2459 | .comma => { | ||
| 2460 | if (tree.tokenTag(tok_i + 1) == .r_paren) { | ||
| 2461 | try ais.writeAll(" }"); | ||
| 2462 | ais.popIndent(); | ||
| 2463 | return renderToken(r, tok_i + 1, space); | ||
| 2464 | } else { | ||
| 2465 | try renderToken(r, tok_i, .space); | ||
| 2466 | } | ||
| 2467 | }, | ||
| 2468 | else => unreachable, | ||
| 2469 | } | ||
| 2470 | } | ||
| 2471 | } else { | ||
| 2472 | unreachable; | ||
| 2473 | } | ||
| 2474 | } | ||
| 2475 | |||
| 2476 | try ais.forcePushIndent(.normal); | ||
| 2477 | try renderExpression(r, asm_node.ast.template, .newline); | ||
| 2478 | ais.setIndentDelta(asm_indent_delta); | ||
| 2479 | const colon1 = tree.lastToken(asm_node.ast.template) + 1; | ||
| 2480 | |||
| 2481 | const colon2 = if (asm_node.outputs.len == 0) colon2: { | ||
| 2482 | try renderToken(r, colon1, .newline); // : | ||
| 2483 | break :colon2 colon1 + 1; | ||
| 2484 | } else colon2: { | ||
| 2485 | try renderToken(r, colon1, .space); // : | ||
| 2486 | |||
| 2487 | try ais.forcePushIndent(.normal); | ||
| 2488 | for (asm_node.outputs, 0..) |asm_output, i| { | ||
| 2489 | if (i + 1 < asm_node.outputs.len) { | ||
| 2490 | const next_asm_output = asm_node.outputs[i + 1]; | ||
| 2491 | try renderAsmOutput(r, asm_output, .none); | ||
| 2492 | |||
| 2493 | const comma = tree.firstToken(next_asm_output) - 1; | ||
| 2494 | try renderToken(r, comma, .newline); // , | ||
| 2495 | try renderExtraNewlineToken(r, tree.firstToken(next_asm_output)); | ||
| 2496 | } else if (asm_node.inputs.len == 0 and asm_node.first_clobber == null) { | ||
| 2497 | try ais.pushSpace(.comma); | ||
| 2498 | try renderAsmOutput(r, asm_output, .comma); | ||
| 2499 | ais.popSpace(); | ||
| 2500 | ais.popIndent(); | ||
| 2501 | ais.setIndentDelta(indent_delta); | ||
| 2502 | ais.popIndent(); | ||
| 2503 | return renderToken(r, asm_node.ast.rparen, space); // rparen | ||
| 2504 | } else { | ||
| 2505 | try ais.pushSpace(.comma); | ||
| 2506 | try renderAsmOutput(r, asm_output, .comma); | ||
| 2507 | ais.popSpace(); | ||
| 2508 | const comma_or_colon = tree.lastToken(asm_output) + 1; | ||
| 2509 | ais.popIndent(); | ||
| 2510 | break :colon2 switch (tree.tokenTag(comma_or_colon)) { | ||
| 2511 | .comma => comma_or_colon + 1, | ||
| 2512 | else => comma_or_colon, | ||
| 2513 | }; | ||
| 2514 | } | ||
| 2515 | } else unreachable; | ||
| 2516 | }; | ||
| 2517 | |||
| 2518 | const colon3 = if (asm_node.inputs.len == 0) colon3: { | ||
| 2519 | try renderToken(r, colon2, .newline); // : | ||
| 2520 | break :colon3 colon2 + 1; | ||
| 2521 | } else colon3: { | ||
| 2522 | try renderToken(r, colon2, .space); // : | ||
| 2523 | try ais.forcePushIndent(.normal); | ||
| 2524 | for (asm_node.inputs, 0..) |asm_input, i| { | ||
| 2525 | if (i + 1 < asm_node.inputs.len) { | ||
| 2526 | const next_asm_input = asm_node.inputs[i + 1]; | ||
| 2527 | try renderAsmInput(r, asm_input, .none); | ||
| 2528 | |||
| 2529 | const first_token = tree.firstToken(next_asm_input); | ||
| 2530 | try renderToken(r, first_token - 1, .newline); // , | ||
| 2531 | try renderExtraNewlineToken(r, first_token); | ||
| 2532 | } else if (asm_node.first_clobber == null) { | ||
| 2533 | try ais.pushSpace(.comma); | ||
| 2534 | try renderAsmInput(r, asm_input, .comma); | ||
| 2535 | ais.popSpace(); | ||
| 2536 | ais.popIndent(); | ||
| 2537 | ais.setIndentDelta(indent_delta); | ||
| 2538 | ais.popIndent(); | ||
| 2539 | return renderToken(r, asm_node.ast.rparen, space); // rparen | ||
| 2540 | } else { | ||
| 2541 | try ais.pushSpace(.comma); | ||
| 2542 | try renderAsmInput(r, asm_input, .comma); | ||
| 2543 | ais.popSpace(); | ||
| 2544 | const comma_or_colon = tree.lastToken(asm_input) + 1; | ||
| 2545 | ais.popIndent(); | ||
| 2546 | break :colon3 switch (tree.tokenTag(comma_or_colon)) { | ||
| 2547 | .comma => comma_or_colon + 1, | ||
| 2548 | else => comma_or_colon, | ||
| 2549 | }; | ||
| 2550 | } | ||
| 2551 | } | ||
| 2552 | unreachable; | ||
| 2553 | }; | ||
| 2554 | |||
| 2555 | try renderToken(r, colon3, .space); // : | ||
| 2556 | try ais.writeAll(".{ "); | ||
| 2557 | const first_clobber = asm_node.first_clobber.?; | ||
| 2558 | var tok_i = first_clobber; | ||
| 2559 | while (true) { | ||
| 2560 | switch (tree.tokenTag(tok_i + 1)) { | ||
| 2561 | .r_paren => { | ||
| 2562 | ais.setIndentDelta(indent_delta); | ||
| 2563 | try ais.writeByte('.'); | ||
| 2564 | const lexeme_len = try writeStringLiteralAsIdentifier(r, tok_i); | ||
| 2565 | try ais.writeAll(" = true }"); | ||
| 2566 | try renderSpace(r, tok_i, lexeme_len, .newline); | ||
| 2567 | ais.popIndent(); | ||
| 2568 | return renderToken(r, tok_i + 1, space); | ||
| 2569 | }, | ||
| 2570 | .comma => { | ||
| 2571 | switch (tree.tokenTag(tok_i + 2)) { | ||
| 2572 | .r_paren => { | ||
| 2573 | ais.setIndentDelta(indent_delta); | ||
| 2574 | try ais.writeByte('.'); | ||
| 2575 | const lexeme_len = try writeStringLiteralAsIdentifier(r, tok_i); | ||
| 2576 | try ais.writeAll(" = true }"); | ||
| 2577 | try renderSpace(r, tok_i, lexeme_len, .newline); | ||
| 2578 | ais.popIndent(); | ||
| 2579 | return renderToken(r, tok_i + 2, space); | ||
| 2580 | }, | ||
| 2581 | else => { | ||
| 2582 | try ais.writeByte('.'); | ||
| 2583 | _ = try writeStringLiteralAsIdentifier(r, tok_i); | ||
| 2584 | try ais.writeAll(" = true"); | ||
| 2585 | try renderToken(r, tok_i + 1, .space); | ||
| 2586 | tok_i += 2; | ||
| 2587 | }, | ||
| 2588 | } | ||
| 2589 | }, | ||
| 2590 | else => unreachable, | ||
| 2591 | } | ||
| 2592 | } | ||
| 2593 | } | ||
| 2594 | |||
| 2595 | fn renderAsm( | 2413 | fn renderAsm( |
| 2596 | r: *Render, | 2414 | r: *Render, |
| 2597 | asm_node: Ast.full.Asm, | 2415 | asm_node: Ast.full.Asm, |
lib/std/zig/AstGen.zig-10| ... | @@ -507,7 +507,6 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Ins | ... | @@ -507,7 +507,6 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Ins |
| 507 | .bool_or, | 507 | .bool_or, |
| 508 | .@"asm", | 508 | .@"asm", |
| 509 | .asm_simple, | 509 | .asm_simple, |
| 510 | .asm_legacy, | ||
| 511 | .string_literal, | 510 | .string_literal, |
| 512 | .number_literal, | 511 | .number_literal, |
| 513 | .call, | 512 | .call, |
| ... | @@ -814,12 +813,6 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE | ... | @@ -814,12 +813,6 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 814 | .@"asm", | 813 | .@"asm", |
| 815 | => return asmExpr(gz, scope, ri, node, tree.fullAsm(node).?), | 814 | => return asmExpr(gz, scope, ri, node, tree.fullAsm(node).?), |
| 816 | 815 | ||
| 817 | .asm_legacy => { | ||
| 818 | return astgen.failNodeNotes(node, "legacy asm clobbers syntax", .{}, &[_]u32{ | ||
| 819 | try astgen.errNoteNode(node, "use 'zig fmt' to auto-upgrade", .{}), | ||
| 820 | }); | ||
| 821 | }, | ||
| 822 | |||
| 823 | .string_literal => return stringLiteral(gz, ri, node), | 816 | .string_literal => return stringLiteral(gz, ri, node), |
| 824 | .multiline_string_literal => return multilineStringLiteral(gz, ri, node), | 817 | .multiline_string_literal => return multilineStringLiteral(gz, ri, node), |
| 825 | 818 | ||
| ... | @@ -10502,7 +10495,6 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) BuiltinFn.Ev | ... | @@ -10502,7 +10495,6 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) BuiltinFn.Ev |
| 10502 | 10495 | ||
| 10503 | .@"asm", | 10496 | .@"asm", |
| 10504 | .asm_simple, | 10497 | .asm_simple, |
| 10505 | .asm_legacy, | ||
| 10506 | .identifier, | 10498 | .identifier, |
| 10507 | .field_access, | 10499 | .field_access, |
| 10508 | .deref, | 10500 | .deref, |
| ... | @@ -10746,7 +10738,6 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In | ... | @@ -10746,7 +10738,6 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In |
| 10746 | .tagged_union_enum_tag_trailing, | 10738 | .tagged_union_enum_tag_trailing, |
| 10747 | .@"asm", | 10739 | .@"asm", |
| 10748 | .asm_simple, | 10740 | .asm_simple, |
| 10749 | .asm_legacy, | ||
| 10750 | .add, | 10741 | .add, |
| 10751 | .add_wrap, | 10742 | .add_wrap, |
| 10752 | .add_sat, | 10743 | .add_sat, |
| ... | @@ -10985,7 +10976,6 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool { | ... | @@ -10985,7 +10976,6 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool { |
| 10985 | .tagged_union_enum_tag_trailing, | 10976 | .tagged_union_enum_tag_trailing, |
| 10986 | .@"asm", | 10977 | .@"asm", |
| 10987 | .asm_simple, | 10978 | .asm_simple, |
| 10988 | .asm_legacy, | ||
| 10989 | .add, | 10979 | .add, |
| 10990 | .add_wrap, | 10980 | .add_wrap, |
| 10991 | .add_sat, | 10981 | .add_sat, |
lib/std/zig/AstRlAnnotate.zig-1| ... | @@ -310,7 +310,6 @@ fn expr(astrl: *AstRlAnnotate, node: Ast.Node.Index, block: ?*Block, ri: ResultI | ... | @@ -310,7 +310,6 @@ fn expr(astrl: *AstRlAnnotate, node: Ast.Node.Index, block: ?*Block, ri: ResultI |
| 310 | .unreachable_literal, | 310 | .unreachable_literal, |
| 311 | .asm_simple, | 311 | .asm_simple, |
| 312 | .@"asm", | 312 | .@"asm", |
| 313 | .asm_legacy, | ||
| 314 | .enum_literal, | 313 | .enum_literal, |
| 315 | .error_value, | 314 | .error_value, |
| 316 | .anyframe_literal, | 315 | .anyframe_literal, |
lib/std/zig/Parse.zig-26| ... | @@ -2857,32 +2857,6 @@ fn expectAsmExpr(p: *Parse) !Node.Index { | ... | @@ -2857,32 +2857,6 @@ fn expectAsmExpr(p: *Parse) !Node.Index { |
| 2857 | 2857 | ||
| 2858 | _ = p.eatToken(.colon) orelse break :clobbers .none; | 2858 | _ = p.eatToken(.colon) orelse break :clobbers .none; |
| 2859 | 2859 | ||
| 2860 | // For automatic upgrades; delete after 0.15.0 released. | ||
| 2861 | if (p.tokenTag(p.tok_i) == .string_literal) { | ||
| 2862 | while (p.eatToken(.string_literal)) |_| { | ||
| 2863 | switch (p.tokenTag(p.tok_i)) { | ||
| 2864 | .comma => p.tok_i += 1, | ||
| 2865 | .colon, .r_paren, .r_brace, .r_bracket => break, | ||
| 2866 | // Likely just a missing comma; give error but continue parsing. | ||
| 2867 | else => try p.warnExpected(.comma), | ||
| 2868 | } | ||
| 2869 | } | ||
| 2870 | const rparen = try p.expectToken(.r_paren); | ||
| 2871 | const span = try p.listToSpan(p.scratch.items[scratch_top..]); | ||
| 2872 | return p.addNode(.{ | ||
| 2873 | .tag = .asm_legacy, | ||
| 2874 | .main_token = asm_token, | ||
| 2875 | .data = .{ .node_and_extra = .{ | ||
| 2876 | template, | ||
| 2877 | try p.addExtra(Node.AsmLegacy{ | ||
| 2878 | .items_start = span.start, | ||
| 2879 | .items_end = span.end, | ||
| 2880 | .rparen = rparen, | ||
| 2881 | }), | ||
| 2882 | } }, | ||
| 2883 | }); | ||
| 2884 | } | ||
| 2885 | |||
| 2886 | break :clobbers (try p.expectExpr()).toOptional(); | 2860 | break :clobbers (try p.expectExpr()).toOptional(); |
| 2887 | } else .none; | 2861 | } else .none; |
| 2888 | 2862 |
lib/std/zig/ZonGen.zig+1-1| ... | @@ -238,7 +238,7 @@ fn expr(zg: *ZonGen, node: Ast.Node.Index, dest_node: Zoir.Node.Index) Allocator | ... | @@ -238,7 +238,7 @@ fn expr(zg: *ZonGen, node: Ast.Node.Index, dest_node: Zoir.Node.Index) Allocator |
| 238 | => try zg.addErrorNode(node, "control flow is not allowed in ZON", .{}), | 238 | => try zg.addErrorNode(node, "control flow is not allowed in ZON", .{}), |
| 239 | 239 | ||
| 240 | .@"comptime" => try zg.addErrorNode(node, "keyword 'comptime' is not allowed in ZON", .{}), | 240 | .@"comptime" => try zg.addErrorNode(node, "keyword 'comptime' is not allowed in ZON", .{}), |
| 241 | .asm_simple, .@"asm", .asm_legacy => try zg.addErrorNode(node, "inline asm is not allowed in ZON", .{}), | 241 | .asm_simple, .@"asm" => try zg.addErrorNode(node, "inline asm is not allowed in ZON", .{}), |
| 242 | 242 | ||
| 243 | .builtin_call_two, | 243 | .builtin_call_two, |
| 244 | .builtin_call_two_comma, | 244 | .builtin_call_two_comma, |
lib/std/zig/parser_test.zig+10-82| ... | @@ -31,54 +31,16 @@ test "zig fmt: tuple struct" { | ... | @@ -31,54 +31,16 @@ test "zig fmt: tuple struct" { |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | test "zig fmt: preserves clobbers in inline asm with stray comma" { | 33 | test "zig fmt: preserves clobbers in inline asm with stray comma" { |
| 34 | try testTransform( | 34 | try testCanonical( |
| 35 | \\fn foo() void { | ||
| 36 | \\ asm volatile ("" | ||
| 37 | \\ : [_] "" (-> type), | ||
| 38 | \\ : | ||
| 39 | \\ : "clobber" | ||
| 40 | \\ ); | ||
| 41 | \\ asm volatile ("" | ||
| 42 | \\ : | ||
| 43 | \\ : [_] "" (type), | ||
| 44 | \\ : "clobber" | ||
| 45 | \\ ); | ||
| 46 | \\} | ||
| 47 | \\ | ||
| 48 | , | ||
| 49 | \\fn foo() void { | 35 | \\fn foo() void { |
| 50 | \\ asm volatile ("" | 36 | \\ asm volatile ("" |
| 51 | \\ : [_] "" (-> type), | 37 | \\ : [_] "" (-> type), |
| 52 | \\ : | 38 | \\ : |
| 53 | \\ : .{ .clobber = true } | 39 | \\ : .{ .clobber = true }); |
| 54 | \\ ); | ||
| 55 | \\ asm volatile ("" | 40 | \\ asm volatile ("" |
| 56 | \\ : | 41 | \\ : |
| 57 | \\ : [_] "" (type), | 42 | \\ : [_] "" (type), |
| 58 | \\ : .{ .clobber = true } | 43 | \\ : .{ .clobber = true }); |
| 59 | \\ ); | ||
| 60 | \\} | ||
| 61 | \\ | ||
| 62 | ); | ||
| 63 | } | ||
| 64 | |||
| 65 | test "zig fmt: remove trailing comma at the end of assembly clobber" { | ||
| 66 | try testTransform( | ||
| 67 | \\fn foo() void { | ||
| 68 | \\ asm volatile ("" | ||
| 69 | \\ : [_] "" (-> type), | ||
| 70 | \\ : | ||
| 71 | \\ : "clobber1", "clobber2", | ||
| 72 | \\ ); | ||
| 73 | \\} | ||
| 74 | \\ | ||
| 75 | , | ||
| 76 | \\fn foo() void { | ||
| 77 | \\ asm volatile ("" | ||
| 78 | \\ : [_] "" (-> type), | ||
| 79 | \\ : | ||
| 80 | \\ : .{ .clobber1 = true, .clobber2 = true } | ||
| 81 | \\ ); | ||
| 82 | \\} | 44 | \\} |
| 83 | \\ | 45 | \\ |
| 84 | ); | 46 | ); |
| ... | @@ -641,27 +603,7 @@ test "zig fmt: builtin call with trailing comma" { | ... | @@ -641,27 +603,7 @@ test "zig fmt: builtin call with trailing comma" { |
| 641 | } | 603 | } |
| 642 | 604 | ||
| 643 | test "zig fmt: asm expression with comptime content" { | 605 | test "zig fmt: asm expression with comptime content" { |
| 644 | try testTransform( | 606 | try testCanonical( |
| 645 | \\comptime { | ||
| 646 | \\ asm ("foo" ++ "bar"); | ||
| 647 | \\} | ||
| 648 | \\pub fn main() void { | ||
| 649 | \\ asm volatile ("foo" ++ "bar"); | ||
| 650 | \\ asm volatile ("foo" ++ "bar" | ||
| 651 | \\ : [_] "" (x), | ||
| 652 | \\ ); | ||
| 653 | \\ asm volatile ("foo" ++ "bar" | ||
| 654 | \\ : [_] "" (x), | ||
| 655 | \\ : [_] "" (y), | ||
| 656 | \\ ); | ||
| 657 | \\ asm volatile ("foo" ++ "bar" | ||
| 658 | \\ : [_] "" (x), | ||
| 659 | \\ : [_] "" (y), | ||
| 660 | \\ : "h", "e", "l", "l", "o" | ||
| 661 | \\ ); | ||
| 662 | \\} | ||
| 663 | \\ | ||
| 664 | , | ||
| 665 | \\comptime { | 607 | \\comptime { |
| 666 | \\ asm ("foo" ++ "bar"); | 608 | \\ asm ("foo" ++ "bar"); |
| 667 | \\} | 609 | \\} |
| ... | @@ -677,8 +619,7 @@ test "zig fmt: asm expression with comptime content" { | ... | @@ -677,8 +619,7 @@ test "zig fmt: asm expression with comptime content" { |
| 677 | \\ asm volatile ("foo" ++ "bar" | 619 | \\ asm volatile ("foo" ++ "bar" |
| 678 | \\ : [_] "" (x), | 620 | \\ : [_] "" (x), |
| 679 | \\ : [_] "" (y), | 621 | \\ : [_] "" (y), |
| 680 | \\ : .{ .h = true, .e = true, .l = true, .l = true, .o = true } | 622 | \\ : .{ .h = true, .e = true, .l = true, .l = true, .o = true }); |
| 681 | \\ ); | ||
| 682 | \\} | 623 | \\} |
| 683 | \\ | 624 | \\ |
| 684 | ); | 625 | ); |
| ... | @@ -2198,7 +2139,7 @@ test "zig fmt: simple asm" { | ... | @@ -2198,7 +2139,7 @@ test "zig fmt: simple asm" { |
| 2198 | \\ asm ("not real assembly" | 2139 | \\ asm ("not real assembly" |
| 2199 | \\ :[a] "x" (->i32),:[a] "x" (1),); | 2140 | \\ :[a] "x" (->i32),:[a] "x" (1),); |
| 2200 | \\ asm ("still not real assembly" | 2141 | \\ asm ("still not real assembly" |
| 2201 | \\ :::"a","b",); | 2142 | \\ :::.{.a=true,.b=true}); |
| 2202 | \\} | 2143 | \\} |
| 2203 | , | 2144 | , |
| 2204 | \\comptime { | 2145 | \\comptime { |
| ... | @@ -3940,24 +3881,13 @@ test "zig fmt: fn type" { | ... | @@ -3940,24 +3881,13 @@ test "zig fmt: fn type" { |
| 3940 | } | 3881 | } |
| 3941 | 3882 | ||
| 3942 | test "zig fmt: inline asm" { | 3883 | test "zig fmt: inline asm" { |
| 3943 | try testTransform( | 3884 | try testCanonical( |
| 3944 | \\pub fn syscall1(number: usize, arg1: usize) usize { | ||
| 3945 | \\ return asm volatile ("syscall" | ||
| 3946 | \\ : [ret] "={rax}" (-> usize), | ||
| 3947 | \\ : [number] "{rax}" (number), | ||
| 3948 | \\ [arg1] "{rdi}" (arg1), | ||
| 3949 | \\ : "rcx", "r11" | ||
| 3950 | \\ ); | ||
| 3951 | \\} | ||
| 3952 | \\ | ||
| 3953 | , | ||
| 3954 | \\pub fn syscall1(number: usize, arg1: usize) usize { | 3885 | \\pub fn syscall1(number: usize, arg1: usize) usize { |
| 3955 | \\ return asm volatile ("syscall" | 3886 | \\ return asm volatile ("syscall" |
| 3956 | \\ : [ret] "={rax}" (-> usize), | 3887 | \\ : [ret] "={rax}" (-> usize), |
| 3957 | \\ : [number] "{rax}" (number), | 3888 | \\ : [number] "{rax}" (number), |
| 3958 | \\ [arg1] "{rdi}" (arg1), | 3889 | \\ [arg1] "{rdi}" (arg1), |
| 3959 | \\ : .{ .rcx = true, .r11 = true } | 3890 | \\ : .{ .rcx = true, .r11 = true }); |
| 3960 | \\ ); | ||
| 3961 | \\} | 3891 | \\} |
| 3962 | \\ | 3892 | \\ |
| 3963 | ); | 3893 | ); |
| ... | @@ -5789,8 +5719,7 @@ test "zig fmt: canonicalize symbols (asm)" { | ... | @@ -5789,8 +5719,7 @@ test "zig fmt: canonicalize symbols (asm)" { |
| 5789 | \\ [@"arg1"] "{rdi}" (arg), | 5719 | \\ [@"arg1"] "{rdi}" (arg), |
| 5790 | \\ [arg2] "{rsi}" (arg), | 5720 | \\ [arg2] "{rsi}" (arg), |
| 5791 | \\ [arg3] "{rdx}" (arg), | 5721 | \\ [arg3] "{rdx}" (arg), |
| 5792 | \\ : "rcx", "fn" | 5722 | \\ : .{ .rcx = true, .@"fn" = true }); |
| 5793 | \\ ); | ||
| 5794 | \\ | 5723 | \\ |
| 5795 | \\ const @"false": usize = 10; | 5724 | \\ const @"false": usize = 10; |
| 5796 | \\ const @"true" = "explode"; | 5725 | \\ const @"true" = "explode"; |
| ... | @@ -5811,8 +5740,7 @@ test "zig fmt: canonicalize symbols (asm)" { | ... | @@ -5811,8 +5740,7 @@ test "zig fmt: canonicalize symbols (asm)" { |
| 5811 | \\ [arg1] "{rdi}" (arg), | 5740 | \\ [arg1] "{rdi}" (arg), |
| 5812 | \\ [arg2] "{rsi}" (arg), | 5741 | \\ [arg2] "{rsi}" (arg), |
| 5813 | \\ [arg3] "{rdx}" (arg), | 5742 | \\ [arg3] "{rdx}" (arg), |
| 5814 | \\ : .{ .rcx = true, .@"fn" = true } | 5743 | \\ : .{ .rcx = true, .@"fn" = true }); |
| 5815 | \\ ); | ||
| 5816 | \\ | 5744 | \\ |
| 5817 | \\ const @"false": usize = 10; | 5745 | \\ const @"false": usize = 10; |
| 5818 | \\ const @"true" = "explode"; | 5746 | \\ const @"true" = "explode"; |
test/standalone/config_header/build.zig+1-1| ... | @@ -21,7 +21,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -21,7 +21,7 @@ pub fn build(b: *std.Build) void { |
| 21 | }, | 21 | }, |
| 22 | ); | 22 | ); |
| 23 | 23 | ||
| 24 | const check_config_header = b.addCheckFile(config_header.getOutput(), .{ .expected_exact = @embedFile("config.h") }); | 24 | const check_config_header = b.addCheckFile(config_header.getOutputFile(), .{ .expected_exact = @embedFile("config.h") }); |
| 25 | 25 | ||
| 26 | const test_step = b.step("test", "Test it"); | 26 | const test_step = b.step("test", "Test it"); |
| 27 | test_step.dependOn(&check_config_header.step); | 27 | test_step.dependOn(&check_config_header.step); |
test/standalone/test_obj_link_run/build.zig+3-3| ... | @@ -9,9 +9,9 @@ pub fn build(b: *std.Build) void { | ... | @@ -9,9 +9,9 @@ pub fn build(b: *std.Build) void { |
| 9 | }), | 9 | }), |
| 10 | }); | 10 | }); |
| 11 | if (is_windows) { | 11 | if (is_windows) { |
| 12 | test_obj.linkSystemLibrary("ntdll"); | 12 | test_obj.root_module.linkSystemLibrary("ntdll", .{}); |
| 13 | test_obj.linkSystemLibrary("kernel32"); | 13 | test_obj.root_module.linkSystemLibrary("kernel32", .{}); |
| 14 | test_obj.linkSystemLibrary("ws2_32"); | 14 | test_obj.root_module.linkSystemLibrary("ws2_32", .{}); |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | const test_exe_mod = b.createModule(.{ | 17 | const test_exe_mod = b.createModule(.{ |