authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-12-31 09:54:41+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-12-31 09:56:21+00:00
log106df881d3a3fe3b744f0563b99cff88d7ef6549
treefd7830fb82c95f52a79fd9984af4caacb090f3fe
parent9ff80d7950a720cf80294ceaec54cc33d22f8871
signaturelock-open Commit is signed but in an unrecognized format.

Sema: add doc comments for comptime reason types


1 files changed, 8 insertions(+), 2 deletions(-)

src/Sema.zig+8-2
...@@ -845,11 +845,15 @@ pub const Block = struct {...@@ -845,11 +845,15 @@ pub const Block = struct {
845 }845 }
846};846};
847847
848/// Represents the reason we are resolving a value or evaluating code at comptime.
849/// Most reasons are represented by a `std.zig.SimpleComptimeReason`, which provides a plain message.
848const ComptimeReason = union(enum) {850const ComptimeReason = union(enum) {
849 /// Evaluating at comptime for a reason in the `std.zig.SimpleComptimeReason` enum.851 /// Evaluating at comptime for a reason in the `std.zig.SimpleComptimeReason` enum.
850 simple: std.zig.SimpleComptimeReason,852 simple: std.zig.SimpleComptimeReason,
851853
852 /// Evaluating at comptime because of a comptime-only type.854 /// Evaluating at comptime because of a comptime-only type. This field is separate so that
855 /// the type in question can be included in the error message. AstGen could never emit this
856 /// reason, because it knows nothing of types.
853 /// The format string looks like "foo '{}' bar", where "{}" is the comptime-only type.857 /// The format string looks like "foo '{}' bar", where "{}" is the comptime-only type.
854 /// We will then explain why this type is comptime-only.858 /// We will then explain why this type is comptime-only.
855 comptime_only: struct {859 comptime_only: struct {
...@@ -885,12 +889,14 @@ const ComptimeReason = union(enum) {...@@ -885,12 +889,14 @@ const ComptimeReason = union(enum) {
885 }889 }
886};890};
887891
892/// Represents the reason a `Block` is being evaluated at comptime.
888const BlockComptimeReason = union(enum) {893const BlockComptimeReason = union(enum) {
889 /// This block inherits being comptime-only from the `inlining` call site.894 /// This block inherits being comptime-only from the `inlining` call site.
890 inlining_parent,895 inlining_parent,
891896
892 /// This block is comptime for the given reason at the given source location.897 /// Comptime evaluation began somewhere in the current function for a given `ComptimeReason`.
893 reason: struct {898 reason: struct {
899 /// The source location which this reason originates from. `r` is reported here.
894 src: LazySrcLoc,900 src: LazySrcLoc,
895 r: ComptimeReason,901 r: ComptimeReason,
896 },902 },