mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:24:49 +01:00
fix: inline to propagate comptime-ness to call site
See conversation at: https://ziggit.dev/t/why-is-the-comptime-keyword-needed-in-this-inline-for-loop-condition/14090
This commit is contained in:
parent
2d88a5a103
commit
d2db1d45f1
2 changed files with 3 additions and 2 deletions
|
|
@ -42,6 +42,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def
|
||||||
/// The result array is in the same order as the input.
|
/// The result array is in the same order as the input.
|
||||||
pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumField) []const E {
|
pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumField) []const E {
|
||||||
comptime {
|
comptime {
|
||||||
|
@setEvalBranchQuota(@typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion);
|
||||||
var result: [fields.len]E = undefined;
|
var result: [fields.len]E = undefined;
|
||||||
for (&result, fields) |*r, f| {
|
for (&result, fields) |*r, f| {
|
||||||
r.* = @enumFromInt(f.value);
|
r.* = @enumFromInt(f.value);
|
||||||
|
|
@ -53,7 +54,7 @@ pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumFi
|
||||||
|
|
||||||
/// Returns the set of all named values in the given enum, in
|
/// Returns the set of all named values in the given enum, in
|
||||||
/// declaration order.
|
/// declaration order.
|
||||||
pub fn values(comptime E: type) []const E {
|
pub inline fn values(comptime E: type) []const E {
|
||||||
return comptime valuesFromFields(E, @typeInfo(E).@"enum".fields);
|
return comptime valuesFromFields(E, @typeInfo(E).@"enum".fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177113,7 +177113,7 @@ fn airBr(self: *CodeGen, inst: Air.Inst.Index) !void {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
|
fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
|
||||||
@setEvalBranchQuota(1_100);
|
@setEvalBranchQuota(1_100 + @typeInfo(Mir.Inst.Fixes).@"enum".fields.len);
|
||||||
const pt = self.pt;
|
const pt = self.pt;
|
||||||
const zcu = pt.zcu;
|
const zcu = pt.zcu;
|
||||||
const unwrapped_asm = self.air.unwrapAsm(inst);
|
const unwrapped_asm = self.air.unwrapAsm(inst);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue