mirror of
https://github.com/ziglang/zig.git
synced 2026-10-14 10:27:43 -04:00
Replace deprecated default initializations with decl literals
This commit is contained in:
1 parent
eccd06f5d0
commit
8588964972
152 files changed
+813
-813
No files matched your search
+10
-10
@@ -10,9 +10,9 @@ const Oom = error{OutOfMemory};
|
||||
|
||||
pub const Decl = @import("Decl.zig");
|
||||
|
||||
pub var files: std.StringArrayHashMapUnmanaged(File) = .{};
|
||||
pub var decls: std.ArrayListUnmanaged(Decl) = .{};
|
||||
pub var modules: std.StringArrayHashMapUnmanaged(File.Index) = .{};
|
||||
pub var files: std.StringArrayHashMapUnmanaged(File) = .empty;
|
||||
pub var decls: std.ArrayListUnmanaged(Decl) = .empty;
|
||||
pub var modules: std.StringArrayHashMapUnmanaged(File.Index) = .empty;
|
||||
|
||||
file: File.Index,
|
||||
|
||||
@@ -42,17 +42,17 @@ pub const Category = union(enum(u8)) {
|
||||
pub const File = struct {
|
||||
ast: Ast,
|
||||
/// Maps identifiers to the declarations they point to.
|
||||
ident_decls: std.AutoArrayHashMapUnmanaged(Ast.TokenIndex, Ast.Node.Index) = .{},
|
||||
ident_decls: std.AutoArrayHashMapUnmanaged(Ast.TokenIndex, Ast.Node.Index) = .empty,
|
||||
/// Maps field access identifiers to the containing field access node.
|
||||
token_parents: std.AutoArrayHashMapUnmanaged(Ast.TokenIndex, Ast.Node.Index) = .{},
|
||||
token_parents: std.AutoArrayHashMapUnmanaged(Ast.TokenIndex, Ast.Node.Index) = .empty,
|
||||
/// Maps declarations to their global index.
|
||||
node_decls: std.AutoArrayHashMapUnmanaged(Ast.Node.Index, Decl.Index) = .{},
|
||||
node_decls: std.AutoArrayHashMapUnmanaged(Ast.Node.Index, Decl.Index) = .empty,
|
||||
/// Maps function declarations to doctests.
|
||||
doctests: std.AutoArrayHashMapUnmanaged(Ast.Node.Index, Ast.Node.Index) = .{},
|
||||
doctests: std.AutoArrayHashMapUnmanaged(Ast.Node.Index, Ast.Node.Index) = .empty,
|
||||
/// root node => its namespace scope
|
||||
/// struct/union/enum/opaque decl node => its namespace scope
|
||||
/// local var decl node => its local variable scope
|
||||
scopes: std.AutoArrayHashMapUnmanaged(Ast.Node.Index, *Scope) = .{},
|
||||
scopes: std.AutoArrayHashMapUnmanaged(Ast.Node.Index, *Scope) = .empty,
|
||||
|
||||
pub fn lookup_token(file: *File, token: Ast.TokenIndex) Decl.Index {
|
||||
const decl_node = file.ident_decls.get(token) orelse return .none;
|
||||
@@ -464,8 +464,8 @@ pub const Scope = struct {
|
||||
const Namespace = struct {
|
||||
base: Scope = .{ .tag = .namespace },
|
||||
parent: *Scope,
|
||||
names: std.StringArrayHashMapUnmanaged(Ast.Node.Index) = .{},
|
||||
doctests: std.StringArrayHashMapUnmanaged(Ast.Node.Index) = .{},
|
||||
names: std.StringArrayHashMapUnmanaged(Ast.Node.Index) = .empty,
|
||||
doctests: std.StringArrayHashMapUnmanaged(Ast.Node.Index) = .empty,
|
||||
decl_index: Decl.Index,
|
||||
};
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ pub fn fileSourceHtml(
|
||||
const file = file_index.get();
|
||||
|
||||
const g = struct {
|
||||
var field_access_buffer: std.ArrayListUnmanaged(u8) = .{};
|
||||
var field_access_buffer: std.ArrayListUnmanaged(u8) = .empty;
|
||||
};
|
||||
|
||||
const token_tags = ast.tokens.items(.tag);
|
||||
|
||||
+14
-14
@@ -60,8 +60,8 @@ export fn unpack(tar_ptr: [*]u8, tar_len: usize) void {
|
||||
};
|
||||
}
|
||||
|
||||
var query_string: std.ArrayListUnmanaged(u8) = .{};
|
||||
var query_results: std.ArrayListUnmanaged(Decl.Index) = .{};
|
||||
var query_string: std.ArrayListUnmanaged(u8) = .empty;
|
||||
var query_results: std.ArrayListUnmanaged(Decl.Index) = .empty;
|
||||
|
||||
/// Resizes the query string to be the correct length; returns the pointer to
|
||||
/// the query string.
|
||||
@@ -93,11 +93,11 @@ fn query_exec_fallible(query: []const u8, ignore_case: bool) !void {
|
||||
segments: u16,
|
||||
};
|
||||
const g = struct {
|
||||
var full_path_search_text: std.ArrayListUnmanaged(u8) = .{};
|
||||
var full_path_search_text_lower: std.ArrayListUnmanaged(u8) = .{};
|
||||
var doc_search_text: std.ArrayListUnmanaged(u8) = .{};
|
||||
var full_path_search_text: std.ArrayListUnmanaged(u8) = .empty;
|
||||
var full_path_search_text_lower: std.ArrayListUnmanaged(u8) = .empty;
|
||||
var doc_search_text: std.ArrayListUnmanaged(u8) = .empty;
|
||||
/// Each element matches a corresponding query_results element.
|
||||
var scores: std.ArrayListUnmanaged(Score) = .{};
|
||||
var scores: std.ArrayListUnmanaged(Score) = .empty;
|
||||
};
|
||||
|
||||
// First element stores the size of the list.
|
||||
@@ -255,8 +255,8 @@ const ErrorIdentifier = packed struct(u64) {
|
||||
}
|
||||
};
|
||||
|
||||
var string_result: std.ArrayListUnmanaged(u8) = .{};
|
||||
var error_set_result: std.StringArrayHashMapUnmanaged(ErrorIdentifier) = .{};
|
||||
var string_result: std.ArrayListUnmanaged(u8) = .empty;
|
||||
var error_set_result: std.StringArrayHashMapUnmanaged(ErrorIdentifier) = .empty;
|
||||
|
||||
export fn decl_error_set(decl_index: Decl.Index) Slice(ErrorIdentifier) {
|
||||
return Slice(ErrorIdentifier).init(decl_error_set_fallible(decl_index) catch @panic("OOM"));
|
||||
@@ -381,7 +381,7 @@ export fn decl_params(decl_index: Decl.Index) Slice(Ast.Node.Index) {
|
||||
|
||||
fn decl_fields_fallible(decl_index: Decl.Index) ![]Ast.Node.Index {
|
||||
const g = struct {
|
||||
var result: std.ArrayListUnmanaged(Ast.Node.Index) = .{};
|
||||
var result: std.ArrayListUnmanaged(Ast.Node.Index) = .empty;
|
||||
};
|
||||
g.result.clearRetainingCapacity();
|
||||
const decl = decl_index.get();
|
||||
@@ -403,7 +403,7 @@ fn decl_fields_fallible(decl_index: Decl.Index) ![]Ast.Node.Index {
|
||||
|
||||
fn decl_params_fallible(decl_index: Decl.Index) ![]Ast.Node.Index {
|
||||
const g = struct {
|
||||
var result: std.ArrayListUnmanaged(Ast.Node.Index) = .{};
|
||||
var result: std.ArrayListUnmanaged(Ast.Node.Index) = .empty;
|
||||
};
|
||||
g.result.clearRetainingCapacity();
|
||||
const decl = decl_index.get();
|
||||
@@ -672,7 +672,7 @@ fn render_docs(
|
||||
defer parsed_doc.deinit(gpa);
|
||||
|
||||
const g = struct {
|
||||
var link_buffer: std.ArrayListUnmanaged(u8) = .{};
|
||||
var link_buffer: std.ArrayListUnmanaged(u8) = .empty;
|
||||
};
|
||||
|
||||
const Writer = std.ArrayListUnmanaged(u8).Writer;
|
||||
@@ -817,7 +817,7 @@ export fn find_module_root(pkg: Walk.ModuleIndex) Decl.Index {
|
||||
}
|
||||
|
||||
/// Set by `set_input_string`.
|
||||
var input_string: std.ArrayListUnmanaged(u8) = .{};
|
||||
var input_string: std.ArrayListUnmanaged(u8) = .empty;
|
||||
|
||||
export fn set_input_string(len: usize) [*]u8 {
|
||||
input_string.resize(gpa, len) catch @panic("OOM");
|
||||
@@ -839,7 +839,7 @@ export fn find_decl() Decl.Index {
|
||||
if (result != .none) return result;
|
||||
|
||||
const g = struct {
|
||||
var match_fqn: std.ArrayListUnmanaged(u8) = .{};
|
||||
var match_fqn: std.ArrayListUnmanaged(u8) = .empty;
|
||||
};
|
||||
for (Walk.decls.items, 0..) |*decl, decl_index| {
|
||||
g.match_fqn.clearRetainingCapacity();
|
||||
@@ -888,7 +888,7 @@ export fn type_fn_members(parent: Decl.Index, include_private: bool) Slice(Decl.
|
||||
|
||||
export fn namespace_members(parent: Decl.Index, include_private: bool) Slice(Decl.Index) {
|
||||
const g = struct {
|
||||
var members: std.ArrayListUnmanaged(Decl.Index) = .{};
|
||||
var members: std.ArrayListUnmanaged(Decl.Index) = .empty;
|
||||
};
|
||||
|
||||
g.members.clearRetainingCapacity();
|
||||
|
||||
@@ -31,11 +31,11 @@ const ExtraData = Document.ExtraData;
|
||||
const StringIndex = Document.StringIndex;
|
||||
|
||||
nodes: Node.List = .{},
|
||||
extra: std.ArrayListUnmanaged(u32) = .{},
|
||||
scratch_extra: std.ArrayListUnmanaged(u32) = .{},
|
||||
string_bytes: std.ArrayListUnmanaged(u8) = .{},
|
||||
scratch_string: std.ArrayListUnmanaged(u8) = .{},
|
||||
pending_blocks: std.ArrayListUnmanaged(Block) = .{},
|
||||
extra: std.ArrayListUnmanaged(u32) = .empty,
|
||||
scratch_extra: std.ArrayListUnmanaged(u32) = .empty,
|
||||
string_bytes: std.ArrayListUnmanaged(u8) = .empty,
|
||||
scratch_string: std.ArrayListUnmanaged(u8) = .empty,
|
||||
pending_blocks: std.ArrayListUnmanaged(Block) = .empty,
|
||||
allocator: Allocator,
|
||||
|
||||
const Parser = @This();
|
||||
@@ -928,8 +928,8 @@ const InlineParser = struct {
|
||||
parent: *Parser,
|
||||
content: []const u8,
|
||||
pos: usize = 0,
|
||||
pending_inlines: std.ArrayListUnmanaged(PendingInline) = .{},
|
||||
completed_inlines: std.ArrayListUnmanaged(CompletedInline) = .{},
|
||||
pending_inlines: std.ArrayListUnmanaged(PendingInline) = .empty,
|
||||
completed_inlines: std.ArrayListUnmanaged(CompletedInline) = .empty,
|
||||
|
||||
const PendingInline = struct {
|
||||
tag: Tag,
|
||||
|
||||
Reference in new issue
Block a user