Skip to content
Merged
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
3 changes: 2 additions & 1 deletion lib/std/zig/Ast/Render.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,8 @@ fn renderStructInit(
const init_token = tree.firstToken(field_init);
try renderToken(r, init_token - 3, .none); // .
try renderIdentifier(r, init_token - 2, .space, .eagerly_unquote); // name
try renderToken(r, init_token - 1, .space); // =
const space_after_equal: Space = if (tree.nodeTag(field_init) == .multiline_string_literal) .none else .space;
try renderToken(r, init_token - 1, space_after_equal); // =
try renderExpressionFixup(r, field_init, .comma_space);
}
}
Expand Down
10 changes: 10 additions & 0 deletions lib/std/zig/parser_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5719,6 +5719,16 @@ test "zig fmt: no space before newline before multiline string" {
\\ ,
\\ };
\\ _ = s2;
\\ const s3 = .{ .text =
\\ \\hello
\\ \\world
\\ , .comment = "test" };
\\ _ = s3;
\\ const s4 = .{ .comment = "test", .text =
\\ \\hello
\\ \\world
\\ };
\\ _ = s4;
\\}
\\
);
Expand Down
24 changes: 12 additions & 12 deletions test/link/elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ fn testComdatElimination(b: *Build, opts: Options) *Step {
fn testCommentString(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "comment-string", opts);

const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
\\pub fn main() void {}
});

Expand All @@ -495,7 +495,7 @@ fn testCommentString(b: *Build, opts: Options) *Step {
fn testCommentStringStaticLib(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "comment-string-static-lib", opts);

const lib = addStaticLibrary(b, opts, .{ .name = "lib", .zig_source_bytes =
const lib = addStaticLibrary(b, opts, .{ .name = "lib", .zig_source_bytes =
\\export fn foo() void {}
});

Expand Down Expand Up @@ -866,7 +866,7 @@ fn testDsoUndef(b: *Build, opts: Options) *Step {
fn testEmitRelocatable(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "emit-relocatable", opts);

const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
\\const std = @import("std");
\\extern var bar: i32;
\\export fn foo() i32 {
Expand All @@ -878,7 +878,7 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
});
a_o.root_module.link_libc = true;

const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
\\#include <stdio.h>
\\int bar = 42;
\\void printBar() {
Expand All @@ -891,7 +891,7 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
c_o.root_module.addObject(a_o);
c_o.root_module.addObject(b_o);

const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
\\const std = @import("std");
\\extern fn printFoo() void;
\\extern fn printBar() void;
Expand Down Expand Up @@ -1925,7 +1925,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
});
g_o.root_module.link_libc = true;

const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
\\#include <stdio.h>
\\__attribute__((destructor)) void fini2() { printf("8"); }
});
Expand Down Expand Up @@ -2447,7 +2447,7 @@ fn testLinkingZig(b: *Build, opts: Options) *Step {
fn testLinksection(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "linksection", opts);

const obj = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
const obj = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
\\export var test_global: u32 linksection(".TestGlobal") = undefined;
\\export fn testFn() linksection(".TestFn") callconv(.c) void {
\\ TestGenericFn("A").f();
Expand Down Expand Up @@ -2540,7 +2540,7 @@ fn testMergeStrings(b: *Build, opts: Options) *Step {
fn testMergeStrings2(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "merge-strings2", opts);

const obj1 = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
const obj1 = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
\\const std = @import("std");
\\export fn foo() void {
\\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 };
Expand All @@ -2549,7 +2549,7 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {
\\}
});

const obj2 = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
const obj2 = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
\\const std = @import("std");
\\extern fn foo() void;
\\pub fn main() void {
Expand Down Expand Up @@ -2797,7 +2797,7 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
,
});
obj2.root_module.link_libcpp = true;
const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
\\#include <iostream>
\\#include <stdexcept>
\\extern int try_again();
Expand Down Expand Up @@ -2909,7 +2909,7 @@ fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "relocatable-merge-strings", opts);

const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
\\.section .rodata.str1.1,"aMS",@progbits,1
\\val1:
\\.ascii "Hello \0"
Expand Down Expand Up @@ -3075,7 +3075,7 @@ fn testStrip(b: *Build, opts: Options) *Step {
fn testThunks(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "thunks", opts);

const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
\\void foo();
\\__attribute__((section(".bar"))) void bar() {
\\ return foo();
Expand Down
Loading