Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions lib/std/Build/WebServer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -672,20 +672,23 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
return base_path.join(arena, bin_name);
}

pub fn updateTimeReportCompile(ws: *WebServer, opts: struct {
compile: *Build.Step.Compile,
pub fn updateTimeReportCompile(
ws: *WebServer,
opts: struct {
compile: *Build.Step.Compile,

use_llvm: bool,
stats: abi.time_report.CompileResult.Stats,
ns_total: u64,
use_llvm: bool,
stats: abi.time_report.CompileResult.Stats,
ns_total: u64,

llvm_pass_timings_len: u32,
files_len: u32,
decls_len: u32,
llvm_pass_timings_len: u32,
files_len: u32,
decls_len: u32,

/// The trailing data of `abi.time_report.CompileResult`, except the step name.
trailing: []const u8,
}) void {
/// The trailing data of `abi.time_report.CompileResult`, except the step name.
trailing: []const u8,
},
) void {
const gpa = ws.gpa;

const step_idx: u32 = for (ws.all_steps, 0..) |s, i| {
Expand Down
21 changes: 13 additions & 8 deletions lib/std/time/epoch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,19 @@ pub const EpochSeconds = struct {
}
};

fn testEpoch(secs: u64, expected_year_day: YearAndDay, expected_month_day: MonthAndDay, expected_day_seconds: struct {
/// 0 to 23
hours_into_day: u5,
/// 0 to 59
minutes_into_hour: u6,
/// 0 to 59
seconds_into_minute: u6,
}) !void {
fn testEpoch(
secs: u64,
expected_year_day: YearAndDay,
expected_month_day: MonthAndDay,
expected_day_seconds: struct {
/// 0 to 23
hours_into_day: u5,
/// 0 to 59
minutes_into_hour: u6,
/// 0 to 59
seconds_into_minute: u6,
},
) !void {
const epoch_seconds = EpochSeconds{ .secs = secs };
const epoch_day = epoch_seconds.getEpochDay();
const day_seconds = epoch_seconds.getDaySeconds();
Expand Down
13 changes: 12 additions & 1 deletion lib/std/zig/Ast/Render.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,18 @@ fn renderFnProto(r: *Render, fn_proto: Ast.full.FnProto, space: Space) Error!voi
// The params list is a sparse set that does *not* include anytype or ... parameters.

const trailing_comma = tree.tokenTag(rparen - 1) == .comma;
if (!trailing_comma and !hasComment(tree, lparen, rparen)) {

// Check if there are any doc comment tokens between lparen and rparen
var has_doc_comment = false;
for (lparen..rparen) |i| {
const token: Ast.TokenIndex = @intCast(i);
if (tree.tokenTag(token) == .doc_comment) {
has_doc_comment = true;
break;
}
}

if (!trailing_comma and !hasComment(tree, lparen, rparen) and !has_doc_comment) {
// Render all on one line, no trailing comma.
try renderToken(r, lparen, .none); // (

Expand Down
18 changes: 18 additions & 0 deletions lib/std/zig/parser_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,24 @@ test "zig fmt: doc comments on param decl" {
);
}

test "zig fmt: doc comments on param decl without trailing comma" {
try testTransform(
\\fn f(
\\ /// comment
\\ x: u32,
\\ y: u32
\\) void {}
\\
,
\\fn f(
\\ /// comment
\\ x: u32,
\\ y: u32,
\\) void {}
\\
);
}

test "zig fmt: aligned struct field" {
try testCanonical(
\\pub const S = struct {
Expand Down