Commit 50accb757f
Changed files (3)
lib
std
zig
lib/std/zig/Ast.zig
@@ -1642,6 +1642,18 @@ pub fn containerDeclArg(tree: Ast, node: Node.Index) full.ContainerDecl {
});
}
+pub fn containerDeclRoot(tree: Ast) full.ContainerDecl {
+ return .{
+ .layout_token = null,
+ .ast = .{
+ .main_token = undefined,
+ .enum_token = null,
+ .members = tree.rootDecls(),
+ .arg = 0,
+ },
+ };
+}
+
pub fn taggedUnionTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
assert(tree.nodes.items(.tag)[node] == .tagged_union_two or
tree.nodes.items(.tag)[node] == .tagged_union_two_trailing);
src/AstGen.zig
@@ -131,20 +131,11 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
};
defer gz_instructions.deinit(gpa);
- const container_decl: Ast.full.ContainerDecl = .{
- .layout_token = null,
- .ast = .{
- .main_token = undefined,
- .enum_token = null,
- .members = tree.rootDecls(),
- .arg = 0,
- },
- };
if (AstGen.structDeclInner(
&gen_scope,
&gen_scope.base,
0,
- container_decl,
+ tree.containerDeclRoot(),
.Auto,
)) |struct_decl_ref| {
assert(refToIndex(struct_decl_ref).? == 0);
src/Module.zig
@@ -935,6 +935,8 @@ pub const Struct = struct {
.tagged_union_enum_tag_trailing,
=> return queryFieldSrc(tree.*, query, file, tree.taggedUnionEnumTag(node)),
+ .root => return queryFieldSrc(tree.*, query, file, tree.containerDeclRoot()),
+
else => unreachable,
}
}