mach: remove compiler error for missing field in app (upstream issue fixed) (#647)

* platform: allow fieldless App
* platform: remove unused field

Co-authored-by: Beau McCartney <beau@beaumccartney.xyz>
This commit is contained in:
Beau McCartney 2022-12-25 13:37:23 -07:00 committed by GitHub
parent 5849304fba
commit 7d04252126
Failed to generate hash of commit
2 changed files with 2 additions and 14 deletions

View file

@ -6,17 +6,8 @@ pub fn checkApplication(comptime app_pkg: type) void {
} }
const App = app_pkg.App; const App = app_pkg.App;
// If App has no fields, it gets interpretted as '*const App' when it should be '*App' if (@typeInfo(App) != .Struct) {
// This gives a more useful compiler error. @compileError("App must be a struct type. Found:" ++ @typeName(App));
switch (@typeInfo(App)) {
.Struct => |app| {
if (app.fields.len == 0) {
@compileError("App must contain fields. Example: '_unused: i32,'");
}
},
else => {
@compileError("App must be a struct type. Found:" ++ @typeName(App));
},
} }
if (@hasDecl(App, "init")) { if (@hasDecl(App, "init")) {

View file

@ -7,9 +7,6 @@ const native = @import("native.zig");
pub const App = @This(); pub const App = @This();
// TODO(self-hosted): https://github.com/ziglang/zig/issues/12275
_unused: i32,
pub const GPUInterface = gpu.dawn.Interface; pub const GPUInterface = gpu.dawn.Interface;
const _ = gpu.Export(GPUInterface); const _ = gpu.Export(GPUInterface);