diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index 96007d564f..f7a18d2c04 100644 --- a/lib/std/zig/Ast.zig +++ b/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); diff --git a/src/AstGen.zig b/src/AstGen.zig index 6adec3fc53..8328264306 100644 --- a/src/AstGen.zig +++ b/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); diff --git a/src/Module.zig b/src/Module.zig index 3cae41a6a5..35b7efb016 100644 --- a/src/Module.zig +++ b/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, } }