mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:24:33 +01:00
compiler,std: remove a handful of redundant discards
I'm embarrassed to say I didn't realise until a few days ago that you could omit the `_` capture for `if`/`while` on `E!void`...
This commit is contained in:
parent
aa0249d74e
commit
49f17237b0
3 changed files with 7 additions and 7 deletions
|
|
@ -322,7 +322,7 @@ pub fn makePathStatus(dir: Dir, io: Io, sub_path: []const u8) MakePathError!Make
|
|||
var status: MakePathStatus = .existed;
|
||||
var component = it.last() orelse return error.BadPathName;
|
||||
while (true) {
|
||||
if (makeDir(dir, io, component.path)) |_| {
|
||||
if (makeDir(dir, io, component.path)) {
|
||||
status = .created;
|
||||
} else |err| switch (err) {
|
||||
error.PathAlreadyExists => {
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ pub const Reader = struct {
|
|||
},
|
||||
.streaming, .streaming_reading => {
|
||||
const seek_err = r.seek_err orelse e: {
|
||||
if (io.vtable.fileSeekBy(io.userdata, r.file, offset)) |_| {
|
||||
if (io.vtable.fileSeekBy(io.userdata, r.file, offset)) {
|
||||
setLogicalPos(r, @intCast(@as(i64, @intCast(logicalPos(r))) + offset));
|
||||
return;
|
||||
} else |err| {
|
||||
|
|
|
|||
10
src/Sema.zig
10
src/Sema.zig
|
|
@ -1061,7 +1061,7 @@ fn analyzeInlineBody(
|
|||
/// The index which a break instruction can target to break from this body.
|
||||
break_target: Zir.Inst.Index,
|
||||
) CompileError!?Air.Inst.Ref {
|
||||
if (sema.analyzeBodyInner(block, body)) |_| {
|
||||
if (sema.analyzeBodyInner(block, body)) {
|
||||
return null;
|
||||
} else |err| switch (err) {
|
||||
error.ComptimeBreak => {},
|
||||
|
|
@ -1808,7 +1808,7 @@ fn analyzeBodyInner(
|
|||
child_block.instructions = block.instructions;
|
||||
defer block.instructions = child_block.instructions;
|
||||
|
||||
const break_result: ?BreakResult = if (sema.analyzeBodyInner(&child_block, inline_body)) |_| r: {
|
||||
const break_result: ?BreakResult = if (sema.analyzeBodyInner(&child_block, inline_body)) r: {
|
||||
break :r null;
|
||||
} else |err| switch (err) {
|
||||
error.ComptimeBreak => brk_res: {
|
||||
|
|
@ -1956,7 +1956,7 @@ fn analyzeBodyInner(
|
|||
.@"defer" => blk: {
|
||||
const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"defer";
|
||||
const defer_body = sema.code.bodySlice(inst_data.index, inst_data.len);
|
||||
if (sema.analyzeBodyInner(block, defer_body)) |_| {
|
||||
if (sema.analyzeBodyInner(block, defer_body)) {
|
||||
// The defer terminated noreturn - no more analysis needed.
|
||||
break;
|
||||
} else |err| switch (err) {
|
||||
|
|
@ -1975,7 +1975,7 @@ fn analyzeBodyInner(
|
|||
const err_code = try sema.resolveInst(inst_data.err_code);
|
||||
try map.ensureSpaceForInstructions(sema.gpa, defer_body);
|
||||
map.putAssumeCapacity(extra.remapped_err_code, err_code);
|
||||
if (sema.analyzeBodyInner(block, defer_body)) |_| {
|
||||
if (sema.analyzeBodyInner(block, defer_body)) {
|
||||
// The defer terminated noreturn - no more analysis needed.
|
||||
break;
|
||||
} else |err| switch (err) {
|
||||
|
|
@ -5959,7 +5959,7 @@ fn resolveBlockBody(
|
|||
assert(sema.air_instructions.items(.tag)[@intFromEnum(merges.block_inst)] == .block);
|
||||
var need_debug_scope = false;
|
||||
child_block.need_debug_scope = &need_debug_scope;
|
||||
if (sema.analyzeBodyInner(child_block, body)) |_| {
|
||||
if (sema.analyzeBodyInner(child_block, body)) {
|
||||
return sema.resolveAnalyzedBlock(parent_block, src, child_block, merges, need_debug_scope);
|
||||
} else |err| switch (err) {
|
||||
error.ComptimeBreak => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue