diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-02-01 18:25:28 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-02-01 19:06:40 -0700 |
| commit | 449554a7307731047fcd9c132386fdf405c3b237 (patch) | |
| tree | c579c496ed162736b24930a17070c2544d4fc033 /lib | |
| parent | f4a249325e8e3741a6294462ae37a79cb9089c56 (diff) | |
| download | zig-449554a7307731047fcd9c132386fdf405c3b237.tar.gz zig-449554a7307731047fcd9c132386fdf405c3b237.zip | |
stage2: remove anytype fields from the language
closes #10705
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/crypto/benchmark.zig | 4 | ||||
| -rw-r--r-- | lib/std/json.zig | 3 | ||||
| -rw-r--r-- | lib/std/zig/Ast.zig | 5 | ||||
| -rw-r--r-- | lib/std/zig/parse.zig | 15 | ||||
| -rw-r--r-- | lib/std/zig/render.zig | 2 |
5 files changed, 6 insertions, 23 deletions
diff --git a/lib/std/crypto/benchmark.zig b/lib/std/crypto/benchmark.zig index 9fd3c42544..50a031af84 100644 --- a/lib/std/crypto/benchmark.zig +++ b/lib/std/crypto/benchmark.zig @@ -297,8 +297,8 @@ pub fn benchmarkAes8(comptime Aes: anytype, comptime count: comptime_int) !u64 { } const CryptoPwhash = struct { - hashFn: anytype, - params: anytype, + hashFn: @compileError("anytype fields are removed from the language"), + params: @compileError("anytype fields are removed from the language"), name: []const u8, }; const bcrypt_params = crypto.pwhash.bcrypt.Params{ .rounds_log = 12 }; diff --git a/lib/std/json.zig b/lib/std/json.zig index 4009bf9c7f..ec3544364f 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -1791,8 +1791,9 @@ fn parseInternal( } inline for (structInfo.fields) |field, i| { if (!fields_seen[i]) { - if (field.default_value) |default| { + if (field.default_value) |default_ptr| { if (!field.is_comptime) { + const default = @ptrCast(*const field.field_type, default_ptr).*; @field(r, field.name) = default; } } else { diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index f7a18d2c04..17da4f5315 100644 --- a/lib/std/zig/Ast.zig +++ b/lib/std/zig/Ast.zig @@ -366,7 +366,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex { .builtin_call, .builtin_call_comma, .error_set_decl, - .@"anytype", .@"comptime", .@"nosuspend", .asm_simple, @@ -729,7 +728,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex { .error_value, => return datas[n].rhs + end_offset, - .@"anytype", .anyframe_literal, .char_literal, .integer_literal, @@ -2935,9 +2933,6 @@ pub const Node = struct { /// main_token is the field name identifier. /// lastToken() does not include the possible trailing comma. container_field, - /// `anytype`. both lhs and rhs unused. - /// Used by `ContainerField`. - @"anytype", /// `comptime lhs`. rhs unused. @"comptime", /// `nosuspend lhs`. rhs unused. diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index 28219fa085..a70d0309e3 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -786,19 +786,8 @@ const Parser = struct { var align_expr: Node.Index = 0; var type_expr: Node.Index = 0; if (p.eatToken(.colon)) |_| { - if (p.eatToken(.keyword_anytype)) |anytype_tok| { - type_expr = try p.addNode(.{ - .tag = .@"anytype", - .main_token = anytype_tok, - .data = .{ - .lhs = undefined, - .rhs = undefined, - }, - }); - } else { - type_expr = try p.expectTypeExpr(); - align_expr = try p.parseByteAlign(); - } + type_expr = try p.expectTypeExpr(); + align_expr = try p.parseByteAlign(); } const value_expr: Node.Index = if (p.eatToken(.equal) == null) 0 else try p.expectExpr(); diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig index de33f380f8..f17ee1e097 100644 --- a/lib/std/zig/render.zig +++ b/lib/std/zig/render.zig @@ -229,8 +229,6 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, return renderToken(ais, tree, main_tokens[node] + 2, space); }, - .@"anytype" => return renderToken(ais, tree, main_tokens[node], space), - .block_two, .block_two_semicolon, => { |
