authorgravatar for fir.damien@gmail.comDamien Firmenich <fir.damien@gmail.com> 2022-04-05 17:08:33+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-04-05 18:08:33+03:00
log5fafcc2b629e2ff00755b2bf45e903590f04aa9f
tree143bde0c47f71678a3d7f340073f519f7c41b7d2
parent95a87e88fac3fc563ac3baaf4eb8027341f4131e
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

zig fmt: remove trailing whitespace on doc comments

Fixes #11353 The renderer treats comments and doc comments differently since doc comments are parsed into the Ast. This commit adds a check after getting the text for the doc comment and trims whitespace at the end before rendering. The `a = 0,` in the test is here to avoid a ParseError while parsing the test.

22 files changed, 74 insertions(+), 46 deletions(-)

lib/std/Thread/Futex.zig+2-2
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1//! Futex is a mechanism used to block (`wait`) and unblock (`wake`) threads using a 32bit memory address as hints.1//! Futex is a mechanism used to block (`wait`) and unblock (`wake`) threads using a 32bit memory address as hints.
2//! Blocking a thread is acknowledged only if the 32bit memory address is equal to a given value.2//! Blocking a thread is acknowledged only if the 32bit memory address is equal to a given value.
3//! This check helps avoid block/unblock deadlocks which occur if a `wake()` happens before a `wait()`.3//! This check helps avoid block/unblock deadlocks which occur if a `wake()` happens before a `wait()`.
4//! Using Futex, other Thread synchronization primitives can be built which efficiently wait for cross-thread events or signals. 4//! Using Futex, other Thread synchronization primitives can be built which efficiently wait for cross-thread events or signals.
55
6const std = @import("../std.zig");6const std = @import("../std.zig");
7const builtin = @import("builtin");7const builtin = @import("builtin");
...@@ -20,7 +20,7 @@ const spinLoopHint = std.atomic.spinLoopHint;...@@ -20,7 +20,7 @@ const spinLoopHint = std.atomic.spinLoopHint;
20/// - The value at `ptr` is no longer equal to `expect`.20/// - The value at `ptr` is no longer equal to `expect`.
21/// - The caller is unblocked by a matching `wake()`.21/// - The caller is unblocked by a matching `wake()`.
22/// - The caller is unblocked spuriously by an arbitrary internal signal.22/// - The caller is unblocked spuriously by an arbitrary internal signal.
23/// 23///
24/// If `timeout` is provided, and the caller is blocked for longer than `timeout` nanoseconds`, `error.TimedOut` is returned.24/// If `timeout` is provided, and the caller is blocked for longer than `timeout` nanoseconds`, `error.TimedOut` is returned.
25///25///
26/// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically26/// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically
lib/std/compress/deflate/compressor.zig+1-1
...@@ -219,7 +219,7 @@ const CompressorOptions = struct {...@@ -219,7 +219,7 @@ const CompressorOptions = struct {
219///219///
220/// `dictionary` is optional and initializes the new `Compressor` with a preset dictionary.220/// `dictionary` is optional and initializes the new `Compressor` with a preset dictionary.
221/// The returned Compressor behaves as if the dictionary had been written to it without producing221/// The returned Compressor behaves as if the dictionary had been written to it without producing
222/// any compressed output. The compressed data written to hm_bw can only be decompressed by a 222/// any compressed output. The compressed data written to hm_bw can only be decompressed by a
223/// Decompressor initialized with the same dictionary.223/// Decompressor initialized with the same dictionary.
224///224///
225/// The compressed data will be passed to the provided `writer`, see `writer()` and `write()`.225/// The compressed data will be passed to the provided `writer`, see `writer()` and `write()`.
lib/std/crypto/argon2.zig+14-14
...@@ -34,18 +34,18 @@ const max_hash_len = 64;...@@ -34,18 +34,18 @@ const max_hash_len = 64;
3434
35/// Argon2 type35/// Argon2 type
36pub const Mode = enum {36pub const Mode = enum {
37 /// Argon2d is faster and uses data-depending memory access, which makes it highly resistant 37 /// Argon2d is faster and uses data-depending memory access, which makes it highly resistant
38 /// against GPU cracking attacks and suitable for applications with no threats from side-channel 38 /// against GPU cracking attacks and suitable for applications with no threats from side-channel
39 /// timing attacks (eg. cryptocurrencies).39 /// timing attacks (eg. cryptocurrencies).
40 argon2d,40 argon2d,
4141
42 /// Argon2i instead uses data-independent memory access, which is preferred for password 42 /// Argon2i instead uses data-independent memory access, which is preferred for password
43 /// hashing and password-based key derivation, but it is slower as it makes more passes over 43 /// hashing and password-based key derivation, but it is slower as it makes more passes over
44 /// the memory to protect from tradeoff attacks.44 /// the memory to protect from tradeoff attacks.
45 argon2i,45 argon2i,
4646
47 /// Argon2id is a hybrid of Argon2i and Argon2d, using a combination of data-depending and 47 /// Argon2id is a hybrid of Argon2i and Argon2d, using a combination of data-depending and
48 /// data-independent memory accesses, which gives some of Argon2i's resistance to side-channel 48 /// data-independent memory accesses, which gives some of Argon2i's resistance to side-channel
49 /// cache timing attacks and much of Argon2d's resistance to GPU cracking attacks.49 /// cache timing attacks and much of Argon2d's resistance to GPU cracking attacks.
50 argon2id,50 argon2id,
51};51};
...@@ -54,7 +54,7 @@ pub const Mode = enum {...@@ -54,7 +54,7 @@ pub const Mode = enum {
54pub const Params = struct {54pub const Params = struct {
55 const Self = @This();55 const Self = @This();
5656
57 /// A [t]ime cost, which defines the amount of computation realized and therefore the execution 57 /// A [t]ime cost, which defines the amount of computation realized and therefore the execution
58 /// time, given in number of iterations.58 /// time, given in number of iterations.
59 t: u32,59 t: u32,
6060
...@@ -64,16 +64,16 @@ pub const Params = struct {...@@ -64,16 +64,16 @@ pub const Params = struct {
64 /// A [p]arallelism degree, which defines the number of parallel threads.64 /// A [p]arallelism degree, which defines the number of parallel threads.
65 p: u24,65 p: u24,
6666
67 /// The [secret] parameter, which is used for keyed hashing. This allows a secret key to be input 67 /// The [secret] parameter, which is used for keyed hashing. This allows a secret key to be input
68 /// at hashing time (from some external location) and be folded into the value of the hash. This 68 /// at hashing time (from some external location) and be folded into the value of the hash. This
69 /// means that even if your salts and hashes are compromised, an attacker cannot brute-force to 69 /// means that even if your salts and hashes are compromised, an attacker cannot brute-force to
70 /// find the password without the key.70 /// find the password without the key.
71 secret: ?[]const u8 = null,71 secret: ?[]const u8 = null,
7272
73 /// The [ad] parameter, which is used to fold any additional data into the hash value. Functionally, 73 /// The [ad] parameter, which is used to fold any additional data into the hash value. Functionally,
74 /// this behaves almost exactly like the secret or salt parameters; the ad parameter is folding 74 /// this behaves almost exactly like the secret or salt parameters; the ad parameter is folding
75 /// into the value of the hash. However, this parameter is used for different data. The salt 75 /// into the value of the hash. However, this parameter is used for different data. The salt
76 /// should be a random string stored alongside your password. The secret should be a random key 76 /// should be a random string stored alongside your password. The secret should be a random key
77 /// only usable at hashing time. The ad is for any other data.77 /// only usable at hashing time. The ad is for any other data.
78 ad: ?[]const u8 = null,78 ad: ?[]const u8 = null,
7979
lib/std/crypto/scrypt.zig+2-2
...@@ -131,7 +131,7 @@ pub const Params = struct {...@@ -131,7 +131,7 @@ pub const Params = struct {
131 r: u30,131 r: u30,
132132
133 /// The [p]arallelization parameter.133 /// The [p]arallelization parameter.
134 /// A large value of [p] can be used to increase the computational cost of scrypt without 134 /// A large value of [p] can be used to increase the computational cost of scrypt without
135 /// increasing the memory usage.135 /// increasing the memory usage.
136 p: u30,136 p: u30,
137137
...@@ -326,7 +326,7 @@ const crypt_format = struct {...@@ -326,7 +326,7 @@ const crypt_format = struct {
326 try out.writeAll(hash_str);326 try out.writeAll(hash_str);
327 }327 }
328328
329 /// Custom codec that maps 6 bits into 8 like regular Base64, but uses its own alphabet, 329 /// Custom codec that maps 6 bits into 8 like regular Base64, but uses its own alphabet,
330 /// encodes bits in little-endian, and can also encode integers.330 /// encodes bits in little-endian, and can also encode integers.
331 fn CustomB64Codec(comptime map: [64]u8) type {331 fn CustomB64Codec(comptime map: [64]u8) type {
332 return struct {332 return struct {
lib/std/math.zig+1-1
...@@ -437,7 +437,7 @@ test "max3" {...@@ -437,7 +437,7 @@ test "max3" {
437 try testing.expect(max3(@as(i32, 2), @as(i32, 1), @as(i32, 0)) == 2);437 try testing.expect(max3(@as(i32, 2), @as(i32, 1), @as(i32, 0)) == 2);
438}438}
439439
440/// Limit val to the inclusive range [lower, upper]. 440/// Limit val to the inclusive range [lower, upper].
441pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) {441pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) {
442 assert(lower <= upper);442 assert(lower <= upper);
443 return max(lower, min(val, upper));443 return max(lower, min(val, upper));
lib/std/math/big/int.zig+2-2
...@@ -1750,8 +1750,8 @@ pub const Mutable = struct {...@@ -1750,8 +1750,8 @@ pub const Mutable = struct {
1750 /// Read the value of `x` from `buffer`1750 /// Read the value of `x` from `buffer`
1751 /// Asserts that `buffer`, `abi_size`, and `bit_count` are large enough to store the value.1751 /// Asserts that `buffer`, `abi_size`, and `bit_count` are large enough to store the value.
1752 ///1752 ///
1753 /// The contents of `buffer` are interpreted as if they were the contents of 1753 /// The contents of `buffer` are interpreted as if they were the contents of
1754 /// @ptrCast(*[abi_size]const u8, &x). Byte ordering is determined by `endian` 1754 /// @ptrCast(*[abi_size]const u8, &x). Byte ordering is determined by `endian`
1755 /// and any required padding bits are expected on the MSB end.1755 /// and any required padding bits are expected on the MSB end.
1756 pub fn readTwosComplement(1756 pub fn readTwosComplement(
1757 x: *Mutable,1757 x: *Mutable,
lib/std/mem/Allocator.zig+2-2
...@@ -50,7 +50,7 @@ pub const VTable = struct {...@@ -50,7 +50,7 @@ pub const VTable = struct {
50 else => *const resizeProto,50 else => *const resizeProto,
51 },51 },
5252
53 /// Free and invalidate a buffer. `buf.len` must equal the most recent length returned by `alloc` or `resize`. 53 /// Free and invalidate a buffer. `buf.len` must equal the most recent length returned by `alloc` or `resize`.
54 /// `buf_align` must equal the same value that was passed as the `ptr_align` parameter to the original `alloc` call.54 /// `buf_align` must equal the same value that was passed as the `ptr_align` parameter to the original `alloc` call.
55 ///55 ///
56 /// `ret_addr` is optionally provided as the first return address of the allocation call stack.56 /// `ret_addr` is optionally provided as the first return address of the allocation call stack.
...@@ -603,7 +603,7 @@ test "allocBytes non-zero len_align" {...@@ -603,7 +603,7 @@ test "allocBytes non-zero len_align" {
603/// allocation could not be granted this function returns `error.OutOfMemory`.603/// allocation could not be granted this function returns `error.OutOfMemory`.
604/// When the size/alignment is less than or equal to the previous allocation,604/// When the size/alignment is less than or equal to the previous allocation,
605/// this function returns `error.OutOfMemory` when the allocator decides the client605/// this function returns `error.OutOfMemory` when the allocator decides the client
606/// would be better off keeping the extra alignment/size. 606/// would be better off keeping the extra alignment/size.
607/// Clients will call `resizeFn` when they require the allocator to track a new alignment/size,607/// Clients will call `resizeFn` when they require the allocator to track a new alignment/size,
608/// and so this function should only return success when the allocator considers608/// and so this function should only return success when the allocator considers
609/// the reallocation desirable from the allocator's perspective.609/// the reallocation desirable from the allocator's perspective.
lib/std/os.zig+2-2
...@@ -1441,7 +1441,7 @@ var wasi_cwd = if (builtin.os.tag == .wasi and !builtin.link_libc) struct {...@@ -1441,7 +1441,7 @@ var wasi_cwd = if (builtin.os.tag == .wasi and !builtin.link_libc) struct {
1441/// Note that `cwd_init` corresponds to a Preopen directory, not necessarily1441/// Note that `cwd_init` corresponds to a Preopen directory, not necessarily
1442/// a POSIX path. For example, "." matches a Preopen provided with `--dir=.`1442/// a POSIX path. For example, "." matches a Preopen provided with `--dir=.`
1443///1443///
1444/// This must be called before using any relative or absolute paths with `std.os` 1444/// This must be called before using any relative or absolute paths with `std.os`
1445/// functions, if you are on WASI without linking libc.1445/// functions, if you are on WASI without linking libc.
1446///1446///
1447/// `alloc` must not be a temporary or leak-detecting allocator, since `std.os`1447/// `alloc` must not be a temporary or leak-detecting allocator, since `std.os`
...@@ -1475,7 +1475,7 @@ pub fn initPreopensWasi(alloc: Allocator, cwd_init: ?[]const u8) !void {...@@ -1475,7 +1475,7 @@ pub fn initPreopensWasi(alloc: Allocator, cwd_init: ?[]const u8) !void {
14751475
1476/// Resolve a relative or absolute path to an handle (`fd_t`) and a relative subpath.1476/// Resolve a relative or absolute path to an handle (`fd_t`) and a relative subpath.
1477///1477///
1478/// For absolute paths, this automatically searches among available Preopens to find 1478/// For absolute paths, this automatically searches among available Preopens to find
1479/// a match. For relative paths, it uses the "emulated" CWD.1479/// a match. For relative paths, it uses the "emulated" CWD.
1480pub fn resolvePathWasi(path: []const u8, out_buffer: *[MAX_PATH_BYTES]u8) !RelativePathWasi {1480pub fn resolvePathWasi(path: []const u8, out_buffer: *[MAX_PATH_BYTES]u8) !RelativePathWasi {
1481 // Note: Due to WASI's "sandboxed" file handles, operations with this RelativePathWasi1481 // Note: Due to WASI's "sandboxed" file handles, operations with this RelativePathWasi
lib/std/os/uefi/pool_allocator.zig+1-1
...@@ -90,7 +90,7 @@ const pool_allocator_vtable = Allocator.VTable{...@@ -90,7 +90,7 @@ const pool_allocator_vtable = Allocator.VTable{
90 .free = UefiPoolAllocator.free,90 .free = UefiPoolAllocator.free,
91};91};
9292
93/// Asserts allocations are 8 byte aligned and calls `boot_services.allocatePool`. 93/// Asserts allocations are 8 byte aligned and calls `boot_services.allocatePool`.
94pub const raw_pool_allocator = Allocator{94pub const raw_pool_allocator = Allocator{
95 .ptr = undefined,95 .ptr = undefined,
96 .vtable = &raw_pool_allocator_table,96 .vtable = &raw_pool_allocator_table,
lib/std/os/uefi/tables/boot_services.zig+1-1
...@@ -67,7 +67,7 @@ pub const BootServices = extern struct {...@@ -67,7 +67,7 @@ pub const BootServices = extern struct {
67 /// Reinstalls a protocol interface on a device handle67 /// Reinstalls a protocol interface on a device handle
68 reinstallProtocolInterface: fn (handle: Handle, protocol: *align(8) const Guid, old_interface: *anyopaque, new_interface: *anyopaque) callconv(.C) Status,68 reinstallProtocolInterface: fn (handle: Handle, protocol: *align(8) const Guid, old_interface: *anyopaque, new_interface: *anyopaque) callconv(.C) Status,
6969
70 /// Removes a protocol interface from a device handle. Usage of 70 /// Removes a protocol interface from a device handle. Usage of
71 /// uninstallMultipleProtocolInterfaces is recommended over this.71 /// uninstallMultipleProtocolInterfaces is recommended over this.
72 uninstallProtocolInterface: fn (handle: Handle, protocol: *align(8) const Guid, interface: *anyopaque) callconv(.C) Status,72 uninstallProtocolInterface: fn (handle: Handle, protocol: *align(8) const Guid, interface: *anyopaque) callconv(.C) Status,
7373
lib/std/packed_int_array.zig+1-1
...@@ -182,7 +182,7 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: Endian) type {...@@ -182,7 +182,7 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: Endian) type {
182182
183/// Creates a bit-packed array of `Int`. Non-byte-multiple integers183/// Creates a bit-packed array of `Int`. Non-byte-multiple integers
184/// will take up less memory in PackedIntArray than in a normal array.184/// will take up less memory in PackedIntArray than in a normal array.
185/// Elements are packed using native endianess and without storing any 185/// Elements are packed using native endianess and without storing any
186/// meta data. PackedArray(i3, 8) will occupy exactly 3 bytes186/// meta data. PackedArray(i3, 8) will occupy exactly 3 bytes
187/// of memory.187/// of memory.
188pub fn PackedIntArray(comptime Int: type, comptime int_count: usize) type {188pub fn PackedIntArray(comptime Int: type, comptime int_count: usize) type {
lib/std/simd.zig+1-1
...@@ -298,7 +298,7 @@ test "vector searching" {...@@ -298,7 +298,7 @@ test "vector searching" {
298pub fn prefixScanWithFunc(298pub fn prefixScanWithFunc(
299 comptime hop: isize,299 comptime hop: isize,
300 vec: anytype,300 vec: anytype,
301 /// The error type that `func` might return. Set this to `void` if `func` doesn't return an error union. 301 /// The error type that `func` might return. Set this to `void` if `func` doesn't return an error union.
302 comptime ErrorType: type,302 comptime ErrorType: type,
303 comptime func: fn (@TypeOf(vec), @TypeOf(vec)) if (ErrorType == void) @TypeOf(vec) else ErrorType!@TypeOf(vec),303 comptime func: fn (@TypeOf(vec), @TypeOf(vec)) if (ErrorType == void) @TypeOf(vec) else ErrorType!@TypeOf(vec),
304 /// When one operand of the operation performed by `func` is this value, the result must equal the other operand.304 /// When one operand of the operation performed by `func` is this value, the result must equal the other operand.
lib/std/time.zig+3-3
...@@ -147,7 +147,7 @@ pub const s_per_day = s_per_hour * 24;...@@ -147,7 +147,7 @@ pub const s_per_day = s_per_hour * 24;
147pub const s_per_week = s_per_day * 7;147pub const s_per_week = s_per_day * 7;
148148
149/// An Instant represents a timestamp with respect to the currently149/// An Instant represents a timestamp with respect to the currently
150/// executing program that ticks during suspend and can be used to 150/// executing program that ticks during suspend and can be used to
151/// record elapsed time unlike `nanoTimestamp`.151/// record elapsed time unlike `nanoTimestamp`.
152///152///
153/// It tries to sample the system's fastest and most precise timer available.153/// It tries to sample the system's fastest and most precise timer available.
...@@ -256,7 +256,7 @@ pub const Instant = struct {...@@ -256,7 +256,7 @@ pub const Instant = struct {
256///256///
257/// Monotonicity is ensured by saturating on the most previous sample.257/// Monotonicity is ensured by saturating on the most previous sample.
258/// This means that while timings reported are monotonic,258/// This means that while timings reported are monotonic,
259/// they're not guaranteed to tick at a steady rate as this is up to the underlying system. 259/// they're not guaranteed to tick at a steady rate as this is up to the underlying system.
260pub const Timer = struct {260pub const Timer = struct {
261 started: Instant,261 started: Instant,
262 previous: Instant,262 previous: Instant,
...@@ -290,7 +290,7 @@ pub const Timer = struct {...@@ -290,7 +290,7 @@ pub const Timer = struct {
290 return current.since(self.started);290 return current.since(self.started);
291 }291 }
292292
293 /// Returns an Instant sampled at the callsite that is 293 /// Returns an Instant sampled at the callsite that is
294 /// guaranteed to be monotonic with respect to the timer's starting point.294 /// guaranteed to be monotonic with respect to the timer's starting point.
295 fn sample(self: *Timer) Instant {295 fn sample(self: *Timer) Instant {
296 const current = Instant.now() catch unreachable;296 const current = Instant.now() catch unreachable;
lib/std/x/net/tcp.zig+1-1
...@@ -186,7 +186,7 @@ pub const Client = struct {...@@ -186,7 +186,7 @@ pub const Client = struct {
186186
187 /// Have keep-alive messages be sent periodically. The timing in which keep-alive messages are sent are187 /// Have keep-alive messages be sent periodically. The timing in which keep-alive messages are sent are
188 /// dependant on operating system settings. It returns `error.UnsupportedSocketOption` if the host does188 /// dependant on operating system settings. It returns `error.UnsupportedSocketOption` if the host does
189 /// not support periodically sending keep-alive messages on connection-oriented sockets. 189 /// not support periodically sending keep-alive messages on connection-oriented sockets.
190 pub fn setKeepAlive(self: Client, enabled: bool) !void {190 pub fn setKeepAlive(self: Client, enabled: bool) !void {
191 return self.socket.setKeepAlive(enabled);191 return self.socket.setKeepAlive(enabled);
192 }192 }
lib/std/x/os/socket_posix.zig+3-3
...@@ -205,7 +205,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -205,7 +205,7 @@ pub fn Mixin(comptime Socket: type) type {
205205
206 /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive206 /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive
207 /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if207 /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if
208 /// the host does not support periodically sending keep-alive messages on connection-oriented sockets. 208 /// the host does not support periodically sending keep-alive messages on connection-oriented sockets.
209 pub fn setKeepAlive(self: Socket, enabled: bool) !void {209 pub fn setKeepAlive(self: Socket, enabled: bool) !void {
210 if (@hasDecl(os.SO, "KEEPALIVE")) {210 if (@hasDecl(os.SO, "KEEPALIVE")) {
211 return self.setOption(os.SOL.SOCKET, os.SO.KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));211 return self.setOption(os.SOL.SOCKET, os.SO.KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));
...@@ -243,7 +243,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -243,7 +243,7 @@ pub fn Mixin(comptime Socket: type) type {
243243
244 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is244 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
245 /// set on a non-blocking socket.245 /// set on a non-blocking socket.
246 /// 246 ///
247 /// Set a timeout on the socket that is to occur if no messages are successfully written247 /// Set a timeout on the socket that is to occur if no messages are successfully written
248 /// to its bound destination after a specified number of milliseconds. A subsequent write248 /// to its bound destination after a specified number of milliseconds. A subsequent write
249 /// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded.249 /// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded.
...@@ -258,7 +258,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -258,7 +258,7 @@ pub fn Mixin(comptime Socket: type) type {
258258
259 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is259 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
260 /// set on a non-blocking socket.260 /// set on a non-blocking socket.
261 /// 261 ///
262 /// Set a timeout on the socket that is to occur if no messages are successfully read262 /// Set a timeout on the socket that is to occur if no messages are successfully read
263 /// from its bound destination after a specified number of milliseconds. A subsequent263 /// from its bound destination after a specified number of milliseconds. A subsequent
264 /// read from the socket will thereafter return `error.WouldBlock` should the timeout be264 /// read from the socket will thereafter return `error.WouldBlock` should the timeout be
lib/std/zig/parser_test.zig+22
...@@ -4712,6 +4712,28 @@ test "zig fmt: space after top level doc comment" {...@@ -4712,6 +4712,28 @@ test "zig fmt: space after top level doc comment" {
4712 );4712 );
4713}4713}
47144714
4715test "zig fmt: remove trailing whitespace after container doc comment" {
4716 try testTransform(
4717 \\//! top level doc comment
4718 \\
4719 ,
4720 \\//! top level doc comment
4721 \\
4722 );
4723}
4724
4725test "zig fmt: remove trailing whitespace after doc comment" {
4726 try testTransform(
4727 \\/// doc comment
4728 \\a = 0,
4729 \\
4730 ,
4731 \\/// doc comment
4732 \\a = 0,
4733 \\
4734 );
4735}
4736
4715test "zig fmt: for loop with ptr payload and index" {4737test "zig fmt: for loop with ptr payload and index" {
4716 try testCanonical(4738 try testCanonical(
4717 \\test {4739 \\test {
lib/std/zig/render.zig+9-3
...@@ -2506,9 +2506,15 @@ fn renderContainerDocComments(ais: *Ais, tree: Ast, start_token: Ast.TokenIndex)...@@ -2506,9 +2506,15 @@ fn renderContainerDocComments(ais: *Ais, tree: Ast, start_token: Ast.TokenIndex)
25062506
2507fn tokenSliceForRender(tree: Ast, token_index: Ast.TokenIndex) []const u8 {2507fn tokenSliceForRender(tree: Ast, token_index: Ast.TokenIndex) []const u8 {
2508 var ret = tree.tokenSlice(token_index);2508 var ret = tree.tokenSlice(token_index);
2509 if (tree.tokens.items(.tag)[token_index] == .multiline_string_literal_line) {2509 switch (tree.tokens.items(.tag)[token_index]) {
2510 assert(ret[ret.len - 1] == '\n');2510 .multiline_string_literal_line => {
2511 ret.len -= 1;2511 assert(ret[ret.len - 1] == '\n');
2512 ret.len -= 1;
2513 },
2514 .container_doc_comment, .doc_comment => {
2515 ret = mem.trimRight(u8, ret, &std.ascii.spaces);
2516 },
2517 else => {},
2512 }2518 }
2513 return ret;2519 return ret;
2514}2520}
lib/std/zig/string_literal.zig+1-1
...@@ -61,7 +61,7 @@ pub fn parseCharLiteral(slice: []const u8) ParsedCharLiteral {...@@ -61,7 +61,7 @@ pub fn parseCharLiteral(slice: []const u8) ParsedCharLiteral {
61 }61 }
62}62}
6363
64/// Parse an escape sequence from `slice[offset..]`. If parsing is successful, 64/// Parse an escape sequence from `slice[offset..]`. If parsing is successful,
65/// offset is updated to reflect the characters consumed.65/// offset is updated to reflect the characters consumed.
66fn parseEscapeSequence(slice: []const u8, offset: *usize) ParsedCharLiteral {66fn parseEscapeSequence(slice: []const u8, offset: *usize) ParsedCharLiteral {
67 assert(slice.len > offset.*);67 assert(slice.len > offset.*);
src/arch/wasm/Mir.zig+2-2
...@@ -10,7 +10,7 @@ const Mir = @This();...@@ -10,7 +10,7 @@ const Mir = @This();
1010
11const std = @import("std");11const std = @import("std");
1212
13/// A struct of array that represents each individual wasm 13/// A struct of array that represents each individual wasm
14instructions: std.MultiArrayList(Inst).Slice,14instructions: std.MultiArrayList(Inst).Slice,
15/// A slice of indexes where the meaning of the data is determined by the15/// A slice of indexes where the meaning of the data is determined by the
16/// `Inst.Tag` value.16/// `Inst.Tag` value.
...@@ -538,7 +538,7 @@ pub const Inst = struct {...@@ -538,7 +538,7 @@ pub const Inst = struct {
538 /// Contains an u32 index into a wasm section entry, such as a local.538 /// Contains an u32 index into a wasm section entry, such as a local.
539 /// Note: This is not an index to another instruction.539 /// Note: This is not an index to another instruction.
540 ///540 ///
541 /// Used by e.g. `local_get`, `local_set`, etc. 541 /// Used by e.g. `local_get`, `local_set`, etc.
542 label: u32,542 label: u32,
543 /// A 32-bit immediate value.543 /// A 32-bit immediate value.
544 ///544 ///
src/arch/x86_64/Mir.zig+1-1
...@@ -364,7 +364,7 @@ pub const Inst = struct {...@@ -364,7 +364,7 @@ pub const Inst = struct {
364 dbg_line,364 dbg_line,
365365
366 /// push registers from the callee_preserved_regs366 /// push registers from the callee_preserved_regs
367 /// data is the bitfield of which regs to push 367 /// data is the bitfield of which regs to push
368 /// for example on x86_64, the callee_preserved_regs are [_]Register{ .rcx, .rsi, .rdi, .r8, .r9, .r10, .r11 }; };368 /// for example on x86_64, the callee_preserved_regs are [_]Register{ .rcx, .rsi, .rdi, .r8, .r9, .r10, .r11 }; };
369 /// so to push rcx and r8 one would make data 0b00000000_00000000_00000000_00001001 (the first and fourth bits are set)369 /// so to push rcx and r8 one would make data 0b00000000_00000000_00000000_00001001 (the first and fourth bits are set)
370 /// ops is unused370 /// ops is unused
src/link/Elf.zig+1-1
...@@ -154,7 +154,7 @@ atom_by_index_table: std.AutoHashMapUnmanaged(u32, *TextBlock) = .{},...@@ -154,7 +154,7 @@ atom_by_index_table: std.AutoHashMapUnmanaged(u32, *TextBlock) = .{},
154/// const Foo = struct{154/// const Foo = struct{
155/// a: u8,155/// a: u8,
156/// };156/// };
157/// 157///
158/// pub fn main() void {158/// pub fn main() void {
159/// var foo = Foo{ .a = 1 };159/// var foo = Foo{ .a = 1 };
160/// _ = foo;160/// _ = foo;
src/link/MachO.zig+1-1
...@@ -232,7 +232,7 @@ atom_by_index_table: std.AutoHashMapUnmanaged(u32, *Atom) = .{},...@@ -232,7 +232,7 @@ atom_by_index_table: std.AutoHashMapUnmanaged(u32, *Atom) = .{},
232/// const Foo = struct{232/// const Foo = struct{
233/// a: u8,233/// a: u8,
234/// };234/// };
235/// 235///
236/// pub fn main() void {236/// pub fn main() void {
237/// var foo = Foo{ .a = 1 };237/// var foo = Foo{ .a = 1 };
238/// _ = foo;238/// _ = foo;