authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-04-16 23:47:05-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-01 16:35:27-07:00
log3b390e4f139220ed11918524288238c289ce0c6d
tree54ba9c72bdba89fa0286cdc99c7afe9e60bbb30a
parenta4fdda6ae04ffc72234d2c6baf22e13d9a5a99a3

revert most instances of anyerror to match origin/master


71 files changed, 430 insertions(+), 438 deletions(-)

lib/std/zig/string_literal.zig+2-2
......@@ -44,7 +44,7 @@ pub const Error = union(enum) {
4444 raw_string: []const u8,
4545 };
4646
47 fn formatMessage(self: FormatMessage, bw: *std.io.BufferedWriter, comptime f: []const u8) anyerror!void {
47 fn formatMessage(self: FormatMessage, bw: *std.io.BufferedWriter, comptime f: []const u8) !void {
4848 _ = f;
4949 switch (self.err) {
5050 .invalid_escape_character => |bad_index| try bw.print(
......@@ -318,7 +318,7 @@ test parseCharLiteral {
318318
319319/// Parses `bytes` as a Zig string literal and writes the result to the `std.io.Writer` type.
320320/// Asserts `bytes` has '"' at beginning and end.
321pub fn parseWrite(writer: *std.io.BufferedWriter, bytes: []const u8) anyerror!Result {
321pub fn parseWrite(writer: *std.io.BufferedWriter, bytes: []const u8) std.io.Writer.Error!Result {
322322 assert(bytes.len >= 2 and bytes[0] == '"' and bytes[bytes.len - 1] == '"');
323323
324324 var index: usize = 1;
lib/std/zon/stringify.zig+46-44
......@@ -40,7 +40,7 @@ pub const SerializeOptions = struct {
4040/// Serialize the given value as ZON.
4141///
4242/// It is asserted at comptime that `@TypeOf(val)` is not a recursive type.
43pub fn serialize(val: anytype, options: SerializeOptions, writer: *std.io.BufferedWriter) anyerror!void {
43pub fn serialize(val: anytype, options: SerializeOptions, writer: *std.io.BufferedWriter) std.io.Writer.Error!void {
4444 var s: Serializer = .{
4545 .writer = writer,
4646 .options = .{ .whitespace = options.whitespace },
......@@ -61,7 +61,7 @@ pub fn serializeMaxDepth(
6161 options: SerializeOptions,
6262 writer: *std.io.BufferedWriter,
6363 depth: usize,
64) anyerror!void {
64) std.io.Writer.Error!void {
6565 var s: Serializer = .{
6666 .writer = writer,
6767 .options = .{ .whitespace = options.whitespace },
......@@ -80,7 +80,7 @@ pub fn serializeArbitraryDepth(
8080 val: anytype,
8181 options: SerializeOptions,
8282 writer: *std.io.BufferedWriter,
83) anyerror!void {
83) std.io.Writer.Error!void {
8484 var s: Serializer = .{
8585 .writer = writer,
8686 .options = .{ .whitespace = options.whitespace },
......@@ -438,26 +438,28 @@ pub const Serializer = struct {
438438 indent_level: u8 = 0,
439439 writer: *std.io.BufferedWriter,
440440
441 pub const Error = std.io.Writer.Error;
442
441443 pub const Options = struct {
442444 /// If false, only syntactically necessary whitespace is emitted.
443445 whitespace: bool = true,
444446 };
445447
446448 /// Serialize a value, similar to `serialize`.
447 pub fn value(self: *Serializer, val: anytype, options: ValueOptions) anyerror!void {
449 pub fn value(self: *Serializer, val: anytype, options: ValueOptions) Error!void {
448450 comptime assert(!typeIsRecursive(@TypeOf(val)));
449451 return self.valueArbitraryDepth(val, options);
450452 }
451453
452454 /// Serialize a value, similar to `serializeMaxDepth`.
453455 /// Can return `error.ExceededMaxDepth`.
454 pub fn valueMaxDepth(self: *Serializer, val: anytype, options: ValueOptions, depth: usize) anyerror!void {
456 pub fn valueMaxDepth(self: *Serializer, val: anytype, options: ValueOptions, depth: usize) Error!void {
455457 try checkValueDepth(val, depth);
456458 return self.valueArbitraryDepth(val, options);
457459 }
458460
459461 /// Serialize a value, similar to `serializeArbitraryDepth`.
460 pub fn valueArbitraryDepth(self: *Serializer, val: anytype, options: ValueOptions) anyerror!void {
462 pub fn valueArbitraryDepth(self: *Serializer, val: anytype, options: ValueOptions) Error!void {
461463 comptime assert(canSerializeType(@TypeOf(val)));
462464 switch (@typeInfo(@TypeOf(val))) {
463465 .int, .comptime_int => if (options.emit_codepoint_literals.emitAsCodepoint(val)) |c| {
......@@ -582,12 +584,12 @@ pub const Serializer = struct {
582584 }
583585
584586 /// Serialize an integer.
585 pub fn int(self: *Serializer, val: anytype) anyerror!void {
587 pub fn int(self: *Serializer, val: anytype) Error!void {
586588 try self.writer.printIntOptions(val, 10, .lower, .{});
587589 }
588590
589591 /// Serialize a float.
590 pub fn float(self: *Serializer, val: anytype) anyerror!void {
592 pub fn float(self: *Serializer, val: anytype) Error!void {
591593 switch (@typeInfo(@TypeOf(val))) {
592594 .float => if (std.math.isNan(val)) {
593595 return self.writer.writeAll("nan");
......@@ -612,7 +614,7 @@ pub const Serializer = struct {
612614 /// Serialize `name` as an identifier prefixed with `.`.
613615 ///
614616 /// Escapes the identifier if necessary.
615 pub fn ident(self: *Serializer, name: []const u8) anyerror!void {
617 pub fn ident(self: *Serializer, name: []const u8) Error!void {
616618 try self.writer.print(".{fp_}", .{std.zig.fmtId(name)});
617619 }
618620
......@@ -622,7 +624,7 @@ pub const Serializer = struct {
622624 pub fn codePoint(
623625 self: *Serializer,
624626 val: u21,
625 ) anyerror!void {
627 ) Error!void {
626628 var buf: [8]u8 = undefined;
627629 const len = std.unicode.utf8Encode(val, &buf) catch return error.InvalidCodepoint;
628630 const str = buf[0..len];
......@@ -632,7 +634,7 @@ pub const Serializer = struct {
632634 /// Like `value`, but always serializes `val` as a tuple.
633635 ///
634636 /// Will fail at comptime if `val` is not a tuple, array, pointer to an array, or slice.
635 pub fn tuple(self: *Serializer, val: anytype, options: ValueOptions) anyerror!void {
637 pub fn tuple(self: *Serializer, val: anytype, options: ValueOptions) Error!void {
636638 comptime assert(!typeIsRecursive(@TypeOf(val)));
637639 try self.tupleArbitraryDepth(val, options);
638640 }
......@@ -645,7 +647,7 @@ pub const Serializer = struct {
645647 val: anytype,
646648 options: ValueOptions,
647649 depth: usize,
648 ) anyerror!void {
650 ) Error!void {
649651 try checkValueDepth(val, depth);
650652 try self.tupleArbitraryDepth(val, options);
651653 }
......@@ -657,11 +659,11 @@ pub const Serializer = struct {
657659 self: *Serializer,
658660 val: anytype,
659661 options: ValueOptions,
660 ) anyerror!void {
662 ) Error!void {
661663 try self.tupleImpl(val, options);
662664 }
663665
664 fn tupleImpl(self: *Serializer, val: anytype, options: ValueOptions) anyerror!void {
666 fn tupleImpl(self: *Serializer, val: anytype, options: ValueOptions) Error!void {
665667 comptime assert(canSerializeType(@TypeOf(val)));
666668 switch (@typeInfo(@TypeOf(val))) {
667669 .@"struct" => {
......@@ -683,7 +685,7 @@ pub const Serializer = struct {
683685 }
684686
685687 /// Like `value`, but always serializes `val` as a string.
686 pub fn string(self: *Serializer, val: []const u8) anyerror!void {
688 pub fn string(self: *Serializer, val: []const u8) Error!void {
687689 try std.fmt.format(self.writer, "\"{f}\"", .{std.zig.fmtEscapes(val)});
688690 }
689691
......@@ -703,7 +705,7 @@ pub const Serializer = struct {
703705 self: *Serializer,
704706 val: []const u8,
705707 options: MultilineStringOptions,
706 ) anyerror!void {
708 ) Error!void {
707709 // Make sure the string does not contain any carriage returns not followed by a newline
708710 var i: usize = 0;
709711 while (i < val.len) : (i += 1) {
......@@ -744,7 +746,7 @@ pub const Serializer = struct {
744746 pub fn beginStruct(
745747 self: *Serializer,
746748 options: SerializeContainerOptions,
747 ) anyerror!Struct {
749 ) Error!Struct {
748750 return Struct.begin(self, options);
749751 }
750752
......@@ -752,23 +754,23 @@ pub const Serializer = struct {
752754 pub fn beginTuple(
753755 self: *Serializer,
754756 options: SerializeContainerOptions,
755 ) anyerror!Tuple {
757 ) Error!Tuple {
756758 return Tuple.begin(self, options);
757759 }
758760
759 fn indent(self: *Serializer) anyerror!void {
761 fn indent(self: *Serializer) Error!void {
760762 if (self.options.whitespace) {
761763 try self.writer.splatByteAll(' ', 4 * self.indent_level);
762764 }
763765 }
764766
765 fn newline(self: *Serializer) anyerror!void {
767 fn newline(self: *Serializer) Error!void {
766768 if (self.options.whitespace) {
767769 try self.writer.writeByte('\n');
768770 }
769771 }
770772
771 fn newlineOrSpace(self: *Serializer, len: usize) anyerror!void {
773 fn newlineOrSpace(self: *Serializer, len: usize) Error!void {
772774 if (self.containerShouldWrap(len)) {
773775 try self.newline();
774776 } else {
......@@ -776,7 +778,7 @@ pub const Serializer = struct {
776778 }
777779 }
778780
779 fn space(self: *Serializer) anyerror!void {
781 fn space(self: *Serializer) Error!void {
780782 if (self.options.whitespace) {
781783 try self.writer.writeByte(' ');
782784 }
......@@ -786,7 +788,7 @@ pub const Serializer = struct {
786788 pub const Tuple = struct {
787789 container: Container,
788790
789 fn begin(parent: *Serializer, options: SerializeContainerOptions) anyerror!Tuple {
791 fn begin(parent: *Serializer, options: SerializeContainerOptions) Error!Tuple {
790792 return .{
791793 .container = try Container.begin(parent, .anon, options),
792794 };
......@@ -795,7 +797,7 @@ pub const Serializer = struct {
795797 /// Finishes serializing the tuple.
796798 ///
797799 /// Prints a trailing comma as configured when appropriate, and the closing bracket.
798 pub fn end(self: *Tuple) anyerror!void {
800 pub fn end(self: *Tuple) Error!void {
799801 try self.container.end();
800802 self.* = undefined;
801803 }
......@@ -805,7 +807,7 @@ pub const Serializer = struct {
805807 self: *Tuple,
806808 val: anytype,
807809 options: ValueOptions,
808 ) anyerror!void {
810 ) Error!void {
809811 try self.container.field(null, val, options);
810812 }
811813
......@@ -816,7 +818,7 @@ pub const Serializer = struct {
816818 val: anytype,
817819 options: ValueOptions,
818820 depth: usize,
819 ) anyerror!void {
821 ) Error!void {
820822 try self.container.fieldMaxDepth(null, val, options, depth);
821823 }
822824
......@@ -826,7 +828,7 @@ pub const Serializer = struct {
826828 self: *Tuple,
827829 val: anytype,
828830 options: ValueOptions,
829 ) anyerror!void {
831 ) Error!void {
830832 try self.container.fieldArbitraryDepth(null, val, options);
831833 }
832834
......@@ -834,7 +836,7 @@ pub const Serializer = struct {
834836 pub fn beginStructField(
835837 self: *Tuple,
836838 options: SerializeContainerOptions,
837 ) anyerror!Struct {
839 ) Error!Struct {
838840 try self.fieldPrefix();
839841 return self.container.serializer.beginStruct(options);
840842 }
......@@ -843,14 +845,14 @@ pub const Serializer = struct {
843845 pub fn beginTupleField(
844846 self: *Tuple,
845847 options: SerializeContainerOptions,
846 ) anyerror!Tuple {
848 ) Error!Tuple {
847849 try self.fieldPrefix();
848850 return self.container.serializer.beginTuple(options);
849851 }
850852
851853 /// Print a field prefix. This prints any necessary commas, and whitespace as
852854 /// configured. Useful if you want to serialize the field value yourself.
853 pub fn fieldPrefix(self: *Tuple) anyerror!void {
855 pub fn fieldPrefix(self: *Tuple) Error!void {
854856 try self.container.fieldPrefix(null);
855857 }
856858 };
......@@ -859,7 +861,7 @@ pub const Serializer = struct {
859861 pub const Struct = struct {
860862 container: Container,
861863
862 fn begin(parent: *Serializer, options: SerializeContainerOptions) anyerror!Struct {
864 fn begin(parent: *Serializer, options: SerializeContainerOptions) Error!Struct {
863865 return .{
864866 .container = try Container.begin(parent, .named, options),
865867 };
......@@ -868,7 +870,7 @@ pub const Serializer = struct {
868870 /// Finishes serializing the struct.
869871 ///
870872 /// Prints a trailing comma as configured when appropriate, and the closing bracket.
871 pub fn end(self: *Struct) anyerror!void {
873 pub fn end(self: *Struct) Error!void {
872874 try self.container.end();
873875 self.* = undefined;
874876 }
......@@ -879,7 +881,7 @@ pub const Serializer = struct {
879881 name: []const u8,
880882 val: anytype,
881883 options: ValueOptions,
882 ) anyerror!void {
884 ) Error!void {
883885 try self.container.field(name, val, options);
884886 }
885887
......@@ -891,7 +893,7 @@ pub const Serializer = struct {
891893 val: anytype,
892894 options: ValueOptions,
893895 depth: usize,
894 ) anyerror!void {
896 ) Error!void {
895897 try self.container.fieldMaxDepth(name, val, options, depth);
896898 }
897899
......@@ -902,7 +904,7 @@ pub const Serializer = struct {
902904 name: []const u8,
903905 val: anytype,
904906 options: ValueOptions,
905 ) anyerror!void {
907 ) Error!void {
906908 try self.container.fieldArbitraryDepth(name, val, options);
907909 }
908910
......@@ -911,7 +913,7 @@ pub const Serializer = struct {
911913 self: *Struct,
912914 name: []const u8,
913915 options: SerializeContainerOptions,
914 ) anyerror!Struct {
916 ) Error!Struct {
915917 try self.fieldPrefix(name);
916918 return self.container.serializer.beginStruct(options);
917919 }
......@@ -921,7 +923,7 @@ pub const Serializer = struct {
921923 self: *Struct,
922924 name: []const u8,
923925 options: SerializeContainerOptions,
924 ) anyerror!Tuple {
926 ) Error!Tuple {
925927 try self.fieldPrefix(name);
926928 return self.container.serializer.beginTuple(options);
927929 }
......@@ -929,7 +931,7 @@ pub const Serializer = struct {
929931 /// Print a field prefix. This prints any necessary commas, the field name (escaped if
930932 /// necessary) and whitespace as configured. Useful if you want to serialize the field
931933 /// value yourself.
932 pub fn fieldPrefix(self: *Struct, name: []const u8) anyerror!void {
934 pub fn fieldPrefix(self: *Struct, name: []const u8) Error!void {
933935 try self.container.fieldPrefix(name);
934936 }
935937 };
......@@ -946,7 +948,7 @@ pub const Serializer = struct {
946948 sz: *Serializer,
947949 field_style: FieldStyle,
948950 options: SerializeContainerOptions,
949 ) anyerror!Container {
951 ) Error!Container {
950952 if (options.shouldWrap()) sz.indent_level +|= 1;
951953 try sz.writer.writeAll(".{");
952954 return .{
......@@ -957,7 +959,7 @@ pub const Serializer = struct {
957959 };
958960 }
959961
960 fn end(self: *Container) anyerror!void {
962 fn end(self: *Container) Error!void {
961963 if (self.options.shouldWrap()) self.serializer.indent_level -|= 1;
962964 if (!self.empty) {
963965 if (self.options.shouldWrap()) {
......@@ -974,7 +976,7 @@ pub const Serializer = struct {
974976 self.* = undefined;
975977 }
976978
977 fn fieldPrefix(self: *Container, name: ?[]const u8) anyerror!void {
979 fn fieldPrefix(self: *Container, name: ?[]const u8) Error!void {
978980 if (!self.empty) {
979981 try self.serializer.writer.writeByte(',');
980982 }
......@@ -998,7 +1000,7 @@ pub const Serializer = struct {
9981000 name: ?[]const u8,
9991001 val: anytype,
10001002 options: ValueOptions,
1001 ) anyerror!void {
1003 ) Error!void {
10021004 comptime assert(!typeIsRecursive(@TypeOf(val)));
10031005 try self.fieldArbitraryDepth(name, val, options);
10041006 }
......@@ -1010,7 +1012,7 @@ pub const Serializer = struct {
10101012 val: anytype,
10111013 options: ValueOptions,
10121014 depth: usize,
1013 ) anyerror!void {
1015 ) Error!void {
10141016 try checkValueDepth(val, depth);
10151017 try self.fieldArbitraryDepth(name, val, options);
10161018 }
......@@ -1020,7 +1022,7 @@ pub const Serializer = struct {
10201022 name: ?[]const u8,
10211023 val: anytype,
10221024 options: ValueOptions,
1023 ) anyerror!void {
1025 ) Error!void {
10241026 try self.fieldPrefix(name);
10251027 try self.serializer.valueArbitraryDepth(val, options);
10261028 }
src/Air.zig+1-1
......@@ -957,7 +957,7 @@ pub const Inst = struct {
957957 return index.unwrap().target;
958958 }
959959
960 pub fn format(index: Index, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
960 pub fn format(index: Index, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
961961 try bw.writeByte('%');
962962 switch (index.unwrap()) {
963963 .ref => {},
src/Air/Liveness.zig+2-2
......@@ -2036,7 +2036,7 @@ fn fmtInstSet(set: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void)) FmtIns
20362036const FmtInstSet = struct {
20372037 set: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void),
20382038
2039 pub fn format(val: FmtInstSet, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
2039 pub fn format(val: FmtInstSet, bw: *std.io.BufferedWriter, comptime _: []const u8) !void {
20402040 if (val.set.count() == 0) {
20412041 try bw.writeAll("[no instructions]");
20422042 return;
......@@ -2056,7 +2056,7 @@ fn fmtInstList(list: []const Air.Inst.Index) FmtInstList {
20562056const FmtInstList = struct {
20572057 list: []const Air.Inst.Index,
20582058
2059 pub fn format(val: FmtInstList, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
2059 pub fn format(val: FmtInstList, bw: *std.io.BufferedWriter, comptime _: []const u8) !void {
20602060 if (val.list.len == 0) {
20612061 try bw.writeAll("[no instructions]");
20622062 return;
src/Air/print.zig+46-44
......@@ -91,14 +91,16 @@ const Writer = struct {
9191 indent: usize,
9292 skip_body: bool,
9393
94 fn writeBody(w: *Writer, s: *std.io.BufferedWriter, body: []const Air.Inst.Index) anyerror!void {
94 const Error = std.io.Writer.Error;
95
96 fn writeBody(w: *Writer, s: *std.io.BufferedWriter, body: []const Air.Inst.Index) Error!void {
9597 for (body) |inst| {
9698 try w.writeInst(s, inst);
9799 try s.writeByte('\n');
98100 }
99101 }
100102
101 fn writeInst(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
103 fn writeInst(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
102104 const tag = w.air.instructions.items(.tag)[@intFromEnum(inst)];
103105 try s.splatByteAll(' ', w.indent);
104106 try s.print("{f}{c}= {s}(", .{
......@@ -338,19 +340,19 @@ const Writer = struct {
338340 try s.writeByte(')');
339341 }
340342
341 fn writeBinOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
343 fn writeBinOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
342344 const bin_op = w.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
343345 try w.writeOperand(s, inst, 0, bin_op.lhs);
344346 try s.writeAll(", ");
345347 try w.writeOperand(s, inst, 1, bin_op.rhs);
346348 }
347349
348 fn writeUnOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
350 fn writeUnOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
349351 const un_op = w.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
350352 try w.writeOperand(s, inst, 0, un_op);
351353 }
352354
353 fn writeNoOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
355 fn writeNoOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
354356 _ = w;
355357 _ = s;
356358 _ = inst;
......@@ -361,25 +363,25 @@ const Writer = struct {
361363 return ty.print(s, w.pt);
362364 }
363365
364 fn writeTy(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
366 fn writeTy(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
365367 const ty = w.air.instructions.items(.data)[@intFromEnum(inst)].ty;
366368 try w.writeType(s, ty);
367369 }
368370
369 fn writeArg(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
371 fn writeArg(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
370372 const arg = w.air.instructions.items(.data)[@intFromEnum(inst)].arg;
371373 try w.writeType(s, arg.ty.toType());
372374 try s.print(", {d}", .{arg.zir_param_index});
373375 }
374376
375 fn writeTyOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
377 fn writeTyOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
376378 const ty_op = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
377379 try w.writeType(s, ty_op.ty.toType());
378380 try s.writeAll(", ");
379381 try w.writeOperand(s, inst, 0, ty_op.operand);
380382 }
381383
382 fn writeBlock(w: *Writer, s: *std.io.BufferedWriter, tag: Air.Inst.Tag, inst: Air.Inst.Index) anyerror!void {
384 fn writeBlock(w: *Writer, s: *std.io.BufferedWriter, tag: Air.Inst.Tag, inst: Air.Inst.Index) Error!void {
383385 const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
384386 try w.writeType(s, ty_pl.ty.toType());
385387 const body: []const Air.Inst.Index = @ptrCast(switch (tag) {
......@@ -420,7 +422,7 @@ const Writer = struct {
420422 }
421423 }
422424
423 fn writeLoop(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
425 fn writeLoop(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
424426 const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
425427 const extra = w.air.extraData(Air.Block, ty_pl.payload);
426428 const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]);
......@@ -436,7 +438,7 @@ const Writer = struct {
436438 try s.writeAll("}");
437439 }
438440
439 fn writeAggregateInit(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
441 fn writeAggregateInit(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
440442 const zcu = w.pt.zcu;
441443 const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
442444 const vector_ty = ty_pl.ty.toType();
......@@ -452,7 +454,7 @@ const Writer = struct {
452454 try s.writeAll("]");
453455 }
454456
455 fn writeUnionInit(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
457 fn writeUnionInit(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
456458 const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
457459 const extra = w.air.extraData(Air.UnionInit, ty_pl.payload).data;
458460
......@@ -460,7 +462,7 @@ const Writer = struct {
460462 try w.writeOperand(s, inst, 0, extra.init);
461463 }
462464
463 fn writeStructField(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
465 fn writeStructField(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
464466 const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
465467 const extra = w.air.extraData(Air.StructField, ty_pl.payload).data;
466468
......@@ -468,7 +470,7 @@ const Writer = struct {
468470 try s.print(", {d}", .{extra.field_index});
469471 }
470472
471 fn writeTyPlBin(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
473 fn writeTyPlBin(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
472474 const data = w.air.instructions.items(.data);
473475 const ty_pl = data[@intFromEnum(inst)].ty_pl;
474476 const extra = w.air.extraData(Air.Bin, ty_pl.payload).data;
......@@ -481,7 +483,7 @@ const Writer = struct {
481483 try w.writeOperand(s, inst, 1, extra.rhs);
482484 }
483485
484 fn writeCmpxchg(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
486 fn writeCmpxchg(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
485487 const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
486488 const extra = w.air.extraData(Air.Cmpxchg, ty_pl.payload).data;
487489
......@@ -495,7 +497,7 @@ const Writer = struct {
495497 });
496498 }
497499
498 fn writeMulAdd(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
500 fn writeMulAdd(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
499501 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
500502 const extra = w.air.extraData(Air.Bin, pl_op.payload).data;
501503
......@@ -506,7 +508,7 @@ const Writer = struct {
506508 try w.writeOperand(s, inst, 2, pl_op.operand);
507509 }
508510
509 fn writeShuffleOne(w: *Writer, s: anytype, inst: Air.Inst.Index) anyerror!void {
511 fn writeShuffleOne(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
510512 const unwrapped = w.air.unwrapShuffleOne(w.pt.zcu, inst);
511513 try w.writeType(s, unwrapped.result_ty);
512514 try s.writeAll(", ");
......@@ -522,7 +524,7 @@ const Writer = struct {
522524 try s.writeByte(']');
523525 }
524526
525 fn writeShuffleTwo(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
527 fn writeShuffleTwo(w: *Writer, s: anytype, inst: Air.Inst.Index) Error!void {
526528 const unwrapped = w.air.unwrapShuffleTwo(w.pt.zcu, inst);
527529 try w.writeType(s, unwrapped.result_ty);
528530 try s.writeAll(", ");
......@@ -541,7 +543,7 @@ const Writer = struct {
541543 try s.writeByte(']');
542544 }
543545
544 fn writeSelect(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
546 fn writeSelect(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
545547 const zcu = w.pt.zcu;
546548 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
547549 const extra = w.air.extraData(Air.Bin, pl_op.payload).data;
......@@ -556,14 +558,14 @@ const Writer = struct {
556558 try w.writeOperand(s, inst, 2, extra.rhs);
557559 }
558560
559 fn writeReduce(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
561 fn writeReduce(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
560562 const reduce = w.air.instructions.items(.data)[@intFromEnum(inst)].reduce;
561563
562564 try w.writeOperand(s, inst, 0, reduce.operand);
563565 try s.print(", {s}", .{@tagName(reduce.operation)});
564566 }
565567
566 fn writeCmpVector(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
568 fn writeCmpVector(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
567569 const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
568570 const extra = w.air.extraData(Air.VectorCmp, ty_pl.payload).data;
569571
......@@ -573,7 +575,7 @@ const Writer = struct {
573575 try w.writeOperand(s, inst, 1, extra.rhs);
574576 }
575577
576 fn writeVectorStoreElem(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
578 fn writeVectorStoreElem(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
577579 const data = w.air.instructions.items(.data)[@intFromEnum(inst)].vector_store_elem;
578580 const extra = w.air.extraData(Air.VectorCmp, data.payload).data;
579581
......@@ -584,21 +586,21 @@ const Writer = struct {
584586 try w.writeOperand(s, inst, 2, extra.rhs);
585587 }
586588
587 fn writeRuntimeNavPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) std.io.Writer.Error!void {
589 fn writeRuntimeNavPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
588590 const ip = &w.pt.zcu.intern_pool;
589591 const ty_nav = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_nav;
590592 try w.writeType(s, .fromInterned(ty_nav.ty));
591593 try s.print(", '{}'", .{ip.getNav(ty_nav.nav).fqn.fmt(ip)});
592594 }
593595
594 fn writeAtomicLoad(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) std.io.Writer.Error!void {
596 fn writeAtomicLoad(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
595597 const atomic_load = w.air.instructions.items(.data)[@intFromEnum(inst)].atomic_load;
596598
597599 try w.writeOperand(s, inst, 0, atomic_load.ptr);
598600 try s.print(", {s}", .{@tagName(atomic_load.order)});
599601 }
600602
601 fn writePrefetch(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
603 fn writePrefetch(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
602604 const prefetch = w.air.instructions.items(.data)[@intFromEnum(inst)].prefetch;
603605
604606 try w.writeOperand(s, inst, 0, prefetch.ptr);
......@@ -612,7 +614,7 @@ const Writer = struct {
612614 s: *std.io.BufferedWriter,
613615 inst: Air.Inst.Index,
614616 order: std.builtin.AtomicOrder,
615 ) anyerror!void {
617 ) Error!void {
616618 const bin_op = w.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
617619 try w.writeOperand(s, inst, 0, bin_op.lhs);
618620 try s.writeAll(", ");
......@@ -620,7 +622,7 @@ const Writer = struct {
620622 try s.print(", {s}", .{@tagName(order)});
621623 }
622624
623 fn writeAtomicRmw(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
625 fn writeAtomicRmw(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
624626 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
625627 const extra = w.air.extraData(Air.AtomicRmw, pl_op.payload).data;
626628
......@@ -630,7 +632,7 @@ const Writer = struct {
630632 try s.print(", {s}, {s}", .{ @tagName(extra.op()), @tagName(extra.ordering()) });
631633 }
632634
633 fn writeFieldParentPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
635 fn writeFieldParentPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
634636 const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
635637 const extra = w.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;
636638
......@@ -638,7 +640,7 @@ const Writer = struct {
638640 try s.print(", {d}", .{extra.field_index});
639641 }
640642
641 fn writeAssembly(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
643 fn writeAssembly(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
642644 const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
643645 const extra = w.air.extraData(Air.Asm, ty_pl.payload);
644646 const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0;
......@@ -711,19 +713,19 @@ const Writer = struct {
711713 try s.print(", \"{f}\"", .{std.zig.fmtEscapes(asm_source)});
712714 }
713715
714 fn writeDbgStmt(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
716 fn writeDbgStmt(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
715717 const dbg_stmt = w.air.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt;
716718 try s.print("{d}:{d}", .{ dbg_stmt.line + 1, dbg_stmt.column + 1 });
717719 }
718720
719 fn writeDbgVar(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
721 fn writeDbgVar(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
720722 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
721723 try w.writeOperand(s, inst, 0, pl_op.operand);
722724 const name: Air.NullTerminatedString = @enumFromInt(pl_op.payload);
723725 try s.print(", \"{f}\"", .{std.zig.fmtEscapes(name.toSlice(w.air))});
724726 }
725727
726 fn writeCall(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
728 fn writeCall(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
727729 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
728730 const extra = w.air.extraData(Air.Call, pl_op.payload);
729731 const args = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[extra.end..][0..extra.data.args_len]));
......@@ -736,19 +738,19 @@ const Writer = struct {
736738 try s.writeAll("]");
737739 }
738740
739 fn writeBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
741 fn writeBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
740742 const br = w.air.instructions.items(.data)[@intFromEnum(inst)].br;
741743 try w.writeInstIndex(s, br.block_inst, false);
742744 try s.writeAll(", ");
743745 try w.writeOperand(s, inst, 0, br.operand);
744746 }
745747
746 fn writeRepeat(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
748 fn writeRepeat(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
747749 const repeat = w.air.instructions.items(.data)[@intFromEnum(inst)].repeat;
748750 try w.writeInstIndex(s, repeat.loop_inst, false);
749751 }
750752
751 fn writeTry(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
753 fn writeTry(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
752754 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
753755 const extra = w.air.extraData(Air.Try, pl_op.payload);
754756 const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]);
......@@ -782,7 +784,7 @@ const Writer = struct {
782784 }
783785 }
784786
785 fn writeTryPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
787 fn writeTryPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
786788 const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
787789 const extra = w.air.extraData(Air.TryPtr, ty_pl.payload);
788790 const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]);
......@@ -819,7 +821,7 @@ const Writer = struct {
819821 }
820822 }
821823
822 fn writeCondBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
824 fn writeCondBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
823825 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
824826 const extra = w.air.extraData(Air.CondBr, pl_op.payload);
825827 const then_body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.then_body_len]);
......@@ -878,7 +880,7 @@ const Writer = struct {
878880 try s.writeAll("}");
879881 }
880882
881 fn writeSwitchBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
883 fn writeSwitchBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
882884 const switch_br = w.air.unwrapSwitch(inst);
883885
884886 const liveness: Air.Liveness.SwitchBrTable = if (w.liveness) |liveness|
......@@ -964,18 +966,18 @@ const Writer = struct {
964966 try s.splatByteAll(' ', old_indent);
965967 }
966968
967 fn writeWasmMemorySize(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
969 fn writeWasmMemorySize(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
968970 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
969971 try s.print("{d}", .{pl_op.payload});
970972 }
971973
972 fn writeWasmMemoryGrow(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
974 fn writeWasmMemoryGrow(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
973975 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
974976 try s.print("{d}, ", .{pl_op.payload});
975977 try w.writeOperand(s, inst, 0, pl_op.operand);
976978 }
977979
978 fn writeWorkDimension(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void {
980 fn writeWorkDimension(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void {
979981 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
980982 try s.print("{d}", .{pl_op.payload});
981983 }
......@@ -986,7 +988,7 @@ const Writer = struct {
986988 inst: Air.Inst.Index,
987989 op_index: usize,
988990 operand: Air.Inst.Ref,
989 ) anyerror!void {
991 ) Error!void {
990992 const small_tomb_bits = Air.Liveness.bpi - 1;
991993 const dies = if (w.liveness) |liveness| blk: {
992994 if (op_index < small_tomb_bits)
......@@ -1011,7 +1013,7 @@ const Writer = struct {
10111013 s: anytype,
10121014 operand: Air.Inst.Ref,
10131015 dies: bool,
1014 ) anyerror!void {
1016 ) Error!void {
10151017 if (@intFromEnum(operand) < InternPool.static_len) {
10161018 return s.print("@{}", .{operand});
10171019 } else if (operand.toInterned()) |ip_index| {
......@@ -1031,7 +1033,7 @@ const Writer = struct {
10311033 s: *std.io.BufferedWriter,
10321034 inst: Air.Inst.Index,
10331035 dies: bool,
1034 ) anyerror!void {
1036 ) Error!void {
10351037 _ = w;
10361038 try s.print("{f}", .{inst});
10371039 if (dies) try s.writeByte('!');
src/Compilation.zig+1-1
......@@ -6024,7 +6024,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
60246024
60256025 // In .rc files, a " within a quoted string is escaped as ""
60266026 const fmtRcEscape = struct {
6027 fn formatRcEscape(bytes: []const u8, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
6027 fn formatRcEscape(bytes: []const u8, bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void {
60286028 _ = fmt;
60296029 for (bytes) |byte| switch (byte) {
60306030 '"' => try bw.writeAll("\"\""),
src/InternPool.zig+1-1
......@@ -1888,7 +1888,7 @@ pub const NullTerminatedString = enum(u32) {
18881888 string: NullTerminatedString,
18891889 ip: *const InternPool,
18901890 };
1891 fn format(data: FormatData, bw: *std.io.BufferedWriter, comptime specifier: []const u8) anyerror!void {
1891 fn format(data: FormatData, bw: *std.io.BufferedWriter, comptime specifier: []const u8) std.io.Writer.Error!void {
18921892 const slice = data.string.toSlice(data.ip);
18931893 if (comptime std.mem.eql(u8, specifier, "")) {
18941894 try bw.writeAll(slice);
src/Package/Fetch/git.zig+1-1
......@@ -119,7 +119,7 @@ pub const Oid = union(Format) {
119119 } else error.InvalidOid;
120120 }
121121
122 pub fn format(oid: Oid, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
122 pub fn format(oid: Oid, bw: *std.io.BufferedWriter, comptime fmt: []const u8) std.io.Writer.Error!void {
123123 _ = fmt;
124124 try bw.print("{x}", .{oid.slice()});
125125 }
src/Sema.zig+2-2
......@@ -9544,7 +9544,7 @@ fn callConvSupportsVarArgs(cc: std.builtin.CallingConvention.Tag) bool {
95449544fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: std.builtin.CallingConvention.Tag) CompileError!void {
95459545 const CallingConventionsSupportingVarArgsList = struct {
95469546 arch: std.Target.Cpu.Arch,
9547 pub fn format(ctx: @This(), bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
9547 pub fn format(ctx: @This(), bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void {
95489548 _ = fmt;
95499549 var first = true;
95509550 for (calling_conventions_supporting_var_args) |cc_inner| {
......@@ -9990,7 +9990,7 @@ fn finishFunc(
99909990 .bad_arch => |allowed_archs| {
99919991 const ArchListFormatter = struct {
99929992 archs: []const std.Target.Cpu.Arch,
9993 pub fn format(formatter: @This(), bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
9993 pub fn format(formatter: @This(), bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void {
99949994 _ = fmt;
99959995 for (formatter.archs, 0..) |arch, i| {
99969996 if (i != 0)
src/Type.zig+4-4
......@@ -121,7 +121,7 @@ pub fn eql(a: Type, b: Type, zcu: *const Zcu) bool {
121121 return a.toIntern() == b.toIntern();
122122}
123123
124pub fn format(ty: Type, bw: *std.io.BufferedWriter, comptime f: []const u8) anyerror!usize {
124pub fn format(ty: Type, bw: *std.io.BufferedWriter, comptime f: []const u8) !usize {
125125 _ = ty;
126126 _ = f;
127127 _ = bw;
......@@ -142,7 +142,7 @@ const FormatContext = struct {
142142 pt: Zcu.PerThread,
143143};
144144
145fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime f: []const u8) anyerror!void {
145fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime f: []const u8) !void {
146146 comptime assert(f.len == 0);
147147 try print(ctx.ty, bw, ctx.pt);
148148}
......@@ -153,14 +153,14 @@ pub fn fmtDebug(ty: Type) std.fmt.Formatter(dump) {
153153
154154/// This is a debug function. In order to print types in a meaningful way
155155/// we also need access to the module.
156pub fn dump(start_type: Type, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void {
156pub fn dump(start_type: Type, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) !void {
157157 comptime assert(unused_format_string.len == 0);
158158 return bw.print("{any}", .{start_type.ip_index});
159159}
160160
161161/// Prints a name suitable for `@typeName`.
162162/// TODO: take an `opt_sema` to pass to `fmtValue` when printing sentinels.
163pub fn print(ty: Type, bw: *std.io.BufferedWriter, pt: Zcu.PerThread) anyerror!void {
163pub fn print(ty: Type, bw: *std.io.BufferedWriter, pt: Zcu.PerThread) std.io.Writer.Error!void {
164164 const zcu = pt.zcu;
165165 const ip = &zcu.intern_pool;
166166 switch (ip.indexToKey(ty.toIntern())) {
src/Zcu.zig+2-2
......@@ -4344,7 +4344,7 @@ pub fn fmtDependee(zcu: *Zcu, d: InternPool.Dependee) std.fmt.Formatter(formatDe
43444344 return .{ .data = .{ .dependee = d, .zcu = zcu } };
43454345}
43464346
4347fn formatAnalUnit(data: struct { unit: AnalUnit, zcu: *Zcu }, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
4347fn formatAnalUnit(data: struct { unit: AnalUnit, zcu: *Zcu }, bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void {
43484348 _ = fmt;
43494349 const zcu = data.zcu;
43504350 const ip = &zcu.intern_pool;
......@@ -4368,7 +4368,7 @@ fn formatAnalUnit(data: struct { unit: AnalUnit, zcu: *Zcu }, bw: *std.io.Buffer
43684368 .memoized_state => return bw.writeAll("memoized_state"),
43694369 }
43704370}
4371fn formatDependee(data: struct { dependee: InternPool.Dependee, zcu: *Zcu }, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
4371fn formatDependee(data: struct { dependee: InternPool.Dependee, zcu: *Zcu }, bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void {
43724372 _ = fmt;
43734373 const zcu = data.zcu;
43744374 const ip = &zcu.intern_pool;
src/arch/aarch64/Emit.zig+1-5
......@@ -71,10 +71,6 @@ const BranchType = enum {
7171};
7272
7373pub fn emitMir(emit: *Emit) InnerError!void {
74 return @errorCast(emit.emitMirInner());
75}
76
77fn emitMirInner(emit: *Emit) anyerror!void {
7874 const mir_tags = emit.mir.instructions.items(.tag);
7975
8076 // Find smallest lowerings for branch instructions
......@@ -441,7 +437,7 @@ fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
441437 return error.EmitFail;
442438}
443439
444fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) anyerror!void {
440fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) InnerError!void {
445441 const delta_line = @as(i33, line) - @as(i33, emit.prev_di_line);
446442 const delta_pc: usize = emit.code.items.len - emit.prev_di_pc;
447443 log.debug(" (advance pc={d} and line={d})", .{ delta_pc, delta_line });
src/arch/arm/Emit.zig-4
......@@ -68,10 +68,6 @@ const BranchType = enum {
6868};
6969
7070pub fn emitMir(emit: *Emit) InnerError!void {
71 return @errorCast(emit.emitMirInner());
72}
73
74fn emitMirInner(emit: *Emit) anyerror!void {
7571 const mir_tags = emit.mir.instructions.items(.tag);
7672
7773 // Find smallest lowerings for branch instructions
src/arch/riscv64/CodeGen.zig+5-5
......@@ -566,7 +566,7 @@ const InstTracking = struct {
566566 }
567567 }
568568
569 pub fn format(inst_tracking: InstTracking, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
569 pub fn format(inst_tracking: InstTracking, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
570570 if (!std.meta.eql(inst_tracking.long, inst_tracking.short)) try bw.print("|{}| ", .{inst_tracking.long});
571571 try bw.print("{}", .{inst_tracking.short});
572572 }
......@@ -932,7 +932,7 @@ const FormatWipMirData = struct {
932932 func: *Func,
933933 inst: Mir.Inst.Index,
934934};
935fn formatWipMir(data: FormatWipMirData, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
935fn formatWipMir(data: FormatWipMirData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
936936 const pt = data.func.pt;
937937 const comp = pt.zcu.comp;
938938 var lower: Lower = .{
......@@ -980,7 +980,7 @@ const FormatNavData = struct {
980980 ip: *const InternPool,
981981 nav_index: InternPool.Nav.Index,
982982};
983fn formatNav(data: FormatNavData, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
983fn formatNav(data: FormatNavData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
984984 try bw.print("{f}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)});
985985}
986986fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(formatNav) {
......@@ -994,7 +994,7 @@ const FormatAirData = struct {
994994 func: *Func,
995995 inst: Air.Inst.Index,
996996};
997fn formatAir(data: FormatAirData, _: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
997fn formatAir(data: FormatAirData, _: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
998998 data.func.air.dumpInst(data.inst, data.func.pt, data.func.liveness);
999999}
10001000fn fmtAir(func: *Func, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) {
......@@ -1004,7 +1004,7 @@ fn fmtAir(func: *Func, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) {
10041004const FormatTrackingData = struct {
10051005 func: *Func,
10061006};
1007fn formatTracking(data: FormatTrackingData, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
1007fn formatTracking(data: FormatTrackingData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
10081008 var it = data.func.inst_tracking.iterator();
10091009 while (it.next()) |entry| try bw.print("\n%{d} = {f}", .{ entry.key_ptr.*, entry.value_ptr.* });
10101010}
src/arch/riscv64/Emit.zig-4
......@@ -18,10 +18,6 @@ pub const Error = Lower.Error || error{
1818};
1919
2020pub fn emitMir(emit: *Emit) Error!void {
21 return @errorCast(emit.emitMirInner());
22}
23
24fn emitMirInner(emit: *Emit) anyerror!void {
2521 const gpa = emit.bin_file.comp.gpa;
2622 var aw: std.io.AllocatingWriter = undefined;
2723 const bw = aw.fromArrayList(gpa, emit.code);
src/arch/riscv64/Mir.zig+1-1
......@@ -92,7 +92,7 @@ pub const Inst = struct {
9292 },
9393 };
9494
95 pub fn format(inst: Inst, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
95 pub fn format(inst: Inst, bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void {
9696 assert(fmt.len == 0);
9797 try bw.print("Tag: {s}, Data: {s}", .{ @tagName(inst.tag), @tagName(inst.data) });
9898 }
src/arch/riscv64/bits.zig+1-1
......@@ -256,7 +256,7 @@ pub const FrameIndex = enum(u32) {
256256 return @intFromEnum(fi) < named_count;
257257 }
258258
259 pub fn format(fi: FrameIndex, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
259 pub fn format(fi: FrameIndex, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
260260 try bw.writeAll("FrameIndex");
261261 if (fi.isNamed())
262262 try bw.print(".{s}", .{@tagName(fi)})
src/arch/wasm/Emit.zig+3-7
......@@ -22,10 +22,6 @@ pub const Error = error{
2222};
2323
2424pub fn lowerToCode(emit: *Emit) Error!void {
25 return @errorCast(emit.lowerToCodeInner());
26}
27
28fn lowerToCodeInner(emit: *Emit) anyerror!void {
2925 const mir = &emit.mir;
3026 const bw = emit.bw;
3127 const wasm = emit.wasm;
......@@ -897,12 +893,12 @@ fn lowerToCodeInner(emit: *Emit) anyerror!void {
897893}
898894
899895/// Asserts 20 unused capacity.
900fn encodeMemArg(bw: *std.io.BufferedWriter, mem_arg: Mir.MemArg) anyerror!void {
896fn encodeMemArg(bw: *std.io.BufferedWriter, mem_arg: Mir.MemArg) std.io.Writer.Error!void {
901897 try bw.writeLeb128(Wasm.Alignment.fromNonzeroByteUnits(mem_arg.alignment).toLog2Units());
902898 try bw.writeLeb128(mem_arg.offset);
903899}
904900
905fn uavRefObj(wasm: *Wasm, bw: *std.io.BufferedWriter, value: InternPool.Index, offset: i32, is_wasm32: bool) !void {
901fn uavRefObj(wasm: *Wasm, bw: *std.io.BufferedWriter, value: InternPool.Index, offset: i32, is_wasm32: bool) std.io.Writer.Error!void {
906902 const comp = wasm.base.comp;
907903 const gpa = comp.gpa;
908904 const opcode: std.wasm.Opcode = if (is_wasm32) .i32_const else .i64_const;
......@@ -951,6 +947,6 @@ fn navRefOff(wasm: *Wasm, bw: *std.io.BufferedWriter, data: Mir.NavRefOff, is_wa
951947 }
952948}
953949
954fn appendOutputFunctionIndex(bw: *std.io.BufferedWriter, i: Wasm.OutputFunctionIndex) anyerror!void {
950fn appendOutputFunctionIndex(bw: *std.io.BufferedWriter, i: Wasm.OutputFunctionIndex) std.io.Writer.Error!void {
955951 return bw.writeLeb128(@intFromEnum(i));
956952}
src/arch/x86_64/CodeGen.zig+6-6
......@@ -524,7 +524,7 @@ pub const MCValue = union(enum) {
524524 };
525525 }
526526
527 pub fn format(mcv: MCValue, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
527 pub fn format(mcv: MCValue, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
528528 switch (mcv) {
529529 .none, .unreach, .dead, .undef => try bw.print("({s})", .{@tagName(mcv)}),
530530 .immediate => |pl| try bw.print("0x{x}", .{pl}),
......@@ -811,7 +811,7 @@ const InstTracking = struct {
811811 }
812812 }
813813
814 pub fn format(tracking: InstTracking, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
814 pub fn format(tracking: InstTracking, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
815815 if (!std.meta.eql(tracking.long, tracking.short)) try bw.print("|{f}| ", .{tracking.long});
816816 try bw.print("{f}", .{tracking.short});
817817 }
......@@ -1087,7 +1087,7 @@ const FormatNavData = struct {
10871087 ip: *const InternPool,
10881088 nav_index: InternPool.Nav.Index,
10891089};
1090fn formatNav(data: FormatNavData, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
1090fn formatNav(data: FormatNavData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
10911091 try bw.print("{f}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)});
10921092}
10931093fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(formatNav) {
......@@ -1101,7 +1101,7 @@ const FormatAirData = struct {
11011101 self: *CodeGen,
11021102 inst: Air.Inst.Index,
11031103};
1104fn formatAir(data: FormatAirData, _: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
1104fn formatAir(data: FormatAirData, _: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
11051105 data.self.air.dumpInst(data.inst, data.self.pt, data.self.liveness);
11061106}
11071107fn fmtAir(self: *CodeGen, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) {
......@@ -1112,7 +1112,7 @@ const FormatWipMirData = struct {
11121112 self: *CodeGen,
11131113 inst: Mir.Inst.Index,
11141114};
1115fn formatWipMir(data: FormatWipMirData, bw: *std.io.BufferedWriter, comptime _: []const u8) !void {
1115fn formatWipMir(data: FormatWipMirData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
11161116 var lower: Lower = .{
11171117 .target = data.self.target,
11181118 .allocator = data.self.gpa,
......@@ -1208,7 +1208,7 @@ fn fmtWipMir(self: *CodeGen, inst: Mir.Inst.Index) std.fmt.Formatter(formatWipMi
12081208const FormatTrackingData = struct {
12091209 self: *CodeGen,
12101210};
1211fn formatTracking(data: FormatTrackingData, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
1211fn formatTracking(data: FormatTrackingData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
12121212 var it = data.self.inst_tracking.iterator();
12131213 while (it.next()) |entry| try bw.print("\n{f} = {f}", .{ entry.key_ptr.*, entry.value_ptr.* });
12141214}
src/arch/x86_64/Disassembler.zig+3-7
......@@ -31,10 +31,6 @@ pub fn init(code: []const u8) Disassembler {
3131}
3232
3333pub fn next(dis: *Disassembler) Error!?Instruction {
34 return @errorCast(dis.nextInner());
35}
36
37fn nextInner(dis: *Disassembler) anyerror!?Instruction {
3834 const prefixes = try dis.parsePrefixes();
3935
4036 const enc = try dis.parseEncoding(prefixes) orelse return error.UnknownOpcode;
......@@ -375,7 +371,7 @@ fn parseGpRegister(low_enc: u3, is_extended: bool, rex: Rex, bit_size: u64) Regi
375371 };
376372}
377373
378fn parseImm(dis: *Disassembler, kind: Encoding.Op) anyerror!Immediate {
374fn parseImm(dis: *Disassembler, kind: Encoding.Op) !Immediate {
379375 var br: std.io.BufferedReader = undefined;
380376 br.initFixed(dis.code[dis.pos..]);
381377 defer dis.pos += br.seek;
......@@ -391,7 +387,7 @@ fn parseImm(dis: *Disassembler, kind: Encoding.Op) anyerror!Immediate {
391387 };
392388}
393389
394fn parseOffset(dis: *Disassembler) anyerror!u64 {
390fn parseOffset(dis: *Disassembler) !u64 {
395391 var br: std.io.BufferedReader = undefined;
396392 br.initFixed(dis.code[dis.pos..]);
397393 defer dis.pos += br.seek;
......@@ -467,7 +463,7 @@ fn parseSibByte(dis: *Disassembler) !Sib {
467463 return Sib{ .scale = scale, .index = index, .base = base };
468464}
469465
470fn parseDisplacement(dis: *Disassembler, modrm: ModRm, sib: ?Sib) anyerror!i32 {
466fn parseDisplacement(dis: *Disassembler, modrm: ModRm, sib: ?Sib) !i32 {
471467 var br: std.io.BufferedReader = undefined;
472468 br.initFixed(dis.code[dis.pos..]);
473469 defer dis.pos += br.seek;
src/arch/x86_64/Emit.zig+1-1
......@@ -909,7 +909,7 @@ const Loc = struct {
909909 is_stmt: bool,
910910};
911911
912fn dbgAdvancePCAndLine(emit: *Emit, loc: Loc, pc: usize) anyerror!void {
912fn dbgAdvancePCAndLine(emit: *Emit, loc: Loc, pc: usize) Error!void {
913913 const delta_line = @as(i33, loc.line) - @as(i33, emit.prev_di_loc.line);
914914 const delta_pc = pc - emit.prev_di_pc;
915915 log.debug(" (advance pc={d} and line={d})", .{ delta_pc, delta_line });
src/arch/x86_64/Encoding.zig+1-1
......@@ -158,7 +158,7 @@ pub fn modRmExt(encoding: Encoding) u3 {
158158 };
159159}
160160
161pub fn format(encoding: Encoding, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
161pub fn format(encoding: Encoding, bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void {
162162 _ = fmt;
163163
164164 var opc = encoding.opcode();
src/arch/x86_64/bits.zig+2-2
......@@ -728,7 +728,7 @@ pub const FrameIndex = enum(u32) {
728728 return @intFromEnum(fi) < named_count;
729729 }
730730
731 pub fn format(fi: FrameIndex, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
731 pub fn format(fi: FrameIndex, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
732732 try bw.writeAll("FrameIndex");
733733 if (fi.isNamed())
734734 try bw.print(".{s}", .{@tagName(fi)})
......@@ -835,7 +835,7 @@ pub const Memory = struct {
835835 };
836836 }
837837
838 pub fn format(s: Size, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
838 pub fn format(s: Size, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
839839 if (s == .none) return;
840840 try bw.writeAll(@tagName(s));
841841 switch (s) {
src/arch/x86_64/encoder.zig+35-35
......@@ -226,7 +226,7 @@ pub const Instruction = struct {
226226 };
227227 }
228228
229 fn format(op: Operand, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void {
229 fn format(op: Operand, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) !void {
230230 _ = op;
231231 _ = bw;
232232 _ = unused_format_string;
......@@ -238,7 +238,7 @@ pub const Instruction = struct {
238238 enc_op: Encoding.Op,
239239 };
240240
241 fn fmtContext(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void {
241 fn fmtContext(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void {
242242 _ = unused_format_string;
243243 const op = ctx.op;
244244 const enc_op = ctx.enc_op;
......@@ -360,7 +360,7 @@ pub const Instruction = struct {
360360 return inst;
361361 }
362362
363 pub fn format(inst: Instruction, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void {
363 pub fn format(inst: Instruction, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void {
364364 _ = unused_format_string;
365365 switch (inst.prefix) {
366366 .none, .directive => {},
......@@ -794,7 +794,7 @@ fn Encoder(comptime opts: Options) type {
794794 // --------
795795
796796 /// Encodes legacy prefixes
797 pub fn legacyPrefixes(self: Self, prefixes: LegacyPrefixes) anyerror!void {
797 pub fn legacyPrefixes(self: Self, prefixes: LegacyPrefixes) !void {
798798 if (@as(u16, @bitCast(prefixes)) != 0) {
799799 // Hopefully this path isn't taken very often, so we'll do it the slow way for now
800800
......@@ -830,7 +830,7 @@ fn Encoder(comptime opts: Options) type {
830830 /// Use 16 bit operand size
831831 ///
832832 /// Note that this flag is overridden by REX.W, if both are present.
833 pub fn prefix16BitMode(self: Self) anyerror!void {
833 pub fn prefix16BitMode(self: Self) !void {
834834 try self.bw.writeByte(0x66);
835835 }
836836
......@@ -840,7 +840,7 @@ fn Encoder(comptime opts: Options) type {
840840 /// or one of reg, index, r/m, base, or opcode-reg might be extended.
841841 ///
842842 /// See struct `Rex` for a description of each field.
843 pub fn rex(self: Self, fields: Rex) anyerror!void {
843 pub fn rex(self: Self, fields: Rex) !void {
844844 if (!fields.present and !fields.isSet()) return;
845845
846846 var byte: u8 = 0b0100_0000;
......@@ -856,7 +856,7 @@ fn Encoder(comptime opts: Options) type {
856856 /// Encodes a VEX prefix given all the fields
857857 ///
858858 /// See struct `Vex` for a description of each field.
859 pub fn vex(self: Self, fields: Vex) anyerror!void {
859 pub fn vex(self: Self, fields: Vex) !void {
860860 if (fields.is3Byte()) {
861861 try self.bw.writeByte(0b1100_0100);
862862
......@@ -889,7 +889,7 @@ fn Encoder(comptime opts: Options) type {
889889 // ------
890890
891891 /// Encodes a 1 byte opcode
892 pub fn opcode_1byte(self: Self, opcode: u8) anyerror!void {
892 pub fn opcode_1byte(self: Self, opcode: u8) !void {
893893 try self.bw.writeByte(opcode);
894894 }
895895
......@@ -898,7 +898,7 @@ fn Encoder(comptime opts: Options) type {
898898 /// e.g. IMUL has the opcode 0x0f 0xaf, so you use
899899 ///
900900 /// encoder.opcode_2byte(0x0f, 0xaf);
901 pub fn opcode_2byte(self: Self, prefix: u8, opcode: u8) anyerror!void {
901 pub fn opcode_2byte(self: Self, prefix: u8, opcode: u8) !void {
902902 try self.bw.writeAll(&.{ prefix, opcode });
903903 }
904904
......@@ -907,14 +907,14 @@ fn Encoder(comptime opts: Options) type {
907907 /// e.g. MOVSD has the opcode 0xf2 0x0f 0x10
908908 ///
909909 /// encoder.opcode_3byte(0xf2, 0x0f, 0x10);
910 pub fn opcode_3byte(self: Self, prefix_1: u8, prefix_2: u8, opcode: u8) anyerror!void {
910 pub fn opcode_3byte(self: Self, prefix_1: u8, prefix_2: u8, opcode: u8) !void {
911911 try self.bw.writeAll(&.{ prefix_1, prefix_2, opcode });
912912 }
913913
914914 /// Encodes a 1 byte opcode with a reg field
915915 ///
916916 /// Remember to add a REX prefix byte if reg is extended!
917 pub fn opcode_withReg(self: Self, opcode: u8, reg: u3) anyerror!void {
917 pub fn opcode_withReg(self: Self, opcode: u8, reg: u3) !void {
918918 assert(opcode & 0b111 == 0);
919919 try self.bw.writeByte(opcode | reg);
920920 }
......@@ -926,7 +926,7 @@ fn Encoder(comptime opts: Options) type {
926926 /// Construct a ModR/M byte given all the fields
927927 ///
928928 /// Remember to add a REX prefix byte if reg or rm are extended!
929 pub fn modRm(self: Self, mod: u2, reg_or_opx: u3, rm: u3) anyerror!void {
929 pub fn modRm(self: Self, mod: u2, reg_or_opx: u3, rm: u3) !void {
930930 try self.bw.writeByte(@as(u8, mod) << 6 | @as(u8, reg_or_opx) << 3 | rm);
931931 }
932932
......@@ -935,7 +935,7 @@ fn Encoder(comptime opts: Options) type {
935935 ///
936936 /// Note reg's effective address is always just reg for the ModR/M byte.
937937 /// Remember to add a REX prefix byte if reg or rm are extended!
938 pub fn modRm_direct(self: Self, reg_or_opx: u3, rm: u3) anyerror!void {
938 pub fn modRm_direct(self: Self, reg_or_opx: u3, rm: u3) !void {
939939 try self.modRm(0b11, reg_or_opx, rm);
940940 }
941941
......@@ -944,7 +944,7 @@ fn Encoder(comptime opts: Options) type {
944944 ///
945945 /// Note reg's effective address is always just reg for the ModR/M byte.
946946 /// Remember to add a REX prefix byte if reg or rm are extended!
947 pub fn modRm_indirectDisp0(self: Self, reg_or_opx: u3, rm: u3) anyerror!void {
947 pub fn modRm_indirectDisp0(self: Self, reg_or_opx: u3, rm: u3) !void {
948948 assert(rm != 4 and rm != 5);
949949 try self.modRm(0b00, reg_or_opx, rm);
950950 }
......@@ -954,7 +954,7 @@ fn Encoder(comptime opts: Options) type {
954954 ///
955955 /// Note reg's effective address is always just reg for the ModR/M byte.
956956 /// Remember to add a REX prefix byte if reg or rm are extended!
957 pub fn modRm_SIBDisp0(self: Self, reg_or_opx: u3) anyerror!void {
957 pub fn modRm_SIBDisp0(self: Self, reg_or_opx: u3) !void {
958958 try self.modRm(0b00, reg_or_opx, 0b100);
959959 }
960960
......@@ -963,7 +963,7 @@ fn Encoder(comptime opts: Options) type {
963963 ///
964964 /// Note reg's effective address is always just reg for the ModR/M byte.
965965 /// Remember to add a REX prefix byte if reg or rm are extended!
966 pub fn modRm_RIPDisp32(self: Self, reg_or_opx: u3) anyerror!void {
966 pub fn modRm_RIPDisp32(self: Self, reg_or_opx: u3) !void {
967967 try self.modRm(0b00, reg_or_opx, 0b101);
968968 }
969969
......@@ -972,7 +972,7 @@ fn Encoder(comptime opts: Options) type {
972972 ///
973973 /// Note reg's effective address is always just reg for the ModR/M byte.
974974 /// Remember to add a REX prefix byte if reg or rm are extended!
975 pub fn modRm_indirectDisp8(self: Self, reg_or_opx: u3, rm: u3) anyerror!void {
975 pub fn modRm_indirectDisp8(self: Self, reg_or_opx: u3, rm: u3) !void {
976976 assert(rm != 4);
977977 try self.modRm(0b01, reg_or_opx, rm);
978978 }
......@@ -982,7 +982,7 @@ fn Encoder(comptime opts: Options) type {
982982 ///
983983 /// Note reg's effective address is always just reg for the ModR/M byte.
984984 /// Remember to add a REX prefix byte if reg or rm are extended!
985 pub fn modRm_SIBDisp8(self: Self, reg_or_opx: u3) anyerror!void {
985 pub fn modRm_SIBDisp8(self: Self, reg_or_opx: u3) !void {
986986 try self.modRm(0b01, reg_or_opx, 0b100);
987987 }
988988
......@@ -991,7 +991,7 @@ fn Encoder(comptime opts: Options) type {
991991 ///
992992 /// Note reg's effective address is always just reg for the ModR/M byte.
993993 /// Remember to add a REX prefix byte if reg or rm are extended!
994 pub fn modRm_indirectDisp32(self: Self, reg_or_opx: u3, rm: u3) anyerror!void {
994 pub fn modRm_indirectDisp32(self: Self, reg_or_opx: u3, rm: u3) !void {
995995 assert(rm != 4);
996996 try self.modRm(0b10, reg_or_opx, rm);
997997 }
......@@ -1001,7 +1001,7 @@ fn Encoder(comptime opts: Options) type {
10011001 ///
10021002 /// Note reg's effective address is always just reg for the ModR/M byte.
10031003 /// Remember to add a REX prefix byte if reg or rm are extended!
1004 pub fn modRm_SIBDisp32(self: Self, reg_or_opx: u3) anyerror!void {
1004 pub fn modRm_SIBDisp32(self: Self, reg_or_opx: u3) !void {
10051005 try self.modRm(0b10, reg_or_opx, 0b100);
10061006 }
10071007
......@@ -1012,7 +1012,7 @@ fn Encoder(comptime opts: Options) type {
10121012 /// Construct a SIB byte given all the fields
10131013 ///
10141014 /// Remember to add a REX prefix byte if index or base are extended!
1015 pub fn sib(self: Self, scale: u2, index: u3, base: u3) anyerror!void {
1015 pub fn sib(self: Self, scale: u2, index: u3, base: u3) !void {
10161016 try self.bw.writeByte(@as(u8, scale) << 6 | @as(u8, index) << 3 | base);
10171017 }
10181018
......@@ -1020,7 +1020,7 @@ fn Encoder(comptime opts: Options) type {
10201020 /// r/m effective address: [base + scale * index]
10211021 ///
10221022 /// Remember to add a REX prefix byte if index or base are extended!
1023 pub fn sib_scaleIndexBase(self: Self, scale: u2, index: u3, base: u3) anyerror!void {
1023 pub fn sib_scaleIndexBase(self: Self, scale: u2, index: u3, base: u3) !void {
10241024 assert(base != 5);
10251025
10261026 try self.sib(scale, index, base);
......@@ -1030,7 +1030,7 @@ fn Encoder(comptime opts: Options) type {
10301030 /// r/m effective address: [scale * index + disp32]
10311031 ///
10321032 /// Remember to add a REX prefix byte if index or base are extended!
1033 pub fn sib_scaleIndexDisp32(self: Self, scale: u2, index: u3) anyerror!void {
1033 pub fn sib_scaleIndexDisp32(self: Self, scale: u2, index: u3) !void {
10341034 // scale is actually ignored
10351035 // index = 4 means no index if and only if we haven't extended the register
10361036 // TODO enforce this
......@@ -1042,7 +1042,7 @@ fn Encoder(comptime opts: Options) type {
10421042 /// r/m effective address: [base]
10431043 ///
10441044 /// Remember to add a REX prefix byte if index or base are extended!
1045 pub fn sib_base(self: Self, base: u3) anyerror!void {
1045 pub fn sib_base(self: Self, base: u3) !void {
10461046 assert(base != 5);
10471047
10481048 // scale is actually ignored
......@@ -1054,7 +1054,7 @@ fn Encoder(comptime opts: Options) type {
10541054 /// r/m effective address: [disp32]
10551055 ///
10561056 /// Remember to add a REX prefix byte if index or base are extended!
1057 pub fn sib_disp32(self: Self) anyerror!void {
1057 pub fn sib_disp32(self: Self) !void {
10581058 // scale is actually ignored
10591059 // index = 4 means no index
10601060 // base = 5 means no base, if mod == 0.
......@@ -1065,7 +1065,7 @@ fn Encoder(comptime opts: Options) type {
10651065 /// r/m effective address: [base + scale * index + disp8]
10661066 ///
10671067 /// Remember to add a REX prefix byte if index or base are extended!
1068 pub fn sib_scaleIndexBaseDisp8(self: Self, scale: u2, index: u3, base: u3) anyerror!void {
1068 pub fn sib_scaleIndexBaseDisp8(self: Self, scale: u2, index: u3, base: u3) !void {
10691069 try self.sib(scale, index, base);
10701070 }
10711071
......@@ -1073,7 +1073,7 @@ fn Encoder(comptime opts: Options) type {
10731073 /// r/m effective address: [base + disp8]
10741074 ///
10751075 /// Remember to add a REX prefix byte if index or base are extended!
1076 pub fn sib_baseDisp8(self: Self, base: u3) anyerror!void {
1076 pub fn sib_baseDisp8(self: Self, base: u3) !void {
10771077 // scale is ignored
10781078 // index = 4 means no index
10791079 try self.sib(0, 4, base);
......@@ -1083,7 +1083,7 @@ fn Encoder(comptime opts: Options) type {
10831083 /// r/m effective address: [base + scale * index + disp32]
10841084 ///
10851085 /// Remember to add a REX prefix byte if index or base are extended!
1086 pub fn sib_scaleIndexBaseDisp32(self: Self, scale: u2, index: u3, base: u3) anyerror!void {
1086 pub fn sib_scaleIndexBaseDisp32(self: Self, scale: u2, index: u3, base: u3) !void {
10871087 try self.sib(scale, index, base);
10881088 }
10891089
......@@ -1091,7 +1091,7 @@ fn Encoder(comptime opts: Options) type {
10911091 /// r/m effective address: [base + disp32]
10921092 ///
10931093 /// Remember to add a REX prefix byte if index or base are extended!
1094 pub fn sib_baseDisp32(self: Self, base: u3) anyerror!void {
1094 pub fn sib_baseDisp32(self: Self, base: u3) !void {
10951095 // scale is ignored
10961096 // index = 4 means no index
10971097 try self.sib(0, 4, base);
......@@ -1104,42 +1104,42 @@ fn Encoder(comptime opts: Options) type {
11041104 /// Encode an 8 bit displacement
11051105 ///
11061106 /// It is sign-extended to 64 bits by the cpu.
1107 pub fn disp8(self: Self, disp: i8) anyerror!void {
1107 pub fn disp8(self: Self, disp: i8) !void {
11081108 try self.bw.writeByte(@as(u8, @bitCast(disp)));
11091109 }
11101110
11111111 /// Encode an 32 bit displacement
11121112 ///
11131113 /// It is sign-extended to 64 bits by the cpu.
1114 pub fn disp32(self: Self, disp: i32) anyerror!void {
1114 pub fn disp32(self: Self, disp: i32) !void {
11151115 try self.bw.writeInt(i32, disp, .little);
11161116 }
11171117
11181118 /// Encode an 8 bit immediate
11191119 ///
11201120 /// It is sign-extended to 64 bits by the cpu.
1121 pub fn imm8(self: Self, imm: u8) anyerror!void {
1121 pub fn imm8(self: Self, imm: u8) !void {
11221122 try self.bw.writeByte(imm);
11231123 }
11241124
11251125 /// Encode an 16 bit immediate
11261126 ///
11271127 /// It is sign-extended to 64 bits by the cpu.
1128 pub fn imm16(self: Self, imm: u16) anyerror!void {
1128 pub fn imm16(self: Self, imm: u16) !void {
11291129 try self.bw.writeInt(u16, imm, .little);
11301130 }
11311131
11321132 /// Encode an 32 bit immediate
11331133 ///
11341134 /// It is sign-extended to 64 bits by the cpu.
1135 pub fn imm32(self: Self, imm: u32) anyerror!void {
1135 pub fn imm32(self: Self, imm: u32) !void {
11361136 try self.bw.writeInt(u32, imm, .little);
11371137 }
11381138
11391139 /// Encode an 64 bit immediate
11401140 ///
11411141 /// It is sign-extended to 64 bits by the cpu.
1142 pub fn imm64(self: Self, imm: u64) anyerror!void {
1142 pub fn imm64(self: Self, imm: u64) !void {
11431143 try self.bw.writeInt(u64, imm, .little);
11441144 }
11451145 };
src/codegen.zig+8-5
......@@ -316,7 +316,10 @@ pub fn generateSymbol(
316316 var aw: std.io.AllocatingWriter = undefined;
317317 const bw = aw.fromArrayList(pt.zcu.gpa, code);
318318 defer code.* = aw.toArrayList();
319 return @errorCast(generateSymbolInner(bin_file, pt, src_loc, val, bw, reloc_parent));
319 return generateSymbolInner(bin_file, pt, src_loc, val, bw, reloc_parent) catch |err| switch (err) {
320 error.WriteFailed => return error.OutOfMemory,
321 else => |e| return e,
322 };
320323}
321324pub fn generateSymbolInner(
322325 bin_file: *link.File,
......@@ -325,7 +328,7 @@ pub fn generateSymbolInner(
325328 val: Value,
326329 bw: *std.io.BufferedWriter,
327330 reloc_parent: link.File.RelocInfo.Parent,
328) anyerror!void {
331) GenerateSymbolError!void {
329332 const zcu = pt.zcu;
330333 const ip = &zcu.intern_pool;
331334 const ty = val.typeOf(zcu);
......@@ -710,7 +713,7 @@ fn lowerPtr(
710713 bw: *std.io.BufferedWriter,
711714 reloc_parent: link.File.RelocInfo.Parent,
712715 prev_offset: u64,
713) anyerror!void {
716) GenerateSymbolError!void {
714717 const zcu = pt.zcu;
715718 const ptr = zcu.intern_pool.indexToKey(ptr_val).ptr;
716719 const offset: u64 = prev_offset + ptr.byte_offset;
......@@ -763,7 +766,7 @@ fn lowerUavRef(
763766 bw: *std.io.BufferedWriter,
764767 reloc_parent: link.File.RelocInfo.Parent,
765768 offset: u64,
766) anyerror!void {
769) GenerateSymbolError!void {
767770 const zcu = pt.zcu;
768771 const ip = &zcu.intern_pool;
769772 const comp = lf.comp;
......@@ -817,7 +820,7 @@ fn lowerNavRef(
817820 bw: *std.io.BufferedWriter,
818821 reloc_parent: link.File.RelocInfo.Parent,
819822 offset: u64,
820) anyerror!void {
823) GenerateSymbolError!void {
821824 const zcu = pt.zcu;
822825 const gpa = zcu.gpa;
823826 const ip = &zcu.intern_pool;
src/codegen/c.zig+4-4
......@@ -8137,7 +8137,7 @@ const StringLiteral = struct {
81378137 };
81388138 }
81398139
8140 pub fn start(self: *StringLiteral) anyerror!void {
8140 pub fn start(self: *StringLiteral) std.io.Writer.Error!void {
81418141 const writer = self.writer;
81428142 if (self.len <= max_string_initializer_len) {
81438143 self.bytes_written += try writer.writeByteCount('\"');
......@@ -8146,7 +8146,7 @@ const StringLiteral = struct {
81468146 }
81478147 }
81488148
8149 pub fn end(self: *StringLiteral) anyerror!void {
8149 pub fn end(self: *StringLiteral) std.io.Writer.Error!void {
81508150 const writer = self.writer;
81518151 if (self.len <= max_string_initializer_len) {
81528152 self.bytes_written += try writer.writeByteCount('\"');
......@@ -8155,7 +8155,7 @@ const StringLiteral = struct {
81558155 }
81568156 }
81578157
8158 fn writeStringLiteralChar(writer: *std.io.BufferedWriter, c: u8) anyerror!usize {
8158 fn writeStringLiteralChar(writer: *std.io.BufferedWriter, c: u8) std.io.Writer.Error!usize {
81598159 switch (c) {
81608160 7 => return writer.writeAllCount("\\a"),
81618161 8 => return writer.writeAllCount("\\b"),
......@@ -8172,7 +8172,7 @@ const StringLiteral = struct {
81728172 }
81738173 }
81748174
8175 pub fn writeChar(self: *StringLiteral, c: u8) anyerror!void {
8175 pub fn writeChar(self: *StringLiteral, c: u8) std.io.Writer.Error!void {
81768176 const writer = self.writer;
81778177 if (self.len <= max_string_initializer_len) {
81788178 if (self.cur_len == 0 and self.bytes_written > 1)
src/codegen/spirv/spec.zig+1-1
......@@ -18,7 +18,7 @@ pub const IdResult = enum(Word) {
1818 none,
1919 _,
2020
21 pub fn format(self: IdResult, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void {
21 pub fn format(self: IdResult, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void {
2222 switch (self) {
2323 .none => try bw.writeAll("(none)"),
2424 else => try bw.print("%{}", .{@intFromEnum(self)}),
src/link/Coff.zig+2-2
......@@ -3066,14 +3066,14 @@ const ImportTable = struct {
30663066 ctx: Context,
30673067 };
30683068
3069 fn format(itab: ImportTable, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void {
3069 fn format(itab: ImportTable, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void {
30703070 _ = itab;
30713071 _ = bw;
30723072 _ = unused_format_string;
30733073 @compileError("do not format ImportTable directly; use itab.fmtDebug()");
30743074 }
30753075
3076 fn format2(fmt_ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void {
3076 fn format2(fmt_ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void {
30773077 comptime assert(unused_format_string.len == 0);
30783078 const lib_name = fmt_ctx.ctx.coff.temp_strtab.getAssumeExists(fmt_ctx.ctx.name_off);
30793079 const base_vaddr = getBaseAddress(fmt_ctx.ctx);
src/link/Dwarf.zig+65-64
......@@ -1,4 +1,4 @@
1gpa: std.mem.Allocator,
1gpa: Allocator,
22bin_file: *link.File,
33format: DW.Format,
44endian: std.builtin.Endian,
......@@ -50,7 +50,7 @@ const ModInfo = struct {
5050 dirs: std.AutoArrayHashMapUnmanaged(Unit.Index, void),
5151 files: std.AutoArrayHashMapUnmanaged(Zcu.File.Index, void),
5252
53 fn deinit(mod_info: *ModInfo, gpa: std.mem.Allocator) void {
53 fn deinit(mod_info: *ModInfo, gpa: Allocator) void {
5454 mod_info.dirs.deinit(gpa);
5555 mod_info.files.deinit(gpa);
5656 mod_info.* = undefined;
......@@ -132,7 +132,7 @@ const DebugInfo = struct {
132132 return AbbrevCode.decl_bytes + dwarf.sectionOffsetBytes();
133133 }
134134
135 fn declAbbrevCode(debug_info: *DebugInfo, unit: Unit.Index, entry: Entry.Index) anyerror!AbbrevCode {
135 fn declAbbrevCode(debug_info: *DebugInfo, unit: Unit.Index, entry: Entry.Index) !AbbrevCode {
136136 const dwarf: *Dwarf = @fieldParentPtr("debug_info", debug_info);
137137 const unit_ptr = debug_info.section.getUnit(unit);
138138 const entry_ptr = unit_ptr.getEntry(entry);
......@@ -221,13 +221,13 @@ const StringSection = struct {
221221 .section = Section.init,
222222 };
223223
224 fn deinit(str_sec: *StringSection, gpa: std.mem.Allocator) void {
224 fn deinit(str_sec: *StringSection, gpa: Allocator) void {
225225 str_sec.contents.deinit(gpa);
226226 str_sec.map.deinit(gpa);
227227 str_sec.section.deinit(gpa);
228228 }
229229
230 fn addString(str_sec: *StringSection, dwarf: *Dwarf, str: []const u8) anyerror!Entry.Index {
230 fn addString(str_sec: *StringSection, dwarf: *Dwarf, str: []const u8) !Entry.Index {
231231 const gop = try str_sec.map.getOrPutAdapted(dwarf.gpa, str, Adapter{ .str_sec = str_sec });
232232 const entry: Entry.Index = @enumFromInt(gop.index);
233233 if (!gop.found_existing) {
......@@ -298,7 +298,7 @@ pub const Section = struct {
298298 .len = 0,
299299 };
300300
301 fn deinit(sec: *Section, gpa: std.mem.Allocator) void {
301 fn deinit(sec: *Section, gpa: Allocator) void {
302302 for (sec.units.items) |*unit| unit.deinit(gpa);
303303 sec.units.deinit(gpa);
304304 sec.* = undefined;
......@@ -358,7 +358,7 @@ pub const Section = struct {
358358 if (sec.last == unit.toOptional()) sec.last = unit_ptr.prev;
359359 }
360360
361 fn popUnit(sec: *Section, gpa: std.mem.Allocator) void {
361 fn popUnit(sec: *Section, gpa: Allocator) void {
362362 const unit_index: Unit.Index = @enumFromInt(sec.units.items.len - 1);
363363 sec.unlinkUnit(unit_index);
364364 var unit = sec.units.pop().?;
......@@ -369,7 +369,7 @@ pub const Section = struct {
369369 return &sec.units.items[@intFromEnum(unit)];
370370 }
371371
372 fn resizeEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf, len: u32) anyerror!void {
372 fn resizeEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf, len: u32) UpdateError!void {
373373 const unit_ptr = sec.getUnit(unit);
374374 const entry_ptr = unit_ptr.getEntry(entry);
375375 if (len > 0) {
......@@ -390,13 +390,13 @@ pub const Section = struct {
390390 assert(entry_ptr.len == len);
391391 }
392392
393 fn replaceEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf, contents: []const u8) anyerror!void {
393 fn replaceEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf, contents: []const u8) UpdateError!void {
394394 try sec.resizeEntry(unit, entry, dwarf, @intCast(contents.len));
395395 const unit_ptr = sec.getUnit(unit);
396396 try unit_ptr.getEntry(entry).replace(unit_ptr, sec, dwarf, contents);
397397 }
398398
399 fn freeEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf) anyerror!void {
399 fn freeEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf) UpdateError!void {
400400 const unit_ptr = sec.getUnit(unit);
401401 const entry_ptr = unit_ptr.getEntry(entry);
402402 if (entry_ptr.len > 0) {
......@@ -519,7 +519,7 @@ const Unit = struct {
519519 unit.cross_section_relocs.clearRetainingCapacity();
520520 }
521521
522 fn deinit(unit: *Unit, gpa: std.mem.Allocator) void {
522 fn deinit(unit: *Unit, gpa: Allocator) void {
523523 for (unit.entries.items) |*entry| entry.deinit(gpa);
524524 unit.entries.deinit(gpa);
525525 unit.cross_unit_relocs.deinit(gpa);
......@@ -527,7 +527,7 @@ const Unit = struct {
527527 unit.* = undefined;
528528 }
529529
530 fn addEntry(unit: *Unit, gpa: std.mem.Allocator) std.mem.Allocator.Error!Entry.Index {
530 fn addEntry(unit: *Unit, gpa: Allocator) Allocator.Error!Entry.Index {
531531 if (unit.free.unwrap()) |entry| {
532532 const entry_ptr = unit.getEntry(entry);
533533 unit.free = entry_ptr.next;
......@@ -782,7 +782,7 @@ const Entry = struct {
782782 entry.external_relocs.clearRetainingCapacity();
783783 }
784784
785 fn deinit(entry: *Entry, gpa: std.mem.Allocator) void {
785 fn deinit(entry: *Entry, gpa: Allocator) void {
786786 entry.cross_entry_relocs.deinit(gpa);
787787 entry.cross_unit_relocs.deinit(gpa);
788788 entry.cross_section_relocs.deinit(gpa);
......@@ -807,7 +807,7 @@ const Entry = struct {
807807 }
808808 };
809809
810 fn pad(entry: *Entry, unit: *Unit, sec: *Section, dwarf: *Dwarf) anyerror!void {
810 fn pad(entry: *Entry, unit: *Unit, sec: *Section, dwarf: *Dwarf) UpdateError!void {
811811 assert(entry.len > 0);
812812 const start = entry.off + entry.len;
813813 if (sec == &dwarf.debug_frame.section) {
......@@ -886,7 +886,7 @@ const Entry = struct {
886886 try dwarf.getFile().?.pwriteAll(bw.getWritten(), sec.off(dwarf) + unit.off + unit.header_len + start);
887887 }
888888
889 fn resize(entry_ptr: *Entry, unit: *Unit, sec: *Section, dwarf: *Dwarf, len: u32) anyerror!void {
889 fn resize(entry_ptr: *Entry, unit: *Unit, sec: *Section, dwarf: *Dwarf, len: u32) UpdateError!void {
890890 assert(len > 0);
891891 assert(sec.alignment.check(len));
892892 if (entry_ptr.len == len) return;
......@@ -1138,7 +1138,7 @@ pub const Loc = union(enum) {
11381138 };
11391139 }
11401140
1141 fn writeReg(bw: *std.io.BufferedWriter, reg: u32, op0: u8, opx: u8) anyerror!void {
1141 fn writeReg(bw: *std.io.BufferedWriter, reg: u32, op0: u8, opx: u8) std.io.Writer.Error!void {
11421142 if (std.math.cast(u5, reg)) |small_reg| {
11431143 try bw.writeByte(op0 + small_reg);
11441144 } else {
......@@ -1147,7 +1147,7 @@ pub const Loc = union(enum) {
11471147 }
11481148 }
11491149
1150 fn write(loc: Loc, bw: *std.io.BufferedWriter, adapter: anytype) anyerror!void {
1150 fn write(loc: Loc, bw: *std.io.BufferedWriter, adapter: anytype) UpdateError!void {
11511151 switch (loc) {
11521152 .empty => {},
11531153 .addr_reloc => |sym_index| {
......@@ -1312,7 +1312,7 @@ pub const Cfa = union(enum) {
13121312 const RegOff = struct { reg: u32, off: i64 };
13131313 const RegExpr = struct { reg: u32, expr: Loc };
13141314
1315 fn write(cfa: Cfa, wip_nav: *WipNav) anyerror!void {
1315 fn write(cfa: Cfa, wip_nav: *WipNav) UpdateError!void {
13161316 const bw = &wip_nav.debug_frame.buffered_writer;
13171317 switch (cfa) {
13181318 .nop => try bw.writeByte(DW.CFA.nop),
......@@ -1586,25 +1586,25 @@ pub const WipNav = struct {
15861586 ) catch |err| return @errorCast(err);
15871587 }
15881588
1589 pub fn setColumn(wip_nav: *WipNav, column: u32) std.mem.Allocator.Error!void {
1589 pub fn setColumn(wip_nav: *WipNav, column: u32) Allocator.Error!void {
15901590 const dlbw = &wip_nav.debug_line.buffered_writer;
15911591 dlbw.writeByte(DW.LNS.set_column) catch |err| return @errorCast(err);
15921592 dlbw.writeLeb128(column + 1) catch |err| return @errorCast(err);
15931593 }
15941594
1595 pub fn negateStmt(wip_nav: *WipNav) std.mem.Allocator.Error!void {
1595 pub fn negateStmt(wip_nav: *WipNav) Allocator.Error!void {
15961596 return @errorCast(wip_nav.debug_line.buffered_writer.writeByte(DW.LNS.negate_stmt));
15971597 }
15981598
1599 pub fn setPrologueEnd(wip_nav: *WipNav) std.mem.Allocator.Error!void {
1599 pub fn setPrologueEnd(wip_nav: *WipNav) Allocator.Error!void {
16001600 return @errorCast(wip_nav.debug_line.buffered_writer.writeByte(DW.LNS.set_prologue_end));
16011601 }
16021602
1603 pub fn setEpilogueBegin(wip_nav: *WipNav) std.mem.Allocator.Error!void {
1603 pub fn setEpilogueBegin(wip_nav: *WipNav) Allocator.Error!void {
16041604 return @errorCast(wip_nav.debug_line.buffered_writer.writeByte(DW.LNS.set_epilogue_begin));
16051605 }
16061606
1607 pub fn enterBlock(wip_nav: *WipNav, code_off: u64) anyerror!void {
1607 pub fn enterBlock(wip_nav: *WipNav, code_off: u64) UpdateError!void {
16081608 const dwarf = wip_nav.dwarf;
16091609 const dibw = &wip_nav.debug_info.buffered_writer;
16101610 const block = try wip_nav.blocks.addOne(dwarf.gpa);
......@@ -1618,7 +1618,7 @@ pub const WipNav = struct {
16181618 wip_nav.any_children = false;
16191619 }
16201620
1621 pub fn leaveBlock(wip_nav: *WipNav, code_off: u64) anyerror!void {
1621 pub fn leaveBlock(wip_nav: *WipNav, code_off: u64) UpdateError!void {
16221622 const block_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.block));
16231623 const block = wip_nav.blocks.pop().?;
16241624 const dib = wip_nav.debug_info.getWritten();
......@@ -1640,7 +1640,7 @@ pub const WipNav = struct {
16401640 code_off: u64,
16411641 line: u32,
16421642 column: u32,
1643 ) anyerror!void {
1643 ) UpdateError!void {
16441644 const dwarf = wip_nav.dwarf;
16451645 const zcu = wip_nav.pt.zcu;
16461646 const dibw = &wip_nav.debug_info.buffered_writer;
......@@ -1659,7 +1659,7 @@ pub const WipNav = struct {
16591659 wip_nav.any_children = false;
16601660 }
16611661
1662 pub fn leaveInlineFunc(wip_nav: *WipNav, func: InternPool.Index, code_off: u64) anyerror!void {
1662 pub fn leaveInlineFunc(wip_nav: *WipNav, func: InternPool.Index, code_off: u64) UpdateError!void {
16631663 const inlined_func_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.inlined_func));
16641664 const block = wip_nav.blocks.pop().?;
16651665 const dib = wip_nav.debug_info.getWritten();
......@@ -1676,7 +1676,7 @@ pub const WipNav = struct {
16761676 wip_nav.any_children = true;
16771677 }
16781678
1679 pub fn setInlineFunc(wip_nav: *WipNav, func: InternPool.Index) anyerror!void {
1679 pub fn setInlineFunc(wip_nav: *WipNav, func: InternPool.Index) UpdateError!void {
16801680 const zcu = wip_nav.pt.zcu;
16811681 const dwarf = wip_nav.dwarf;
16821682 if (wip_nav.func == func) return;
......@@ -1725,19 +1725,19 @@ pub const WipNav = struct {
17251725 wip_nav.func = func;
17261726 }
17271727
1728 fn externalReloc(wip_nav: *WipNav, sec: *Section, reloc: ExternalReloc) std.mem.Allocator.Error!void {
1728 fn externalReloc(wip_nav: *WipNav, sec: *Section, reloc: ExternalReloc) Allocator.Error!void {
17291729 try sec.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(wip_nav.dwarf.gpa, reloc);
17301730 }
17311731
1732 pub fn infoExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) std.mem.Allocator.Error!void {
1732 pub fn infoExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) Allocator.Error!void {
17331733 try wip_nav.externalReloc(&wip_nav.dwarf.debug_info.section, reloc);
17341734 }
17351735
1736 fn frameExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) std.mem.Allocator.Error!void {
1736 fn frameExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) Allocator.Error!void {
17371737 try wip_nav.externalReloc(&wip_nav.dwarf.debug_frame.section, reloc);
17381738 }
17391739
1740 fn abbrevCode(wip_nav: *WipNav, abbrev_code: AbbrevCode) anyerror!void {
1740 fn abbrevCode(wip_nav: *WipNav, abbrev_code: AbbrevCode) UpdateError!void {
17411741 try wip_nav.debug_info.buffered_writer.writeLeb128(try wip_nav.dwarf.refAbbrevCode(abbrev_code));
17421742 }
17431743
......@@ -1748,7 +1748,7 @@ pub const WipNav = struct {
17481748 target_unit: Unit.Index,
17491749 target_entry: Entry.Index,
17501750 target_off: u32,
1751 ) anyerror!void {
1751 ) UpdateError!void {
17521752 const dwarf = wip_nav.dwarf;
17531753 const gpa = dwarf.gpa;
17541754 const entry_ptr = @field(dwarf, @tagName(sec)).section.getUnit(wip_nav.unit).getEntry(wip_nav.entry);
......@@ -1779,11 +1779,11 @@ pub const WipNav = struct {
17791779 try bw.splatByteAll(0, dwarf.sectionOffsetBytes());
17801780 }
17811781
1782 fn infoSectionOffset(wip_nav: *WipNav, target_sec: Section.Index, target_unit: Unit.Index, target_entry: Entry.Index, target_off: u32) anyerror!void {
1782 fn infoSectionOffset(wip_nav: *WipNav, target_sec: Section.Index, target_unit: Unit.Index, target_entry: Entry.Index, target_off: u32) UpdateError!void {
17831783 try wip_nav.sectionOffset(.debug_info, target_sec, target_unit, target_entry, target_off);
17841784 }
17851785
1786 fn strp(wip_nav: *WipNav, str: []const u8) anyerror!void {
1786 fn strp(wip_nav: *WipNav, str: []const u8) UpdateError!void {
17871787 try wip_nav.infoSectionOffset(.debug_str, StringSection.unit, try wip_nav.dwarf.debug_str.addString(wip_nav.dwarf, str), 0);
17881788 }
17891789
......@@ -1807,7 +1807,7 @@ pub const WipNav = struct {
18071807 }
18081808 };
18091809
1810 fn infoExprLoc(wip_nav: *WipNav, loc: Loc) anyerror!void {
1810 fn infoExprLoc(wip_nav: *WipNav, loc: Loc) UpdateError!void {
18111811 const bw = &wip_nav.debug_info.buffered_writer;
18121812 const counter: ExprLocCounter = .init(wip_nav.dwarf);
18131813 const start = bw.count;
......@@ -1821,10 +1821,10 @@ pub const WipNav = struct {
18211821 fn endian(ctx: @This()) std.builtin.Endian {
18221822 return ctx.wip_nav.dwarf.endian;
18231823 }
1824 fn addrSym(ctx: @This(), _: *std.io.BufferedWriter, sym_index: u32) anyerror!void {
1824 fn addrSym(ctx: @This(), _: *std.io.BufferedWriter, sym_index: u32) UpdateError!void {
18251825 try ctx.wip_nav.infoAddrSym(sym_index, 0);
18261826 }
1827 fn infoEntry(ctx: @This(), _: *std.io.BufferedWriter, unit: Unit.Index, entry: Entry.Index) anyerror!void {
1827 fn infoEntry(ctx: @This(), _: *std.io.BufferedWriter, unit: Unit.Index, entry: Entry.Index) UpdateError!void {
18281828 try ctx.wip_nav.infoSectionOffset(.debug_info, unit, entry, 0);
18291829 }
18301830 } = .{ .wip_nav = wip_nav };
......@@ -1832,7 +1832,7 @@ pub const WipNav = struct {
18321832 try loc.write(bw, adapter);
18331833 }
18341834
1835 fn infoAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) anyerror!void {
1835 fn infoAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) UpdateError!void {
18361836 const dibw = &wip_nav.debug_info.buffered_writer;
18371837 try wip_nav.infoExternalReloc(.{
18381838 .source_off = @intCast(dibw.count),
......@@ -1856,10 +1856,10 @@ pub const WipNav = struct {
18561856 fn endian(ctx: @This()) std.builtin.Endian {
18571857 return ctx.wip_nav.dwarf.endian;
18581858 }
1859 fn addrSym(ctx: @This(), _: *std.io.BufferedWriter, sym_index: u32) anyerror!void {
1859 fn addrSym(ctx: @This(), _: *std.io.BufferedWriter, sym_index: u32) UpdateError!void {
18601860 try ctx.wip_nav.frameAddrSym(sym_index, 0);
18611861 }
1862 fn infoEntry(ctx: @This(), _: *std.io.BufferedWriter, unit: Unit.Index, entry: Entry.Index) anyerror!void {
1862 fn infoEntry(ctx: @This(), _: *std.io.BufferedWriter, unit: Unit.Index, entry: Entry.Index) UpdateError!void {
18631863 try ctx.wip_nav.sectionOffset(.debug_frame, .debug_info, unit, entry, 0);
18641864 }
18651865 } = .{ .wip_nav = wip_nav };
......@@ -1867,7 +1867,7 @@ pub const WipNav = struct {
18671867 try loc.write(bw, adapter);
18681868 }
18691869
1870 fn frameAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) anyerror!void {
1870 fn frameAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) UpdateError!void {
18711871 const dfbw = &wip_nav.debug_frame.buffered_writer;
18721872 try wip_nav.frameExternalReloc(.{
18731873 .source_off = @intCast(dfbw.count),
......@@ -1877,7 +1877,7 @@ pub const WipNav = struct {
18771877 try dfbw.splatByteAll(0, @intFromEnum(wip_nav.dwarf.address_size));
18781878 }
18791879
1880 fn getNavEntry(wip_nav: *WipNav, nav_index: InternPool.Nav.Index) anyerror!struct { Unit.Index, Entry.Index } {
1880 fn getNavEntry(wip_nav: *WipNav, nav_index: InternPool.Nav.Index) UpdateError!struct { Unit.Index, Entry.Index } {
18811881 const zcu = wip_nav.pt.zcu;
18821882 const ip = &zcu.intern_pool;
18831883 const nav = ip.getNav(nav_index);
......@@ -1889,12 +1889,12 @@ pub const WipNav = struct {
18891889 return .{ unit, entry };
18901890 }
18911891
1892 fn refNav(wip_nav: *WipNav, nav_index: InternPool.Nav.Index) anyerror!void {
1892 fn refNav(wip_nav: *WipNav, nav_index: InternPool.Nav.Index) UpdateError!void {
18931893 const unit, const entry = try wip_nav.getNavEntry(nav_index);
18941894 try wip_nav.infoSectionOffset(.debug_info, unit, entry, 0);
18951895 }
18961896
1897 fn getTypeEntry(wip_nav: *WipNav, ty: Type) anyerror!struct { Unit.Index, Entry.Index } {
1897 fn getTypeEntry(wip_nav: *WipNav, ty: Type) UpdateError!struct { Unit.Index, Entry.Index } {
18981898 const zcu = wip_nav.pt.zcu;
18991899 const ip = &zcu.intern_pool;
19001900 const maybe_inst_index = ty.typeDeclInst(zcu);
......@@ -1916,12 +1916,12 @@ pub const WipNav = struct {
19161916 return .{ unit, entry };
19171917 }
19181918
1919 fn refType(wip_nav: *WipNav, ty: Type) anyerror!void {
1919 fn refType(wip_nav: *WipNav, ty: Type) UpdateError!void {
19201920 const unit, const entry = try wip_nav.getTypeEntry(ty);
19211921 try wip_nav.infoSectionOffset(.debug_info, unit, entry, 0);
19221922 }
19231923
1924 fn getValueEntry(wip_nav: *WipNav, value: Value) anyerror!struct { Unit.Index, Entry.Index } {
1924 fn getValueEntry(wip_nav: *WipNav, value: Value) UpdateError!struct { Unit.Index, Entry.Index } {
19251925 const zcu = wip_nav.pt.zcu;
19261926 const ip = &zcu.intern_pool;
19271927 const ty = value.typeOf(zcu);
......@@ -1937,12 +1937,12 @@ pub const WipNav = struct {
19371937 return .{ unit, entry };
19381938 }
19391939
1940 fn refValue(wip_nav: *WipNav, value: Value) anyerror!void {
1940 fn refValue(wip_nav: *WipNav, value: Value) UpdateError!void {
19411941 const unit, const entry = try wip_nav.getValueEntry(value);
19421942 try wip_nav.infoSectionOffset(.debug_info, unit, entry, 0);
19431943 }
19441944
1945 fn refForward(wip_nav: *WipNav) anyerror!u32 {
1945 fn refForward(wip_nav: *WipNav) Allocator.Error!u32 {
19461946 const dwarf = wip_nav.dwarf;
19471947 const dibw = &wip_nav.debug_info.buffered_writer;
19481948 const cross_entry_relocs = &dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).cross_entry_relocs;
......@@ -1962,7 +1962,7 @@ pub const WipNav = struct {
19621962 reloc.target_off = @intCast(wip_nav.debug_info.buffered_writer.count);
19631963 }
19641964
1965 fn blockValue(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc, val: Value) anyerror!void {
1965 fn blockValue(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc, val: Value) UpdateError!void {
19661966 const ty = val.typeOf(wip_nav.pt.zcu);
19671967 const dibw = &wip_nav.debug_info.buffered_writer;
19681968 const bytes = if (ty.hasRuntimeBits(wip_nav.pt.zcu)) ty.abiSize(wip_nav.pt.zcu) else 0;
......@@ -1996,7 +1996,7 @@ pub const WipNav = struct {
19961996 abbrev_code: AbbrevCodeForForm,
19971997 ty: Type,
19981998 big_int: std.math.big.int.Const,
1999 ) anyerror!void {
1999 ) UpdateError!void {
20002000 const zcu = wip_nav.pt.zcu;
20012001 const dibw = &wip_nav.debug_info.buffered_writer;
20022002 const signedness = switch (ty.toIntern()) {
......@@ -2045,7 +2045,7 @@ pub const WipNav = struct {
20452045 loaded_enum: InternPool.LoadedEnumType,
20462046 abbrev_code: AbbrevCodeForForm,
20472047 field_index: usize,
2048 ) anyerror!void {
2048 ) UpdateError!void {
20492049 const zcu = wip_nav.pt.zcu;
20502050 const ip = &zcu.intern_pool;
20512051 var big_int_space: Value.BigIntSpace = undefined;
......@@ -2065,7 +2065,7 @@ pub const WipNav = struct {
20652065 nav: *const InternPool.Nav,
20662066 file: Zcu.File.Index,
20672067 decl: *const std.zig.Zir.Inst.Declaration.Unwrapped,
2068 ) anyerror!void {
2068 ) UpdateError!void {
20692069 const zcu = wip_nav.pt.zcu;
20702070 const ip = &zcu.intern_pool;
20712071 const dwarf = wip_nav.dwarf;
......@@ -2143,7 +2143,7 @@ pub const WipNav = struct {
21432143 const empty: PendingLazy = .{ .types = .empty, .values = .empty };
21442144 };
21452145
2146 fn updateLazy(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) anyerror!void {
2146 fn updateLazy(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) UpdateError!void {
21472147 while (true) if (wip_nav.pending_lazy.types.pop()) |pending_ty|
21482148 try wip_nav.dwarf.updateLazyType(wip_nav.pt, src_loc, pending_ty, &wip_nav.pending_lazy)
21492149 else if (wip_nav.pending_lazy.values.pop()) |pending_val|
......@@ -2366,7 +2366,7 @@ pub fn deinit(dwarf: *Dwarf) void {
23662366 dwarf.* = undefined;
23672367}
23682368
2369fn getUnit(dwarf: *Dwarf, mod: *Module) anyerror!Unit.Index {
2369fn getUnit(dwarf: *Dwarf, mod: *Module) !Unit.Index {
23702370 const mod_gop = try dwarf.mods.getOrPut(dwarf.gpa, mod);
23712371 const unit: Unit.Index = @enumFromInt(mod_gop.index);
23722372 if (!mod_gop.found_existing) {
......@@ -2494,7 +2494,7 @@ fn initWipNavInner(
24942494 pt: Zcu.PerThread,
24952495 nav_index: InternPool.Nav.Index,
24962496 sym_index: u32,
2497) anyerror!?WipNav {
2497) !?WipNav {
24982498 const zcu = pt.zcu;
24992499 const ip = &zcu.intern_pool;
25002500
......@@ -2702,7 +2702,7 @@ fn finishWipNavFuncInner(
27022702 nav_index: InternPool.Nav.Index,
27032703 code_size: u64,
27042704 wip_nav: *WipNav,
2705) anyerror!void {
2705) UpdateError!void {
27062706 const zcu = pt.zcu;
27072707 const ip = &zcu.intern_pool;
27082708 const nav = ip.getNav(nav_index);
......@@ -2802,7 +2802,7 @@ fn finishWipNavInner(
28022802 pt: Zcu.PerThread,
28032803 nav_index: InternPool.Nav.Index,
28042804 wip_nav: *WipNav,
2805) anyerror!void {
2805) UpdateError!void {
28062806 const zcu = pt.zcu;
28072807 const ip = &zcu.intern_pool;
28082808 const nav = ip.getNav(nav_index);
......@@ -2822,7 +2822,7 @@ fn finishWipNavInner(
28222822 try wip_nav.updateLazy(zcu.navSrcLoc(nav_index));
28232823}
28242824
2825fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) anyerror!void {
2825fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) !void {
28262826 const zcu = pt.zcu;
28272827 const ip = &zcu.intern_pool;
28282828 const nav_src_loc = zcu.navSrcLoc(nav_index);
......@@ -3276,7 +3276,7 @@ fn updateLazyType(
32763276 src_loc: Zcu.LazySrcLoc,
32773277 type_index: InternPool.Index,
32783278 pending_lazy: *WipNav.PendingLazy,
3279) anyerror!void {
3279) UpdateError!void {
32803280 const zcu = pt.zcu;
32813281 const ip = &zcu.intern_pool;
32823282 assert(ip.typeOf(type_index) == .type_type);
......@@ -3783,7 +3783,7 @@ fn updateLazyValue(
37833783 src_loc: Zcu.LazySrcLoc,
37843784 value_index: InternPool.Index,
37853785 pending_lazy: *WipNav.PendingLazy,
3786) anyerror!void {
3786) UpdateError!void {
37873787 const zcu = pt.zcu;
37883788 const ip = &zcu.intern_pool;
37893789 assert(ip.typeOf(value_index) != .type_type);
......@@ -4175,7 +4175,7 @@ fn optRepr(opt_child_type: Type, zcu: *const Zcu) enum {
41754175 };
41764176}
41774177
4178fn updateContainerTypeInner(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternPool.Index) anyerror!void {
4178fn updateContainerTypeInner(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternPool.Index) UpdateError!void {
41794179 const zcu = pt.zcu;
41804180 const ip = &zcu.intern_pool;
41814181 const ty: Type = .fromInterned(type_index);
......@@ -4498,7 +4498,7 @@ pub fn freeNav(dwarf: *Dwarf, nav_index: InternPool.Nav.Index) void {
44984498 _ = nav_index;
44994499}
45004500
4501fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) anyerror!@typeInfo(AbbrevCode).@"enum".tag_type {
4501fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(AbbrevCode).@"enum".tag_type {
45024502 assert(abbrev_code != .null);
45034503 const entry: Entry.Index = @enumFromInt(@intFromEnum(abbrev_code));
45044504 if (dwarf.debug_abbrev.section.getUnit(DebugAbbrev.unit).getEntry(entry).len > 0) return @intFromEnum(abbrev_code);
......@@ -6063,7 +6063,7 @@ fn addCommonEntry(dwarf: *Dwarf, unit: Unit.Index) UpdateError!Entry.Index {
60636063 return entry;
60646064}
60656065
6066fn freeCommonEntry(dwarf: *Dwarf, unit: Unit.Index, entry: Entry.Index) anyerror!void {
6066fn freeCommonEntry(dwarf: *Dwarf, unit: Unit.Index, entry: Entry.Index) UpdateError!void {
60676067 try dwarf.debug_aranges.section.freeEntry(unit, entry, dwarf);
60686068 try dwarf.debug_frame.section.freeEntry(unit, entry, dwarf);
60696069 try dwarf.debug_info.section.freeEntry(unit, entry, dwarf);
......@@ -6082,7 +6082,7 @@ fn writeInt(dwarf: *Dwarf, buf: []u8, int: u64) void {
60826082 }
60836083}
60846084
6085fn writeIntTo(dwarf: *Dwarf, bw: *std.io.BufferedWriter, len: usize, int: u64) anyerror!void {
6085fn writeIntTo(dwarf: *Dwarf, bw: *std.io.BufferedWriter, len: usize, int: u64) !void {
60866086 dwarf.writeInt((try bw.writableSlice(len))[0..len], int);
60876087 bw.advance(len);
60886088}
......@@ -6159,3 +6159,4 @@ const link = @import("../link.zig");
61596159const log = std.log.scoped(.dwarf);
61606160const std = @import("std");
61616161const target_info = @import("../target.zig");
6162const Allocator = std.mem.Allocator;
src/link/Elf.zig+4-4
......@@ -2996,7 +2996,7 @@ fn allocateSpecialPhdrs(self: *Elf) void {
29962996 }
29972997}
29982998
2999fn writeAtoms(self: *Elf) anyerror!void {
2999fn writeAtoms(self: *Elf) !void {
30003000 const gpa = self.base.comp.gpa;
30013001
30023002 var undefs: std.AutoArrayHashMap(SymbolResolver.Index, std.ArrayList(Ref)) = .init(gpa);
......@@ -3130,7 +3130,7 @@ pub fn updateSymtabSize(self: *Elf) !void {
31303130 strtab.sh_size = strsize + 1;
31313131}
31323132
3133fn writeSyntheticSections(self: *Elf) anyerror!void {
3133fn writeSyntheticSections(self: *Elf) !void {
31343134 const gpa = self.base.comp.gpa;
31353135 const slice = self.sections.slice();
31363136
......@@ -3883,7 +3883,7 @@ fn fmtShdr(self: *Elf, shdr: elf.Elf64_Shdr) std.fmt.Formatter(formatShdr) {
38833883 } };
38843884}
38853885
3886fn formatShdr(ctx: FormatShdrCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
3886fn formatShdr(ctx: FormatShdrCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
38873887 _ = unused_fmt_string;
38883888 const shdr = ctx.shdr;
38893889 try bw.print("{s} : @{x} ({x}) : align({x}) : size({x}) : entsize({x}) : flags({f})", .{
......@@ -4216,7 +4216,7 @@ pub const Ref = struct {
42164216 return ref.index == other.index and ref.file == other.file;
42174217 }
42184218
4219 pub fn format(ref: Ref, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
4219 pub fn format(ref: Ref, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
42204220 _ = unused_fmt_string;
42214221 try bw.print("ref({},{})", .{ ref.index, ref.file });
42224222 }
src/link/Elf/Archive.zig+3-3
......@@ -184,7 +184,7 @@ pub const ArSymtab = struct {
184184 }
185185 }
186186
187 pub fn format(ar: ArSymtab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
187 pub fn format(ar: ArSymtab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
188188 _ = ar;
189189 _ = bw;
190190 _ = unused_fmt_string;
......@@ -203,7 +203,7 @@ pub const ArSymtab = struct {
203203 } };
204204 }
205205
206 fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
206 fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
207207 _ = unused_fmt_string;
208208 const ar = ctx.ar;
209209 const elf_file = ctx.elf_file;
......@@ -251,7 +251,7 @@ pub const ArStrtab = struct {
251251 try writer.writeAll(ar.buffer.items);
252252 }
253253
254 pub fn format(ar: ArStrtab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
254 pub fn format(ar: ArStrtab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
255255 _ = unused_fmt_string;
256256 try bw.print("{f}", .{std.fmt.fmtSliceEscapeLower(ar.buffer.items)});
257257 }
src/link/Elf/Atom.zig+6-6
......@@ -908,7 +908,7 @@ pub fn setExtra(atom: Atom, extras: Extra, elf_file: *Elf) void {
908908 atom.file(elf_file).?.setAtomExtra(atom.extra_index, extras);
909909}
910910
911pub fn format(atom: Atom, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
911pub fn format(atom: Atom, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
912912 _ = atom;
913913 _ = bw;
914914 _ = unused_fmt_string;
......@@ -927,7 +927,7 @@ const FormatContext = struct {
927927 elf_file: *Elf,
928928};
929929
930fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
930fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
931931 _ = unused_fmt_string;
932932 const atom = ctx.atom;
933933 const elf_file = ctx.elf_file;
......@@ -1080,7 +1080,7 @@ const x86_64 = struct {
10801080 args: ResolveArgs,
10811081 it: *RelocsIterator,
10821082 bw: *std.io.BufferedWriter,
1083 ) anyerror!void {
1083 ) std.io.Writer.Error!void {
10841084 dev.check(.x86_64_backend);
10851085 const t = &elf_file.base.comp.root_mod.resolved_target.result;
10861086 const diags = &elf_file.base.comp.link_diags;
......@@ -1212,7 +1212,7 @@ const x86_64 = struct {
12121212 target: *const Symbol,
12131213 args: ResolveArgs,
12141214 bw: *std.io.BufferedWriter,
1215 ) anyerror!void {
1215 ) std.io.Writer.Error!void {
12161216 dev.check(.x86_64_backend);
12171217
12181218 const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type());
......@@ -1593,7 +1593,7 @@ const aarch64 = struct {
15931593 args: ResolveArgs,
15941594 it: *RelocsIterator,
15951595 bw: *std.io.BufferedWriter,
1596 ) anyerror!void {
1596 ) std.io.Writer.Error!void {
15971597 _ = it;
15981598
15991599 const diags = &elf_file.base.comp.link_diags;
......@@ -2004,7 +2004,7 @@ const riscv = struct {
20042004 target: *const Symbol,
20052005 args: ResolveArgs,
20062006 bw: *std.io.BufferedWriter,
2007 ) anyerror!void {
2007 ) std.io.Writer.Error!void {
20082008 const r_type: elf.R_RISCV = @enumFromInt(rel.r_type());
20092009
20102010 _, const A, const S, const GOT, _, _, const DTP = args;
src/link/Elf/AtomList.zig+2-2
......@@ -167,7 +167,7 @@ pub fn lastAtom(list: AtomList, elf_file: *Elf) *Atom {
167167 return elf_file.atom(list.atoms.keys()[list.atoms.keys().len - 1]).?;
168168}
169169
170pub fn format(list: AtomList, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
170pub fn format(list: AtomList, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
171171 _ = list;
172172 _ = bw;
173173 _ = unused_fmt_string;
......@@ -180,7 +180,7 @@ pub fn fmt(list: AtomList, elf_file: *Elf) std.fmt.Formatter(format2) {
180180 return .{ .data = .{ list, elf_file } };
181181}
182182
183fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
183fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
184184 _ = unused_fmt_string;
185185 const list, const elf_file = ctx;
186186 try bw.print("list : @{x} : shdr({d}) : align({x}) : size({x})", .{
src/link/Elf/LinkerDefined.zig+1-1
......@@ -449,7 +449,7 @@ const FormatContext = struct {
449449 elf_file: *Elf,
450450};
451451
452fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
452fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
453453 _ = unused_fmt_string;
454454 const self = ctx.self;
455455 const elf_file = ctx.elf_file;
src/link/Elf/Merge.zig+4-4
......@@ -157,7 +157,7 @@ pub const Section = struct {
157157 }
158158 };
159159
160 pub fn format(msec: Section, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
160 pub fn format(msec: Section, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
161161 _ = msec;
162162 _ = bw;
163163 _ = unused_fmt_string;
......@@ -176,7 +176,7 @@ pub const Section = struct {
176176 elf_file: *Elf,
177177 };
178178
179 pub fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
179 pub fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
180180 _ = unused_fmt_string;
181181 const msec = ctx.msec;
182182 const elf_file = ctx.elf_file;
......@@ -219,7 +219,7 @@ pub const Subsection = struct {
219219 return msec.bytes.items[msub.string_index..][0..msub.size];
220220 }
221221
222 pub fn format(msub: Subsection, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
222 pub fn format(msub: Subsection, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
223223 _ = msub;
224224 _ = bw;
225225 _ = unused_fmt_string;
......@@ -238,7 +238,7 @@ pub const Subsection = struct {
238238 elf_file: *Elf,
239239 };
240240
241 pub fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
241 pub fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
242242 _ = unused_fmt_string;
243243 const msub = ctx.msub;
244244 const elf_file = ctx.elf_file;
src/link/Elf/Object.zig+8-8
......@@ -1431,7 +1431,7 @@ pub fn group(self: *Object, index: Elf.Group.Index) *Elf.Group {
14311431 return &self.groups.items[index];
14321432}
14331433
1434pub fn format(self: *Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
1434pub fn format(self: *Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
14351435 _ = self;
14361436 _ = bw;
14371437 _ = unused_fmt_string;
......@@ -1450,7 +1450,7 @@ const FormatContext = struct {
14501450 elf_file: *Elf,
14511451};
14521452
1453fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
1453fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
14541454 _ = unused_fmt_string;
14551455 const object = ctx.object;
14561456 const elf_file = ctx.elf_file;
......@@ -1477,7 +1477,7 @@ pub fn fmtAtoms(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatAtoms) {
14771477 } };
14781478}
14791479
1480fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
1480fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
14811481 _ = unused_fmt_string;
14821482 const object = ctx.object;
14831483 try bw.writeAll(" atoms\n");
......@@ -1494,7 +1494,7 @@ pub fn fmtCies(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatCies) {
14941494 } };
14951495}
14961496
1497fn formatCies(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
1497fn formatCies(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
14981498 _ = unused_fmt_string;
14991499 const object = ctx.object;
15001500 try bw.writeAll(" cies\n");
......@@ -1510,7 +1510,7 @@ pub fn fmtFdes(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatFdes) {
15101510 } };
15111511}
15121512
1513fn formatFdes(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
1513fn formatFdes(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
15141514 _ = unused_fmt_string;
15151515 const object = ctx.object;
15161516 try bw.writeAll(" fdes\n");
......@@ -1526,8 +1526,8 @@ pub fn fmtGroups(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatGroups)
15261526 } };
15271527}
15281528
1529fn formatGroups(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
1530 _ = unused_fmt_string;
1529fn formatGroups(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
1530 comptime assert(unused_fmt_string.len == 0);
15311531 const object = ctx.object;
15321532 const elf_file = ctx.elf_file;
15331533 try bw.writeAll(" groups\n");
......@@ -1548,7 +1548,7 @@ pub fn fmtPath(self: Object) std.fmt.Formatter(formatPath) {
15481548 return .{ .data = self };
15491549}
15501550
1551fn formatPath(object: Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
1551fn formatPath(object: Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
15521552 _ = unused_fmt_string;
15531553 if (object.archive) |ar| {
15541554 try bw.print("{f}({f})", .{ ar.path, object.path });
src/link/Elf/SharedObject.zig+2-2
......@@ -509,7 +509,7 @@ pub fn setSymbolExtra(self: *SharedObject, index: u32, extra: Symbol.Extra) void
509509 }
510510}
511511
512pub fn format(self: SharedObject, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
512pub fn format(self: SharedObject, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
513513 _ = self;
514514 _ = bw;
515515 _ = unused_fmt_string;
......@@ -528,7 +528,7 @@ const FormatContext = struct {
528528 elf_file: *Elf,
529529};
530530
531fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
531fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
532532 _ = unused_fmt_string;
533533 const shared = ctx.shared;
534534 const elf_file = ctx.elf_file;
src/link/Elf/Symbol.zig+3-3
......@@ -316,7 +316,7 @@ pub fn setOutputSym(symbol: Symbol, elf_file: *Elf, out: *elf.Elf64_Sym) void {
316316 out.st_size = esym.st_size;
317317}
318318
319pub fn format(symbol: Symbol, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
319pub fn format(symbol: Symbol, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
320320 _ = symbol;
321321 _ = bw;
322322 _ = unused_fmt_string;
......@@ -335,7 +335,7 @@ pub fn fmtName(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(formatName) {
335335 } };
336336}
337337
338fn formatName(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
338fn formatName(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
339339 _ = unused_fmt_string;
340340 const elf_file = ctx.elf_file;
341341 const symbol = ctx.symbol;
......@@ -358,7 +358,7 @@ pub fn fmt(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(format2) {
358358 } };
359359}
360360
361fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
361fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
362362 _ = unused_fmt_string;
363363 const symbol = ctx.symbol;
364364 const elf_file = ctx.elf_file;
src/link/Elf/Thunk.zig+2-2
......@@ -65,7 +65,7 @@ fn trampolineSize(cpu_arch: std.Target.Cpu.Arch) usize {
6565 };
6666}
6767
68pub fn format(thunk: Thunk, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
68pub fn format(thunk: Thunk, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
6969 _ = thunk;
7070 _ = bw;
7171 _ = unused_fmt_string;
......@@ -84,7 +84,7 @@ const FormatContext = struct {
8484 elf_file: *Elf,
8585};
8686
87fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
87fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
8888 _ = unused_fmt_string;
8989 const thunk = ctx.thunk;
9090 const elf_file = ctx.elf_file;
src/link/Elf/ZigObject.zig+2-2
......@@ -2198,7 +2198,7 @@ const FormatContext = struct {
21982198 elf_file: *Elf,
21992199};
22002200
2201fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2201fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
22022202 _ = unused_fmt_string;
22032203 const self = ctx.self;
22042204 const elf_file = ctx.elf_file;
......@@ -2221,7 +2221,7 @@ pub fn fmtAtoms(self: *ZigObject, elf_file: *Elf) std.fmt.Formatter(formatAtoms)
22212221 } };
22222222}
22232223
2224fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2224fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
22252225 _ = unused_fmt_string;
22262226 try bw.writeAll(" atoms\n");
22272227 for (ctx.self.atoms_indexes.items) |atom_index| {
src/link/Elf/file.zig+1-1
......@@ -14,7 +14,7 @@ pub const File = union(enum) {
1414 return .{ .data = file };
1515 }
1616
17 fn formatPath(file: File, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
17 fn formatPath(file: File, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
1818 _ = unused_fmt_string;
1919 switch (file) {
2020 .zig_object => |zo| try bw.writeAll(zo.basename),
src/link/Elf/gc.zig+1-1
......@@ -185,7 +185,7 @@ const Level = struct {
185185 self.value += 1;
186186 }
187187
188 pub fn format(self: *const @This(), bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
188 pub fn format(self: *const @This(), bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
189189 _ = unused_fmt_string;
190190 try bw.splatByteAll(' ', self.value);
191191 }
src/link/Elf/relocation.zig+1-1
......@@ -148,7 +148,7 @@ pub fn fmtRelocType(r_type: u32, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatte
148148 } };
149149}
150150
151fn formatRelocType(ctx: FormatRelocTypeCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
151fn formatRelocType(ctx: FormatRelocTypeCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
152152 _ = unused_fmt_string;
153153 const r_type = ctx.r_type;
154154 switch (ctx.cpu_arch) {
src/link/Elf/synthetic_sections.zig+16-16
......@@ -94,7 +94,7 @@ pub const DynamicSection = struct {
9494 return nentries * @sizeOf(elf.Elf64_Dyn);
9595 }
9696
97 pub fn write(dt: DynamicSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
97 pub fn write(dt: DynamicSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
9898 const shdrs = elf_file.sections.items(.shdr);
9999
100100 // NEEDED
......@@ -360,7 +360,7 @@ pub const GotSection = struct {
360360 return s;
361361 }
362362
363 pub fn write(got: GotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
363 pub fn write(got: GotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
364364 const comp = elf_file.base.comp;
365365 const is_dyn_lib = elf_file.isEffectivelyDynLib();
366366 const apply_relocs = true; // TODO add user option for this
......@@ -615,7 +615,7 @@ pub const GotSection = struct {
615615 return .{ .data = .{ .got = got, .elf_file = elf_file } };
616616 }
617617
618 pub fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
618 pub fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
619619 _ = unused_fmt_string;
620620 const got = ctx.got;
621621 const elf_file = ctx.elf_file;
......@@ -672,7 +672,7 @@ pub const PltSection = struct {
672672 };
673673 }
674674
675 pub fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
675 pub fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
676676 const cpu_arch = elf_file.getTarget().cpu.arch;
677677 switch (cpu_arch) {
678678 .x86_64 => try x86_64.write(plt, elf_file, bw),
......@@ -752,7 +752,7 @@ pub const PltSection = struct {
752752 return .{ .data = .{ .plt = plt, .elf_file = elf_file } };
753753 }
754754
755 pub fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
755 pub fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
756756 _ = unused_fmt_string;
757757 const plt = ctx.plt;
758758 const elf_file = ctx.elf_file;
......@@ -770,7 +770,7 @@ pub const PltSection = struct {
770770 }
771771
772772 const x86_64 = struct {
773 fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
773 fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
774774 const shdrs = elf_file.sections.items(.shdr);
775775 const plt_addr = shdrs[elf_file.section_indexes.plt.?].sh_addr;
776776 const got_plt_addr = shdrs[elf_file.section_indexes.got_plt.?].sh_addr;
......@@ -805,7 +805,7 @@ pub const PltSection = struct {
805805 };
806806
807807 const aarch64 = struct {
808 fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
808 fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
809809 {
810810 const shdrs = elf_file.sections.items(.shdr);
811811 const plt_addr: i64 = @intCast(shdrs[elf_file.section_indexes.plt.?].sh_addr);
......@@ -871,7 +871,7 @@ pub const GotPltSection = struct {
871871 return preamble_size + elf_file.plt.symbols.items.len * 8;
872872 }
873873
874 pub fn write(got_plt: GotPltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
874 pub fn write(got_plt: GotPltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
875875 _ = got_plt;
876876 {
877877 // [0]: _DYNAMIC
......@@ -922,7 +922,7 @@ pub const PltGotSection = struct {
922922 };
923923 }
924924
925 pub fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
925 pub fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
926926 const cpu_arch = elf_file.getTarget().cpu.arch;
927927 switch (cpu_arch) {
928928 .x86_64 => try x86_64.write(plt_got, elf_file, bw),
......@@ -958,7 +958,7 @@ pub const PltGotSection = struct {
958958 }
959959
960960 const x86_64 = struct {
961 pub fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
961 pub fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
962962 for (plt_got.symbols.items) |ref| {
963963 const sym = elf_file.symbol(ref).?;
964964 const target_addr = sym.gotAddress(elf_file);
......@@ -976,7 +976,7 @@ pub const PltGotSection = struct {
976976 };
977977
978978 const aarch64 = struct {
979 fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
979 fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
980980 for (plt_got.symbols.items) |ref| {
981981 const sym = elf_file.symbol(ref).?;
982982 const target_addr = sym.gotAddress(elf_file);
......@@ -1155,7 +1155,7 @@ pub const DynsymSection = struct {
11551155 return @as(u32, @intCast(dynsym.entries.items.len + 1));
11561156 }
11571157
1158 pub fn write(dynsym: DynsymSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
1158 pub fn write(dynsym: DynsymSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
11591159 try bw.writeStruct(Elf.null_sym);
11601160 for (dynsym.entries.items) |entry| {
11611161 const sym = elf_file.symbol(entry.ref).?;
......@@ -1458,7 +1458,7 @@ pub const VerneedSection = struct {
14581458 return vern.verneed.items.len * @sizeOf(elf.Elf64_Verneed) + vern.vernaux.items.len * @sizeOf(elf.Vernaux);
14591459 }
14601460
1461 pub fn write(vern: VerneedSection, bw: *std.io.BufferedWriter) anyerror!void {
1461 pub fn write(vern: VerneedSection, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
14621462 try bw.writeAll(mem.sliceAsBytes(vern.verneed.items));
14631463 try bw.writeAll(mem.sliceAsBytes(vern.vernaux.items));
14641464 }
......@@ -1486,8 +1486,8 @@ pub const GroupSection = struct {
14861486 return (members.len + 1) * @sizeOf(u32);
14871487 }
14881488
1489 pub fn write(cgs: GroupSection, elf_file: *Elf, bw: *std.io.BufferedWriter) !void {
1490 const cg = cgs.group(elf_file);
1489 pub fn write(cgs: GroupSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
1490 const cg = cgs.comdatGroup(elf_file);
14911491 const object = cg.file(elf_file).object;
14921492 const members = cg.members(elf_file);
14931493 try bw.writeInt(u32, if (cg.is_comdat) elf.GRP_COMDAT else 0, .little);
......@@ -1514,7 +1514,7 @@ pub const GroupSection = struct {
15141514 }
15151515};
15161516
1517fn writeInt(value: anytype, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void {
1517fn writeInt(value: anytype, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
15181518 const entry_size = elf_file.archPtrWidthBytes();
15191519 const target = elf_file.getTarget();
15201520 const endian = target.cpu.arch.endian();
src/link/MachO.zig+7-7
......@@ -2822,7 +2822,7 @@ fn calcSymtabSize(self: *MachO) !void {
28222822 }
28232823}
28242824
2825fn writeLoadCommands(self: *MachO) anyerror!struct { usize, usize, u64 } {
2825fn writeLoadCommands(self: *MachO) std.io.Writer.Error!struct { usize, usize, u64 } {
28262826 const comp = self.base.comp;
28272827 const gpa = comp.gpa;
28282828
......@@ -3910,7 +3910,7 @@ pub fn dumpState(self: *MachO) std.fmt.Formatter(fmtDumpState) {
39103910 return .{ .data = self };
39113911}
39123912
3913fn fmtDumpState(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
3913fn fmtDumpState(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
39143914 _ = unused_fmt_string;
39153915 if (self.getZigObject()) |zo| {
39163916 try bw.print("zig_object({d}) : {s}\n", .{ zo.index, zo.basename });
......@@ -3969,7 +3969,7 @@ fn fmtSections(self: *MachO) std.fmt.Formatter(formatSections) {
39693969 return .{ .data = self };
39703970}
39713971
3972fn formatSections(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
3972fn formatSections(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
39733973 _ = unused_fmt_string;
39743974 const slice = self.sections.slice();
39753975 for (slice.items(.header), slice.items(.segment_id), 0..) |header, seg_id, i| {
......@@ -3987,7 +3987,7 @@ fn fmtSegments(self: *MachO) std.fmt.Formatter(formatSegments) {
39873987 return .{ .data = self };
39883988}
39893989
3990fn formatSegments(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
3990fn formatSegments(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
39913991 _ = unused_fmt_string;
39923992 for (self.segments.items, 0..) |seg, i| {
39933993 try bw.print("seg({d}) : {s} : @{x}-{x} ({x}-{x})\n", .{
......@@ -4001,7 +4001,7 @@ pub fn fmtSectType(tt: u8) std.fmt.Formatter(formatSectType) {
40014001 return .{ .data = tt };
40024002}
40034003
4004fn formatSectType(tt: u8, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
4004fn formatSectType(tt: u8, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
40054005 _ = unused_fmt_string;
40064006 const name = switch (tt) {
40074007 macho.S_REGULAR => "REGULAR",
......@@ -4270,7 +4270,7 @@ pub const Platform = struct {
42704270 cpu_arch: std.Target.Cpu.Arch,
42714271 };
42724272
4273 pub fn formatTarget(ctx: FmtCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
4273 pub fn formatTarget(ctx: FmtCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
42744274 _ = unused_fmt_string;
42754275 try bw.print("{s}-{s}", .{ @tagName(ctx.cpu_arch), @tagName(ctx.platform.os_tag) });
42764276 if (ctx.platform.abi != .none) {
......@@ -4483,7 +4483,7 @@ pub const Ref = struct {
44834483 };
44844484 }
44854485
4486 pub fn format(ref: Ref, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
4486 pub fn format(ref: Ref, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
44874487 _ = unused_fmt_string;
44884488 try bw.print("%{d} in file({d})", .{ ref.index, ref.file });
44894489 }
src/link/MachO/Archive.zig+4-4
......@@ -82,7 +82,7 @@ pub fn writeHeader(
8282 object_name: []const u8,
8383 object_size: usize,
8484 format: Format,
85) anyerror!void {
85) std.io.Writer.Error!void {
8686 var hdr: ar_hdr = undefined;
8787 @memset(mem.asBytes(&hdr), ' ');
8888 inline for (@typeInfo(ar_hdr).@"struct".fields) |field| @field(hdr, field.name)[0] = '0';
......@@ -177,7 +177,7 @@ pub const ArSymtab = struct {
177177 return ptr_width + ar.entries.items.len * 2 * ptr_width + ptr_width + mem.alignForward(usize, ar.strtab.buffer.items.len, ptr_width);
178178 }
179179
180 pub fn write(ar: ArSymtab, bw: *std.io.BufferedWriter, format: Format, macho_file: *MachO) anyerror!void {
180 pub fn write(ar: ArSymtab, bw: *std.io.BufferedWriter, format: Format, macho_file: *MachO) std.io.Writer.Error!void {
181181 const ptr_width = ptrWidth(format);
182182 // Header
183183 try writeHeader(bw, SYMDEF, ar.size(format), format);
......@@ -212,7 +212,7 @@ pub const ArSymtab = struct {
212212 return .{ .data = .{ .ar = ar, .macho_file = macho_file } };
213213 }
214214
215 fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
215 fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
216216 _ = unused_fmt_string;
217217 const ar = ctx.ar;
218218 const macho_file = ctx.macho_file;
......@@ -249,7 +249,7 @@ pub fn ptrWidth(format: Format) usize {
249249 };
250250}
251251
252pub fn writeInt(bw: *std.io.BufferedWriter, format: Format, value: u64) anyerror!void {
252pub fn writeInt(bw: *std.io.BufferedWriter, format: Format, value: u64) std.io.Writer.Error!void {
253253 switch (format) {
254254 .p32 => try bw.writeInt(u32, std.math.cast(u32, value) orelse return error.Overflow, .little),
255255 .p64 => try bw.writeInt(u64, value, .little),
src/link/MachO/Atom.zig+2-2
......@@ -639,7 +639,7 @@ fn resolveRelocInner(
639639 code: []u8,
640640 macho_file: *MachO,
641641 bw: *std.io.BufferedWriter,
642) anyerror!void {
642) std.io.Writer.Error!void {
643643 const t = &macho_file.base.comp.root_mod.resolved_target.result;
644644 const cpu_arch = t.cpu.arch;
645645 const rel_offset = math.cast(usize, rel.offset - self.off) orelse return error.Overflow;
......@@ -1140,7 +1140,7 @@ const FormatContext = struct {
11401140 macho_file: *MachO,
11411141};
11421142
1143fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
1143fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
11441144 _ = unused_fmt_string;
11451145 const atom = ctx.atom;
11461146 const macho_file = ctx.macho_file;
src/link/MachO/Dylib.zig+1-1
......@@ -676,7 +676,7 @@ const FormatContext = struct {
676676 macho_file: *MachO,
677677};
678678
679fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
679fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
680680 _ = unused_fmt_string;
681681 const dylib = ctx.dylib;
682682 const macho_file = ctx.macho_file;
src/link/MachO/InternalObject.zig+2-2
......@@ -848,7 +848,7 @@ pub fn fmtAtoms(self: *InternalObject, macho_file: *MachO) std.fmt.Formatter(for
848848 } };
849849}
850850
851fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
851fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
852852 _ = unused_fmt_string;
853853 try bw.writeAll(" atoms\n");
854854 for (ctx.self.getAtoms()) |atom_index| {
......@@ -864,7 +864,7 @@ pub fn fmtSymtab(self: *InternalObject, macho_file: *MachO) std.fmt.Formatter(fo
864864 } };
865865}
866866
867fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
867fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
868868 _ = unused_fmt_string;
869869 const macho_file = ctx.macho_file;
870870 const self = ctx.self;
src/link/MachO/Object.zig+9-9
......@@ -2513,7 +2513,7 @@ pub fn readSectionData(self: Object, allocator: Allocator, file: File.Handle, n_
25132513 return data;
25142514}
25152515
2516pub fn format(self: *Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2516pub fn format(self: *Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
25172517 _ = self;
25182518 _ = bw;
25192519 _ = unused_fmt_string;
......@@ -2532,7 +2532,7 @@ pub fn fmtAtoms(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatAtoms
25322532 } };
25332533}
25342534
2535fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2535fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
25362536 _ = unused_fmt_string;
25372537 const object = ctx.object;
25382538 const macho_file = ctx.macho_file;
......@@ -2550,7 +2550,7 @@ pub fn fmtCies(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatCies)
25502550 } };
25512551}
25522552
2553fn formatCies(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2553fn formatCies(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
25542554 _ = unused_fmt_string;
25552555 const object = ctx.object;
25562556 try bw.writeAll(" cies\n");
......@@ -2566,7 +2566,7 @@ pub fn fmtFdes(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatFdes)
25662566 } };
25672567}
25682568
2569fn formatFdes(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2569fn formatFdes(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
25702570 _ = unused_fmt_string;
25712571 const object = ctx.object;
25722572 try bw.writeAll(" fdes\n");
......@@ -2582,7 +2582,7 @@ pub fn fmtUnwindRecords(self: *Object, macho_file: *MachO) std.fmt.Formatter(for
25822582 } };
25832583}
25842584
2585fn formatUnwindRecords(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2585fn formatUnwindRecords(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
25862586 _ = unused_fmt_string;
25872587 const object = ctx.object;
25882588 const macho_file = ctx.macho_file;
......@@ -2599,7 +2599,7 @@ pub fn fmtSymtab(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatSymt
25992599 } };
26002600}
26012601
2602fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2602fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
26032603 _ = unused_fmt_string;
26042604 const object = ctx.object;
26052605 const macho_file = ctx.macho_file;
......@@ -2629,7 +2629,7 @@ pub fn fmtPath(self: Object) std.fmt.Formatter(formatPath) {
26292629 return .{ .data = self };
26302630}
26312631
2632fn formatPath(object: Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2632fn formatPath(object: Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
26332633 _ = unused_fmt_string;
26342634 if (object.in_archive) |ar| {
26352635 try bw.print("{f}({s})", .{
......@@ -2690,7 +2690,7 @@ const StabFile = struct {
26902690 return object.symbols.items[index];
26912691 }
26922692
2693 pub fn format(stab: Stab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2693 pub fn format(stab: Stab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
26942694 _ = stab;
26952695 _ = bw;
26962696 _ = unused_fmt_string;
......@@ -2703,7 +2703,7 @@ const StabFile = struct {
27032703 return .{ .data = .{ stab, object } };
27042704 }
27052705
2706 fn format2(ctx: StabFormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
2706 fn format2(ctx: StabFormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
27072707 _ = unused_fmt_string;
27082708 const stab, const object = ctx;
27092709 const sym = stab.getSymbol(object).?;
src/link/MachO/Relocation.zig+1-1
......@@ -76,7 +76,7 @@ pub fn fmtPretty(rel: Relocation, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatt
7676 return .{ .data = .{ rel, cpu_arch } };
7777}
7878
79fn formatPretty(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
79fn formatPretty(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
8080 _ = unused_fmt_string;
8181 const rel, const cpu_arch = ctx;
8282 try bw.writeAll(switch (rel.type) {
src/link/MachO/Symbol.zig+2-2
......@@ -286,7 +286,7 @@ pub fn setOutputSym(symbol: Symbol, macho_file: *MachO, out: *macho.nlist_64) vo
286286 }
287287}
288288
289pub fn format(symbol: Symbol, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
289pub fn format(symbol: Symbol, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
290290 _ = symbol;
291291 _ = bw;
292292 _ = unused_fmt_string;
......@@ -305,7 +305,7 @@ pub fn fmt(symbol: Symbol, macho_file: *MachO) std.fmt.Formatter(format2) {
305305 } };
306306}
307307
308fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
308fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
309309 _ = unused_fmt_string;
310310 const symbol = ctx.symbol;
311311 try bw.print("%{d} : {s} : @{x}", .{
src/link/MachO/Thunk.zig+2-2
......@@ -61,7 +61,7 @@ pub fn writeSymtab(thunk: Thunk, macho_file: *MachO, ctx: anytype) void {
6161 }
6262}
6363
64pub fn format(thunk: Thunk, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
64pub fn format(thunk: Thunk, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
6565 _ = thunk;
6666 _ = bw;
6767 _ = unused_fmt_string;
......@@ -80,7 +80,7 @@ const FormatContext = struct {
8080 macho_file: *MachO,
8181};
8282
83fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
83fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
8484 _ = unused_fmt_string;
8585 const thunk = ctx.thunk;
8686 const macho_file = ctx.macho_file;
src/link/MachO/UnwindInfo.zig+6-6
......@@ -289,7 +289,7 @@ pub fn calcSize(info: UnwindInfo) usize {
289289 return total_size;
290290}
291291
292pub fn write(info: UnwindInfo, macho_file: *MachO, bw: *std.io.BufferedWriter) anyerror!void {
292pub fn write(info: UnwindInfo, macho_file: *MachO, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
293293 const seg = macho_file.getTextSegment();
294294 const header = macho_file.sections.items(.header)[macho_file.unwind_info_sect_index.?];
295295
......@@ -449,7 +449,7 @@ pub const Encoding = extern struct {
449449 return enc.enc == other.enc;
450450 }
451451
452 pub fn format(enc: Encoding, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
452 pub fn format(enc: Encoding, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
453453 _ = unused_fmt_string;
454454 try bw.print("0x{x:0>8}", .{enc.enc});
455455 }
......@@ -505,7 +505,7 @@ pub const Record = struct {
505505 return lsda.getAddress(macho_file) + rec.lsda_offset;
506506 }
507507
508 pub fn format(rec: Record, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
508 pub fn format(rec: Record, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
509509 _ = rec;
510510 _ = bw;
511511 _ = unused_fmt_string;
......@@ -524,7 +524,7 @@ pub const Record = struct {
524524 macho_file: *MachO,
525525 };
526526
527 fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
527 fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
528528 _ = unused_fmt_string;
529529 const rec = ctx.rec;
530530 const macho_file = ctx.macho_file;
......@@ -589,7 +589,7 @@ const Page = struct {
589589 return null;
590590 }
591591
592 fn format(page: *const Page, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void {
592 fn format(page: *const Page, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void {
593593 _ = page;
594594 _ = bw;
595595 _ = unused_format_string;
......@@ -601,7 +601,7 @@ const Page = struct {
601601 info: UnwindInfo,
602602 };
603603
604 fn format2(ctx: FormatPageContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void {
604 fn format2(ctx: FormatPageContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void {
605605 _ = unused_format_string;
606606 try bw.writeAll("Page:\n");
607607 try bw.print(" kind: {s}\n", .{@tagName(ctx.page.kind)});
src/link/MachO/ZigObject.zig+3-3
......@@ -317,7 +317,7 @@ pub fn updateArSize(self: *ZigObject) void {
317317 self.output_ar_state.size = self.data.items.len;
318318}
319319
320pub fn writeAr(self: ZigObject, bw: *std.io.BufferedWriter, ar_format: Archive.Format) anyerror!void {
320pub fn writeAr(self: ZigObject, bw: *std.io.BufferedWriter, ar_format: Archive.Format) std.io.Writer.Error!void {
321321 // Header
322322 const size = std.math.cast(usize, self.output_ar_state.size) orelse return error.Overflow;
323323 try Archive.writeHeader(bw, self.basename, size, ar_format);
......@@ -1688,7 +1688,7 @@ const FormatContext = struct {
16881688 macho_file: *MachO,
16891689};
16901690
1691fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
1691fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
16921692 _ = unused_fmt_string;
16931693 try bw.writeAll(" symbols\n");
16941694 const self = ctx.self;
......@@ -1711,7 +1711,7 @@ pub fn fmtAtoms(self: *ZigObject, macho_file: *MachO) std.fmt.Formatter(formatAt
17111711 } };
17121712}
17131713
1714fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
1714fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
17151715 _ = unused_fmt_string;
17161716 const self = ctx.self;
17171717 const macho_file = ctx.macho_file;
src/link/MachO/dead_strip.zig+1-1
......@@ -196,7 +196,7 @@ const Level = struct {
196196 self.value += 1;
197197 }
198198
199 pub fn format(self: *const @This(), bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
199 pub fn format(self: *const @This(), bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
200200 _ = unused_fmt_string;
201201 try bw.splatByteAll(' ', self.value);
202202 }
src/link/MachO/dyld_info/Rebase.zig+9-9
......@@ -133,7 +133,7 @@ fn finalize(rebase: *Rebase, gpa: Allocator) !void {
133133 try done(bw);
134134}
135135
136fn finalizeSegment(entries: []const Entry, bw: *std.io.BufferedWriter) anyerror!void {
136fn finalizeSegment(entries: []const Entry, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
137137 if (entries.len == 0) return;
138138
139139 const segment_id = entries[0].segment_id;
......@@ -220,24 +220,24 @@ fn finalizeSegment(entries: []const Entry, bw: *std.io.BufferedWriter) anyerror!
220220 }
221221}
222222
223fn setTypePointer(bw: *std.io.BufferedWriter) anyerror!void {
223fn setTypePointer(bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
224224 log.debug(">>> set type: {d}", .{macho.REBASE_TYPE_POINTER});
225225 try bw.writeByte(macho.REBASE_OPCODE_SET_TYPE_IMM | @as(u4, @intCast(macho.REBASE_TYPE_POINTER)));
226226}
227227
228fn setSegmentOffset(segment_id: u4, offset: u64, bw: *std.io.BufferedWriter) anyerror!void {
228fn setSegmentOffset(segment_id: u4, offset: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
229229 log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset });
230230 try bw.writeByte(macho.REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | @as(u4, @truncate(segment_id)));
231231 try bw.writeLeb128(offset);
232232}
233233
234fn rebaseAddAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void {
234fn rebaseAddAddr(addr: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
235235 log.debug(">>> rebase with add: {x}", .{addr});
236236 try bw.writeByte(macho.REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB);
237237 try bw.writeLeb128(addr);
238238}
239239
240fn rebaseTimes(count: usize, bw: *std.io.BufferedWriter) anyerror!void {
240fn rebaseTimes(count: usize, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
241241 log.debug(">>> rebase with count: {d}", .{count});
242242 if (count <= 0xf) {
243243 try bw.writeByte(macho.REBASE_OPCODE_DO_REBASE_IMM_TIMES | @as(u4, @truncate(count)));
......@@ -247,14 +247,14 @@ fn rebaseTimes(count: usize, bw: *std.io.BufferedWriter) anyerror!void {
247247 }
248248}
249249
250fn rebaseTimesSkip(count: usize, skip: u64, bw: *std.io.BufferedWriter) anyerror!void {
250fn rebaseTimesSkip(count: usize, skip: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
251251 log.debug(">>> rebase with count: {d} and skip: {x}", .{ count, skip });
252252 try bw.writeByte(macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB);
253253 try bw.writeLeb128(count);
254254 try bw.writeLeb128(skip);
255255}
256256
257fn addAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void {
257fn addAddr(addr: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
258258 log.debug(">>> add: {x}", .{addr});
259259 if (std.math.divExact(u64, addr, @sizeOf(u64))) |scaled| {
260260 if (std.math.cast(u4, scaled)) |imm_scaled| return bw.writeByte(
......@@ -265,12 +265,12 @@ fn addAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void {
265265 try bw.writeLeb128(addr);
266266}
267267
268fn done(bw: *std.io.BufferedWriter) anyerror!void {
268fn done(bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
269269 log.debug(">>> done", .{});
270270 try bw.writeByte(macho.REBASE_OPCODE_DONE);
271271}
272272
273pub fn write(rebase: Rebase, bw: *std.io.BufferedWriter) anyerror!void {
273pub fn write(rebase: Rebase, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
274274 try bw.writeAll(rebase.buffer.items);
275275}
276276
src/link/MachO/dyld_info/Trie.zig+1-1
......@@ -232,7 +232,7 @@ pub fn deinit(self: *Trie, allocator: Allocator) void {
232232 allocator.free(self.buffer);
233233}
234234
235pub fn write(self: Trie, bw: *std.io.BufferedWriter) anyerror!void {
235pub fn write(self: Trie, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
236236 try bw.writeAll(self.buffer);
237237}
238238
src/link/MachO/dyld_info/bind.zig+15-15
......@@ -139,7 +139,7 @@ pub const Bind = struct {
139139 try done(bw);
140140 }
141141
142 fn finalizeSegment(entries: []const Entry, ctx: *MachO, bw: *std.io.BufferedWriter) anyerror!void {
142 fn finalizeSegment(entries: []const Entry, ctx: *MachO, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
143143 if (entries.len == 0) return;
144144
145145 const seg_id = entries[0].segment_id;
......@@ -251,7 +251,7 @@ pub const Bind = struct {
251251 }
252252 }
253253
254 pub fn write(bind: Bind, bw: *std.io.BufferedWriter) anyerror!void {
254 pub fn write(bind: Bind, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
255255 try bw.writeAll(bind.buffer.items);
256256 }
257257};
......@@ -380,7 +380,7 @@ pub const WeakBind = struct {
380380 try done(bw);
381381 }
382382
383 fn finalizeSegment(entries: []const Entry, ctx: *MachO, bw: *std.io.BufferedWriter) anyerror!void {
383 fn finalizeSegment(entries: []const Entry, ctx: *MachO, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
384384 if (entries.len == 0) return;
385385
386386 const seg_id = entries[0].segment_id;
......@@ -481,7 +481,7 @@ pub const WeakBind = struct {
481481 }
482482 }
483483
484 pub fn write(bind: WeakBind, bw: *std.io.BufferedWriter) anyerror!void {
484 pub fn write(bind: WeakBind, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
485485 try bw.writeAll(bind.buffer.items);
486486 }
487487};
......@@ -565,30 +565,30 @@ pub const LazyBind = struct {
565565 }
566566 }
567567
568 pub fn write(bind: LazyBind, bw: *std.io.BufferedWriter) anyerror!void {
568 pub fn write(bind: LazyBind, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
569569 try bw.writeAll(bind.buffer.items);
570570 }
571571};
572572
573fn setSegmentOffset(segment_id: u4, offset: u64, bw: *std.io.BufferedWriter) anyerror!void {
573fn setSegmentOffset(segment_id: u4, offset: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
574574 log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset });
575575 try bw.writeByte(macho.BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | segment_id);
576576 try bw.writeLeb128(offset);
577577}
578578
579fn setSymbol(name: []const u8, flags: u4, bw: *std.io.BufferedWriter) anyerror!void {
579fn setSymbol(name: []const u8, flags: u4, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
580580 log.debug(">>> set symbol: {s} with flags: {x}", .{ name, flags });
581581 try bw.writeByte(macho.BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM | flags);
582582 try bw.writeAll(name);
583583 try bw.writeByte(0);
584584}
585585
586fn setTypePointer(bw: *std.io.BufferedWriter) anyerror!void {
586fn setTypePointer(bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
587587 log.debug(">>> set type: {d}", .{macho.BIND_TYPE_POINTER});
588588 try bw.writeByte(macho.BIND_OPCODE_SET_TYPE_IMM | @as(u4, @intCast(macho.BIND_TYPE_POINTER)));
589589}
590590
591fn setDylibOrdinal(ordinal: i16, bw: *std.io.BufferedWriter) anyerror!void {
591fn setDylibOrdinal(ordinal: i16, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
592592 switch (ordinal) {
593593 else => unreachable, // Invalid dylib special binding
594594 macho.BIND_SPECIAL_DYLIB_SELF,
......@@ -610,18 +610,18 @@ fn setDylibOrdinal(ordinal: i16, bw: *std.io.BufferedWriter) anyerror!void {
610610 }
611611}
612612
613fn setAddend(addend: i64, bw: *std.io.BufferedWriter) anyerror!void {
613fn setAddend(addend: i64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
614614 log.debug(">>> set addend: {x}", .{addend});
615615 try bw.writeByte(macho.BIND_OPCODE_SET_ADDEND_SLEB);
616616 try bw.writeLeb128(addend);
617617}
618618
619fn doBind(bw: *std.io.BufferedWriter) anyerror!void {
619fn doBind(bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
620620 log.debug(">>> bind", .{});
621621 try bw.writeByte(macho.BIND_OPCODE_DO_BIND);
622622}
623623
624fn doBindAddAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void {
624fn doBindAddAddr(addr: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
625625 log.debug(">>> bind with add: {x}", .{addr});
626626 if (std.math.divExact(u64, addr, @sizeOf(u64))) |scaled| {
627627 if (std.math.cast(u4, scaled)) |imm_scaled| return bw.writeByte(
......@@ -632,20 +632,20 @@ fn doBindAddAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void {
632632 try bw.writeLeb128(addr);
633633}
634634
635fn doBindTimesSkip(count: usize, skip: u64, bw: *std.io.BufferedWriter) anyerror!void {
635fn doBindTimesSkip(count: usize, skip: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
636636 log.debug(">>> bind with count: {d} and skip: {x}", .{ count, skip });
637637 try bw.writeByte(macho.BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB);
638638 try bw.writeLeb128(count);
639639 try bw.writeLeb128(skip);
640640}
641641
642fn addAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void {
642fn addAddr(addr: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
643643 log.debug(">>> add: {x}", .{addr});
644644 try bw.writeByte(macho.BIND_OPCODE_ADD_ADDR_ULEB);
645645 try bw.writeLeb128(addr);
646646}
647647
648fn done(bw: *std.io.BufferedWriter) anyerror!void {
648fn done(bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
649649 log.debug(">>> done", .{});
650650 try bw.writeByte(macho.BIND_OPCODE_DONE);
651651}
src/link/MachO/eh_frame.zig+2-2
......@@ -104,7 +104,7 @@ pub const Cie = struct {
104104 macho_file: *MachO,
105105 };
106106
107 fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
107 fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
108108 _ = unused_fmt_string;
109109 const cie = ctx.cie;
110110 try bw.print("@{x} : size({x})", .{
......@@ -250,7 +250,7 @@ pub const Fde = struct {
250250 macho_file: *MachO,
251251 };
252252
253 fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
253 fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
254254 _ = unused_fmt_string;
255255 const fde = ctx.fde;
256256 const macho_file = ctx.macho_file;
src/link/MachO/file.zig+2-2
......@@ -14,7 +14,7 @@ pub const File = union(enum) {
1414 return .{ .data = file };
1515 }
1616
17 fn formatPath(file: File, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void {
17 fn formatPath(file: File, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void {
1818 _ = unused_fmt_string;
1919 switch (file) {
2020 .zig_object => |zo| try bw.writeAll(zo.basename),
......@@ -322,7 +322,7 @@ pub const File = union(enum) {
322322 };
323323 }
324324
325 pub fn writeAr(file: File, bw: *std.io.BufferedWriter, ar_format: Archive.Format, macho_file: *MachO) anyerror!void {
325 pub fn writeAr(file: File, bw: *std.io.BufferedWriter, ar_format: Archive.Format, macho_file: *MachO) std.io.Writer.Error!void {
326326 return switch (file) {
327327 .dylib, .internal => unreachable,
328328 .zig_object => |x| x.writeAr(bw, ar_format),
src/link/MachO/load_commands.zig+3-3
......@@ -180,7 +180,7 @@ pub fn calcMinHeaderPadSize(macho_file: *MachO) !u32 {
180180 return offset;
181181}
182182
183pub fn writeDylinkerLC(bw: *std.io.BufferedWriter) anyerror!void {
183pub fn writeDylinkerLC(bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
184184 const name_len = mem.sliceTo(default_dyld_path, 0).len;
185185 const cmdsize = @as(u32, @intCast(mem.alignForward(
186186 u64,
......@@ -268,7 +268,7 @@ pub fn writeRpathLC(bw: *std.io.BufferedWriter, rpath: []const u8) !void {
268268 try bw.splatByteAll(0, cmdsize - @sizeOf(macho.rpath_command) - rpath_len);
269269}
270270
271pub fn writeVersionMinLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, sdk_version: ?std.SemanticVersion) anyerror!void {
271pub fn writeVersionMinLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, sdk_version: ?std.SemanticVersion) std.io.Writer.Error!void {
272272 const cmd: macho.LC = switch (platform.os_tag) {
273273 .macos => .VERSION_MIN_MACOSX,
274274 .ios => .VERSION_MIN_IPHONEOS,
......@@ -286,7 +286,7 @@ pub fn writeVersionMinLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, s
286286 }));
287287}
288288
289pub fn writeBuildVersionLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, sdk_version: ?std.SemanticVersion) anyerror!void {
289pub fn writeBuildVersionLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, sdk_version: ?std.SemanticVersion) std.io.Writer.Error!void {
290290 const cmdsize = @sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version);
291291 try bw.writeStruct(macho.build_version_command{
292292 .cmdsize = cmdsize,
src/link/Wasm.zig+2-2
......@@ -2125,7 +2125,7 @@ pub const FunctionType = extern struct {
21252125 wasm: *const Wasm,
21262126 ft: FunctionType,
21272127
2128 pub fn format(self: Formatter, bw: *std.io.BufferedWriter, comptime format_string: []const u8) anyerror!void {
2128 pub fn format(self: Formatter, bw: *std.io.BufferedWriter, comptime format_string: []const u8) std.io.Writer.Error!void {
21292129 if (format_string.len != 0) std.fmt.invalidFmtError(format_string, self);
21302130 const params = self.ft.params.slice(self.wasm);
21312131 const returns = self.ft.returns.slice(self.wasm);
......@@ -2905,7 +2905,7 @@ pub const Feature = packed struct(u8) {
29052905 @"=",
29062906 };
29072907
2908 pub fn format(feature: Feature, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
2908 pub fn format(feature: Feature, bw: *std.io.BufferedWriter, comptime fmt: []const u8) std.io.Writer.Error!void {
29092909 _ = fmt;
29102910 try bw.print("{s} {s}", .{ @tagName(feature.prefix), @tagName(feature.tag) });
29112911 }
src/link/Wasm/Flush.zig+15-15
......@@ -1065,7 +1065,7 @@ fn emitNameSection(
10651065 wasm: *Wasm,
10661066 aw: *std.io.AllocatingWriter,
10671067 data_segment_groups: []const DataSegmentGroup,
1068) anyerror!void {
1068) !void {
10691069 const f = &wasm.flush_buffer;
10701070 const bw = &aw.buffered_writer;
10711071 const header_offset = try reserveSectionHeader(bw);
......@@ -1127,7 +1127,7 @@ fn emitNameSection(
11271127 }
11281128}
11291129
1130fn emitFeaturesSection(aw: *std.io.AllocatingWriter, target: *const std.Target) anyerror!void {
1130fn emitFeaturesSection(aw: *std.io.AllocatingWriter, target: *const std.Target) Allocator.Error!void {
11311131 const feature_count = target.cpu.features.count();
11321132 if (feature_count == 0) return;
11331133
......@@ -1251,7 +1251,7 @@ fn wantSegmentMerge(
12511251/// section id + fixed leb contents size + fixed leb vector length
12521252const vec_section_header_size = section_header_size + size_header_size;
12531253
1254fn reserveVecSectionHeader(bw: *std.io.BufferedWriter) anyerror!u32 {
1254fn reserveVecSectionHeader(bw: *std.io.BufferedWriter) std.io.Writer.Error!u32 {
12551255 const offset = bw.count;
12561256 _ = try bw.writableSlice(vec_section_header_size);
12571257 bw.advance(vec_section_header_size);
......@@ -1272,7 +1272,7 @@ fn replaceVecSectionHeader(
12721272
12731273const section_header_size = 1 + size_header_size;
12741274
1275fn reserveSectionHeader(bw: *std.io.BufferedWriter) anyerror!u32 {
1275fn reserveSectionHeader(bw: *std.io.BufferedWriter) std.io.Writer.Error!u32 {
12761276 const offset = bw.count;
12771277 _ = try bw.writableSlice(section_header_size);
12781278 bw.advance(section_header_size);
......@@ -1287,7 +1287,7 @@ fn replaceSectionHeader(aw: *std.io.AllocatingWriter, offset: u32, section: u8)
12871287
12881288const size_header_size = 5;
12891289
1290fn reserveSizeHeader(bw: *std.io.BufferedWriter) anyerror!u32 {
1290fn reserveSizeHeader(bw: *std.io.BufferedWriter) std.io.Writer.Error!u32 {
12911291 const offset = bw.count;
12921292 _ = try bw.writableSlice(size_header_size);
12931293 bw.advance(size_header_size);
......@@ -1299,7 +1299,7 @@ fn replaceSizeHeader(aw: *std.io.AllocatingWriter, offset: u32) void {
12991299 std.leb.writeUnsignedFixed(5, header[0..5], @intCast(aw.buffered_writer.count - offset - size_header_size));
13001300}
13011301
1302fn emitLimits(bw: *std.io.BufferedWriter, limits: std.wasm.Limits) anyerror!void {
1302fn emitLimits(bw: *std.io.BufferedWriter, limits: std.wasm.Limits) std.io.Writer.Error!void {
13031303 try bw.writeByte(@bitCast(limits.flags));
13041304 try bw.writeLeb128(limits.min);
13051305 if (limits.flags.has_max) try bw.writeLeb128(limits.max);
......@@ -1310,7 +1310,7 @@ fn emitMemoryImport(
13101310 bw: *std.io.BufferedWriter,
13111311 name_index: String,
13121312 memory_import: *const Wasm.MemoryImport,
1313) anyerror!void {
1313) std.io.Writer.Error!void {
13141314 const module_name = memory_import.module_name.slice(wasm);
13151315 try bw.writeLeb128(module_name.len);
13161316 try bw.writeAll(module_name);
......@@ -1323,7 +1323,7 @@ fn emitMemoryImport(
13231323 try emitLimits(bw, memory_import.limits());
13241324}
13251325
1326pub fn emitInit(bw: *std.io.BufferedWriter, init_expr: std.wasm.InitExpression) anyerror!void {
1326pub fn emitInit(bw: *std.io.BufferedWriter, init_expr: std.wasm.InitExpression) std.io.Writer.Error!void {
13271327 switch (init_expr) {
13281328 inline else => |val, tag| {
13291329 try bw.writeByte(@intFromEnum(@field(std.wasm.Opcode, @tagName(tag))));
......@@ -1341,12 +1341,12 @@ pub fn emitInit(bw: *std.io.BufferedWriter, init_expr: std.wasm.InitExpression)
13411341 try bw.writeByte(@intFromEnum(std.wasm.Opcode.end));
13421342}
13431343
1344pub fn emitExpr(wasm: *const Wasm, bw: *std.io.BufferedWriter, expr: Wasm.Expr) anyerror!void {
1344pub fn emitExpr(wasm: *const Wasm, bw: *std.io.BufferedWriter, expr: Wasm.Expr) std.io.Writer.Error!void {
13451345 const slice = expr.slice(wasm);
13461346 try bw.writeAll(slice[0 .. slice.len + 1]); // +1 to include end opcode
13471347}
13481348
1349fn emitSegmentInfo(wasm: *Wasm, aw: *std.io.BufferedWriter) anyerror!void {
1349fn emitSegmentInfo(wasm: *Wasm, aw: *std.io.BufferedWriter) std.io.Writer.Error!void {
13501350 const bw = &aw.buffered_writer;
13511351 const header_offset = try reserveSectionHeader(bw);
13521352 defer replaceSectionHeader(aw, header_offset, @intFromEnum(Wasm.SubsectionType.segment_info));
......@@ -1371,7 +1371,7 @@ fn emitTagNameTable(
13711371 tag_name_bytes: []const u8,
13721372 base: u32,
13731373 comptime Int: type,
1374) anyerror!void {
1374) std.io.Writer.Error!void {
13751375 for (tag_name_offs) |off| {
13761376 const name_len: u32 = @intCast(mem.indexOfScalar(u8, tag_name_bytes[off..], 0).?);
13771377 try bw.writeInt(Int, base + off, .little);
......@@ -1539,7 +1539,7 @@ fn reloc_leb_type(code: []u8, index: FuncTypeIndex) void {
15391539 std.leb.writeUnsignedFixed(5, code[0..5], @intFromEnum(index));
15401540}
15411541
1542fn emitCallCtorsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) anyerror!void {
1542fn emitCallCtorsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
15431543 try bw.writeUleb128(0); // no locals
15441544 for (wasm.object_init_funcs.items) |init_func| {
15451545 const func = init_func.function_index.ptr(wasm);
......@@ -1558,7 +1558,7 @@ fn emitCallCtorsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) anyerror
15581558 try bw.writeByte(@intFromEnum(std.wasm.Opcode.end)); // end function body
15591559}
15601560
1561fn emitInitMemoryFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter, virtual_addrs: *const VirtualAddrs) anyerror!void {
1561fn emitInitMemoryFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter, virtual_addrs: *const VirtualAddrs) std.io.Writer.Error!void {
15621562 const comp = wasm.base.comp;
15631563 const shared_memory = comp.config.shared_memory;
15641564
......@@ -1710,7 +1710,7 @@ fn emitInitMemoryFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter, virtual
17101710 try bw.writeByte(@intFromEnum(std.wasm.Opcode.end));
17111711}
17121712
1713fn emitInitTlsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) anyerror!void {
1713fn emitInitTlsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
17141714 const comp = wasm.base.comp;
17151715 assert(comp.config.shared_memory);
17161716
......@@ -1888,7 +1888,7 @@ fn emitTagNameFunction(
18881888 try bw.writeByte(@intFromEnum(std.wasm.Opcode.end));
18891889}
18901890
1891fn appendGlobal(bw: *std.io.BufferedWriter, mutable: bool, val: u32) anyerror!void {
1891fn appendGlobal(bw: *std.io.BufferedWriter, mutable: bool, val: u32) std.io.Writer.Error!void {
18921892 try bw.writeAll(&.{
18931893 @intFromEnum(std.wasm.Valtype.i32),
18941894 @intFromBool(mutable),
src/link/Wasm/Object.zig+5-5
......@@ -259,7 +259,7 @@ pub fn parse(
259259 ss: *ScratchSpace,
260260 must_link: bool,
261261 gc_sections: bool,
262) anyerror!Object {
262) !Object {
263263 const comp = wasm.base.comp;
264264 const gpa = comp.gpa;
265265 const diags = &comp.link_diags;
......@@ -1402,7 +1402,7 @@ pub fn parse(
14021402/// Based on the "features" custom section, parses it into a list of
14031403/// features that tell the linker what features were enabled and may be mandatory
14041404/// to be able to link.
1405fn parseFeatures(wasm: *Wasm, br: *std.io.BufferedReader, path: Path) anyerror!Wasm.Feature.Set {
1405fn parseFeatures(wasm: *Wasm, br: *std.io.BufferedReader, path: Path) error{ OutOfMemory, LinkFailure }!Wasm.Feature.Set {
14061406 const gpa = wasm.base.comp.gpa;
14071407 const diags = &wasm.base.comp.link_diags;
14081408 const features_len = try br.takeLeb128(u32);
......@@ -1430,7 +1430,7 @@ fn parseFeatures(wasm: *Wasm, br: *std.io.BufferedReader, path: Path) anyerror!W
14301430 return .fromString(try wasm.internString(@ptrCast(feature_buffer)));
14311431}
14321432
1433fn readLimits(br: *std.io.BufferedReader) anyerror!std.wasm.Limits {
1433fn readLimits(br: *std.io.BufferedReader) std.io.Reader.Error!std.wasm.Limits {
14341434 const flags: std.wasm.Limits.Flags = @bitCast(try br.takeByte());
14351435 const min = try br.takeLeb128(u32);
14361436 const max = if (flags.has_max) try br.takeLeb128(u32) else 0;
......@@ -1441,13 +1441,13 @@ fn readLimits(br: *std.io.BufferedReader) anyerror!std.wasm.Limits {
14411441 };
14421442}
14431443
1444fn readInit(wasm: *Wasm, br: *std.io.BufferedReader) anyerror!Wasm.Expr {
1444fn readInit(wasm: *Wasm, br: *std.io.BufferedReader) std.io.Reader.Error!Wasm.Expr {
14451445 const start = br.seek;
14461446 try skipInit(br); // one after the end opcode
14471447 return wasm.addExpr(br.storageBuffer()[start..br.seek]);
14481448}
14491449
1450pub fn skipInit(br: *std.io.BufferedReader) anyerror!void {
1450pub fn skipInit(br: *std.io.BufferedReader) std.io.Reader.Error!void {
14511451 switch (try br.takeEnum(std.wasm.Opcode, .little)) {
14521452 .i32_const => _ = try br.takeLeb128(i32),
14531453 .i64_const => _ = try br.takeLeb128(i64),
src/link/riscv.zig+4-4
......@@ -1,4 +1,4 @@
1pub fn writeSetSub6(comptime op: enum { set, sub }, addend: anytype, bw: *std.io.BufferedWriter) anyerror!void {
1pub fn writeSetSub6(comptime op: enum { set, sub }, addend: anytype, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
22 const mask: u8 = 0b11_000000;
33 const actual: i8 = @truncate(addend);
44 const old_value = (try bw.writableSlice(1))[0];
......@@ -9,7 +9,7 @@ pub fn writeSetSub6(comptime op: enum { set, sub }, addend: anytype, bw: *std.io
99 try bw.writeByte(new_value);
1010}
1111
12pub fn writeSetSubUleb(comptime op: enum { set, sub }, addend: i64, bw: *std.io.BufferedWriter) anyerror!void {
12pub fn writeSetSubUleb(comptime op: enum { set, sub }, addend: i64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
1313 switch (op) {
1414 .set => try overwriteUleb(@intCast(addend), bw),
1515 .sub => {
......@@ -21,7 +21,7 @@ pub fn writeSetSubUleb(comptime op: enum { set, sub }, addend: i64, bw: *std.io.
2121 }
2222}
2323
24fn overwriteUleb(new_value: u64, bw: *std.io.BufferedWriter) anyerror!void {
24fn overwriteUleb(new_value: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void {
2525 var value: u64 = new_value;
2626 while (true) {
2727 const byte = (try bw.writableSlice(1))[0];
......@@ -36,7 +36,7 @@ pub fn writeAddend(
3636 comptime op: enum { add, sub },
3737 value: anytype,
3838 bw: *std.io.BufferedWriter,
39) anyerror!void {
39) std.io.Writer.Error!void {
4040 const n = @divExact(@bitSizeOf(Int), 8);
4141 var V: Int = mem.readInt(Int, (try bw.writableSlice(n))[0..n], .little);
4242 const addend: Int = @truncate(value);
src/link/table_section.zig+1-1
......@@ -39,7 +39,7 @@ pub fn TableSection(comptime Entry: type) type {
3939 return self.entries.items.len;
4040 }
4141
42 pub fn format(self: Self, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void {
42 pub fn format(self: Self, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void {
4343 comptime assert(unused_format_string.len == 0);
4444 try bw.writeAll("TableSection:\n");
4545 for (self.entries.items, 0..) |entry, i| {
src/print_targets.zig+2-2
......@@ -11,7 +11,7 @@ const assert = std.debug.assert;
1111const glibc = @import("libs/glibc.zig");
1212const introspect = @import("introspect.zig");
1313
14pub fn cmdTargets(arena: Allocator, args: []const []const u8) anyerror!void {
14pub fn cmdTargets(arena: Allocator, args: []const []const u8) !void {
1515 _ = args;
1616 const host = std.zig.resolveTargetQueryOrFatal(.{});
1717 var buffer: [1024]u8 = undefined;
......@@ -20,7 +20,7 @@ pub fn cmdTargets(arena: Allocator, args: []const []const u8) anyerror!void {
2020 try bw.flush();
2121}
2222
23fn print(arena: Allocator, output: *std.io.BufferedWriter, host: *const Target) anyerror!void {
23fn print(arena: Allocator, output: *std.io.BufferedWriter, host: *const Target) std.io.Writer.Error!void {
2424 var zig_lib_directory = introspect.findZigLibDir(arena) catch |err| {
2525 fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)});
2626 };
src/print_value.zig+6-6
......@@ -20,7 +20,7 @@ pub const FormatContext = struct {
2020 depth: u8,
2121};
2222
23pub fn formatSema(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
23pub fn formatSema(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt: []const u8) std.io.Writer.Error!void {
2424 const sema = ctx.opt_sema.?;
2525 comptime std.debug.assert(fmt.len == 0);
2626 return print(ctx.val, bw, ctx.depth, ctx.pt, sema) catch |err| switch (err) {
......@@ -31,7 +31,7 @@ pub fn formatSema(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt:
3131 };
3232}
3333
34pub fn format(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void {
34pub fn format(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt: []const u8) std.io.Writer.Error!void {
3535 std.debug.assert(ctx.opt_sema == null);
3636 comptime std.debug.assert(fmt.len == 0);
3737 return print(ctx.val, bw, ctx.depth, ctx.pt, null) catch |err| switch (err) {
......@@ -47,7 +47,7 @@ pub fn print(
4747 level: u8,
4848 pt: Zcu.PerThread,
4949 opt_sema: ?*Sema,
50) anyerror!void {
50) std.io.Writer.Error!void {
5151 const zcu = pt.zcu;
5252 const ip = &zcu.intern_pool;
5353 switch (ip.indexToKey(val.toIntern())) {
......@@ -190,7 +190,7 @@ fn printAggregate(
190190 level: u8,
191191 pt: Zcu.PerThread,
192192 opt_sema: ?*Sema,
193) anyerror!void {
193) std.io.Writer.Error!void {
194194 if (level == 0) {
195195 if (is_ref) try bw.writeByte('&');
196196 return bw.writeAll(".{ ... }");
......@@ -276,7 +276,7 @@ fn printPtr(
276276 level: u8,
277277 pt: Zcu.PerThread,
278278 opt_sema: ?*Sema,
279) anyerror!void {
279) std.io.Writer.Error!void {
280280 const ptr = switch (pt.zcu.intern_pool.indexToKey(ptr_val.toIntern())) {
281281 .undef => return bw.writeAll("undefined"),
282282 .ptr => |ptr| ptr,
......@@ -336,7 +336,7 @@ pub fn printPtrDerivation(
336336 /// The maximum recursion depth. We can never recurse infinitely here, but the depth can be arbitrary,
337337 /// so at this depth we just write "..." to prevent stack overflow.
338338 ptr_depth: u8,
339) anyerror!Value.PointerDeriveStep {
339) std.io.Writer.Error!Value.PointerDeriveStep {
340340 const zcu = pt.zcu;
341341 const ip = &zcu.intern_pool;
342342
src/print_zir.zig+14-12
......@@ -10,7 +10,7 @@ const Zcu = @import("Zcu.zig");
1010const LazySrcLoc = Zcu.LazySrcLoc;
1111
1212/// Write human-readable, debug formatted ZIR code.
13pub fn renderAsText(gpa: Allocator, tree: ?Ast, zir: Zir, bw: *std.io.BufferedWriter) anyerror!void {
13pub fn renderAsText(gpa: Allocator, tree: ?Ast, zir: Zir, bw: *std.io.BufferedWriter) !void {
1414 var arena = std.heap.ArenaAllocator.init(gpa);
1515 defer arena.deinit();
1616
......@@ -176,11 +176,13 @@ const Writer = struct {
176176 }
177177 } = .{},
178178
179 const Error = std.io.Writer.Error;
180
179181 fn writeInstToStream(
180182 self: *Writer,
181183 stream: *std.io.BufferedWriter,
182184 inst: Zir.Inst.Index,
183 ) anyerror!void {
185 ) Error!void {
184186 const tags = self.code.instructions.items(.tag);
185187 const tag = tags[@intFromEnum(inst)];
186188 try stream.print("= {s}(", .{@tagName(tags[@intFromEnum(inst)])});
......@@ -633,7 +635,7 @@ const Writer = struct {
633635 self: *Writer,
634636 stream: *std.io.BufferedWriter,
635637 inst: Zir.Inst.Index,
636 ) anyerror!void {
638 ) Error!void {
637639 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
638640 try self.writeInstRef(stream, inst_data.operand);
639641 try stream.writeAll(") ");
......@@ -644,7 +646,7 @@ const Writer = struct {
644646 self: *Writer,
645647 stream: *std.io.BufferedWriter,
646648 inst: Zir.Inst.Index,
647 ) anyerror!void {
649 ) Error!void {
648650 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;
649651 try self.writeInstRef(stream, inst_data.operand);
650652 try stream.writeAll(") ");
......@@ -655,7 +657,7 @@ const Writer = struct {
655657 self: *Writer,
656658 stream: *std.io.BufferedWriter,
657659 inst: Zir.Inst.Index,
658 ) anyerror!void {
660 ) Error!void {
659661 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
660662 const extra = self.code.extraData(Zir.Inst.ValidateDestructure, inst_data.payload_index).data;
661663 try self.writeInstRef(stream, extra.operand);
......@@ -669,7 +671,7 @@ const Writer = struct {
669671 self: *Writer,
670672 stream: *std.io.BufferedWriter,
671673 inst: Zir.Inst.Index,
672 ) anyerror!void {
674 ) Error!void {
673675 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
674676 const extra = self.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data;
675677 try self.writeInstRef(stream, extra.ty);
......@@ -681,7 +683,7 @@ const Writer = struct {
681683 self: *Writer,
682684 stream: *std.io.BufferedWriter,
683685 inst: Zir.Inst.Index,
684 ) anyerror!void {
686 ) Error!void {
685687 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
686688 const extra = self.code.extraData(Zir.Inst.ArrayTypeSentinel, inst_data.payload_index).data;
687689 try self.writeInstRef(stream, extra.len);
......@@ -697,7 +699,7 @@ const Writer = struct {
697699 self: *Writer,
698700 stream: *std.io.BufferedWriter,
699701 inst: Zir.Inst.Index,
700 ) anyerror!void {
702 ) Error!void {
701703 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].ptr_type;
702704 const str_allowzero = if (inst_data.flags.is_allowzero) "allowzero, " else "";
703705 const str_const = if (!inst_data.flags.is_mutable) "const, " else "";
......@@ -780,7 +782,7 @@ const Writer = struct {
780782 self: *Writer,
781783 stream: *std.io.BufferedWriter,
782784 inst: Zir.Inst.Index,
783 ) anyerror!void {
785 ) Error!void {
784786 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str;
785787 const str = inst_data.get(self.code);
786788 try stream.print("\"{f}\")", .{std.zig.fmtEscapes(str)});
......@@ -1185,7 +1187,7 @@ const Writer = struct {
11851187 self: *Writer,
11861188 stream: *std.io.BufferedWriter,
11871189 inst: Zir.Inst.Index,
1188 ) anyerror!void {
1190 ) Error!void {
11891191 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].inst_node;
11901192 try self.writeInstIndex(stream, inst_data.inst);
11911193 try stream.writeAll(") ");
......@@ -2238,7 +2240,7 @@ const Writer = struct {
22382240 self: *Writer,
22392241 stream: *std.io.BufferedWriter,
22402242 inst: Zir.Inst.Index,
2241 ) anyerror!void {
2243 ) Error!void {
22422244 const src_node = self.code.instructions.items(.data)[@intFromEnum(inst)].node;
22432245 try stream.writeAll(") ");
22442246 try self.writeSrcNode(stream, src_node);
......@@ -2248,7 +2250,7 @@ const Writer = struct {
22482250 self: *Writer,
22492251 stream: *std.io.BufferedWriter,
22502252 inst: Zir.Inst.Index,
2251 ) anyerror!void {
2253 ) Error!void {
22522254 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;
22532255 const str = inst_data.get(self.code);
22542256 try stream.print("\"{f}\") ", .{std.zig.fmtEscapes(str)});
src/print_zoir.zig+6-4
......@@ -1,4 +1,4 @@
1pub fn renderToWriter(zoir: Zoir, arena: Allocator, w: *std.io.BufferedWriter) anyerror!void {
1pub fn renderToWriter(zoir: Zoir, arena: Allocator, w: *std.io.BufferedWriter) error{ WriteFailed, OutOfMemory }!void {
22 assert(!zoir.hasCompileErrors());
33
44 const bytes_per_node = comptime n: {
......@@ -37,7 +37,7 @@ pub fn renderToWriter(zoir: Zoir, arena: Allocator, w: *std.io.BufferedWriter) a
3737 .indent = 0,
3838 };
3939
40 return @errorCast(pz.renderRoot());
40 return pz.renderRoot();
4141}
4242
4343const PrintZon = struct {
......@@ -46,12 +46,14 @@ const PrintZon = struct {
4646 zoir: Zoir,
4747 indent: u32,
4848
49 fn renderRoot(pz: *PrintZon) anyerror!void {
49 const Error = std.io.Writer.Error;
50
51 fn renderRoot(pz: *PrintZon) Error!void {
5052 try pz.renderNode(.root);
5153 try pz.w.writeByte('\n');
5254 }
5355
54 fn renderNode(pz: *PrintZon, node: Zoir.Node.Index) anyerror!void {
56 fn renderNode(pz: *PrintZon, node: Zoir.Node.Index) Error!void {
5557 const zoir = pz.zoir;
5658 try pz.w.print("%{d} = ", .{@intFromEnum(node)});
5759 switch (node.get(zoir)) {