Commit 5a57610039
Changed files (3)
src-self-hosted
std
event
src-self-hosted/stage1.zig
@@ -90,8 +90,7 @@ export fn stage2_translate_c(
.import => translate_c.Mode.import,
.translate => translate_c.Mode.translate,
}, &errors, resources_path) catch |err| switch (err) {
- // TODO after https://github.com/ziglang/zig/issues/769 we can remove error.UnsupportedType
- error.SemanticAnalyzeFail, error.UnsupportedType => {
+ error.SemanticAnalyzeFail => {
out_errors_ptr.* = errors.ptr;
out_errors_len.* = errors.len;
return Error.CCompileErrors;
src-self-hosted/translate_c.zig
@@ -18,14 +18,9 @@ const CallingConvention = builtin.TypeInfo.CallingConvention;
pub const ClangErrMsg = Stage2ErrorMsg;
-pub const Error = error{
- OutOfMemory,
- UnsupportedType,
-};
-pub const TransError = error{
- OutOfMemory,
- UnsupportedTranslation,
-};
+pub const Error = error{OutOfMemory};
+const TypeError = Error || error{UnsupportedType};
+const TransError = Error || error{UnsupportedTranslation};
const DeclTable = std.HashMap(usize, void, addrHash, addrEql);
@@ -276,7 +271,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
error.UnsupportedType => {
return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function");
},
- error.OutOfMemory => return error.OutOfMemory,
+ error.OutOfMemory => |e| return e,
};
},
.FunctionNoProto => blk: {
@@ -285,7 +280,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
error.UnsupportedType => {
return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function");
},
- error.OutOfMemory => return error.OutOfMemory,
+ error.OutOfMemory => |e| return e,
};
},
else => unreachable,
@@ -299,7 +294,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
// actual function definition with body
const body_stmt = ZigClangFunctionDecl_getBody(fn_decl);
const result = transStmt(rp, scope, body_stmt, .unused, .r_value) catch |err| switch (err) {
- error.OutOfMemory => return error.OutOfMemory,
+ error.OutOfMemory => |e| return e,
error.UnsupportedTranslation => return failDecl(c, fn_decl_loc, fn_name, "unable to translate function"),
};
assert(result.node.id == ast.Node.Id.Block);
@@ -377,7 +372,7 @@ fn addTopLevelDecl(c: *Context, name: []const u8, decl_node: *ast.Node) !void {
try c.tree.root_node.decls.push(decl_node);
}
-fn transQualType(rp: RestorePoint, qt: ZigClangQualType, source_loc: ZigClangSourceLocation) Error!*ast.Node {
+fn transQualType(rp: RestorePoint, qt: ZigClangQualType, source_loc: ZigClangSourceLocation) TypeError!*ast.Node {
return transType(rp, ZigClangQualType_getTypePtr(qt), source_loc);
}
@@ -405,7 +400,7 @@ fn makeRestorePoint(c: *Context) RestorePoint {
};
}
-fn transType(rp: RestorePoint, ty: *const ZigClangType, source_loc: ZigClangSourceLocation) Error!*ast.Node {
+fn transType(rp: RestorePoint, ty: *const ZigClangType, source_loc: ZigClangSourceLocation) TypeError!*ast.Node {
switch (ZigClangType_getTypeClass(ty)) {
.Builtin => {
const builtin_ty = @ptrCast(*const ZigClangBuiltinType, ty);
@@ -535,7 +530,7 @@ fn finishTransFnProto(
try emitWarning(rp.c, source_loc, "unsupported function proto return type");
return err;
},
- error.OutOfMemory => return error.OutOfMemory,
+ error.OutOfMemory => |e| return e,
};
}
}
std/event/fs.zig
@@ -961,12 +961,7 @@ pub fn Watch(comptime V: type) type {
} else |err| switch (err) {
error.EventNotFound => unreachable,
error.ProcessNotFound => unreachable,
- error.AccessDenied, error.SystemResources => {
- // TODO https://github.com/ziglang/zig/issues/769
- const casted_err = @errSetCast(error{
- AccessDenied,
- SystemResources,
- }, err);
+ error.AccessDenied, error.SystemResources => |casted_err| {
await (async self.channel.put(casted_err) catch unreachable);
},
}