| author | |
| committer | |
| log | 6b6c1b1b0e04d70a4917f073a6a8bc87a5e8abb3 |
| tree | c3b32e4ab3e3c081c9ab1091cd0ca860dc477c4f |
| parent | 5c44934e20fedb29b88616f51de70c92e5d4ba42 |
This reverts commit dea72d15da4fba909dc3ccb2e9dc5286372ac023, reversing
changes made to ab381933c87bcc744058d25a876cfdc0d23fc674.
The changeset does not work as advertised and does not have sufficient
test coverage.
Reopens #2282217 files changed, 15 insertions(+), 251 deletions(-)
doc/langref.html.in+13-49| ... | @@ -2288,7 +2288,7 @@ or | ... | @@ -2288,7 +2288,7 @@ or |
| 2288 | {#code|test_aligned_struct_fields.zig#} | 2288 | {#code|test_aligned_struct_fields.zig#} |
| 2289 | 2289 | ||
| 2290 | <p> | 2290 | <p> |
| 2291 | Equating packed structs results in a comparison of the backing integer, | 2291 | Equating packed structs results in a comparison of the backing integer, |
| 2292 | and only works for the `==` and `!=` operators. | 2292 | and only works for the `==` and `!=` operators. |
| 2293 | </p> | 2293 | </p> |
| 2294 | {#code|test_packed_struct_equality.zig#} | 2294 | {#code|test_packed_struct_equality.zig#} |
| ... | @@ -4086,7 +4086,7 @@ fn performFn(start_value: i32) i32 { | ... | @@ -4086,7 +4086,7 @@ fn performFn(start_value: i32) i32 { |
| 4086 | special-case syntax. | 4086 | special-case syntax. |
| 4087 | </p> | 4087 | </p> |
| 4088 | <p> | 4088 | <p> |
| 4089 | Here is an example of a generic {#syntax#}List{#endsyntax#} data structure. | 4089 | 			Here is an example of a generic {#syntax#}List{#endsyntax#} data structure. |
| 4090 | </p> | 4090 | </p> |
| 4091 | {#code|generic_data_structure.zig#} | 4091 | {#code|generic_data_structure.zig#} |
| 4092 | 4092 | ||
| ... | @@ -4291,10 +4291,10 @@ pub fn print(self: *Writer, arg0: []const u8, arg1: i32) !void { | ... | @@ -4291,10 +4291,10 @@ pub fn print(self: *Writer, arg0: []const u8, arg1: i32) !void { |
| 4291 | <pre>{#syntax#}@addrSpaceCast(ptr: anytype) anytype{#endsyntax#}</pre> | 4291 | <pre>{#syntax#}@addrSpaceCast(ptr: anytype) anytype{#endsyntax#}</pre> |
| 4292 | <p> | 4292 | <p> |
| 4293 | Converts a pointer from one address space to another. The new address space is inferred | 4293 | Converts a pointer from one address space to another. The new address space is inferred |
| 4294 | based on the result type. Depending on the current target and address spaces, this cast | 4294 | 			based on the result type. Depending on the current target and address spaces, this cast |
| 4295 | may be a no-op, a complex operation, or illegal. If the cast is legal, then the resulting | 4295 | 			may be a no-op, a complex operation, or illegal. If the cast is legal, then the resulting |
| 4296 | pointer points to the same memory location as the pointer operand. It is always valid to | 4296 | 			pointer points to the same memory location as the pointer operand. It is always valid to |
| 4297 | cast a pointer between the same address spaces. | 4297 | 			cast a pointer between the same address spaces. |
| 4298 | </p> | 4298 | </p> |
| 4299 | {#header_close#} | 4299 | {#header_close#} |
| 4300 | {#header_open|@addWithOverflow#} | 4300 | {#header_open|@addWithOverflow#} |
| ... | @@ -4307,7 +4307,7 @@ pub fn print(self: *Writer, arg0: []const u8, arg1: i32) !void { | ... | @@ -4307,7 +4307,7 @@ pub fn print(self: *Writer, arg0: []const u8, arg1: i32) !void { |
| 4307 | <pre>{#syntax#}@alignCast(ptr: anytype) anytype{#endsyntax#}</pre> | 4307 | <pre>{#syntax#}@alignCast(ptr: anytype) anytype{#endsyntax#}</pre> |
| 4308 | <p> | 4308 | <p> |
| 4309 | {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}?*T{#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. | 4309 | {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}?*T{#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. |
| 4310 | Changes the alignment of a pointer. The alignment to use is inferred based on the result type. | 4310 | 			Changes the alignment of a pointer. The alignment to use is inferred based on the result type. |
| 4311 | </p> | 4311 | </p> |
| 4312 | <p>A {#link|pointer alignment safety check|Incorrect Pointer Alignment#} is added | 4312 | <p>A {#link|pointer alignment safety check|Incorrect Pointer Alignment#} is added |
| 4313 | to the generated code to make sure the pointer is aligned as promised.</p> | 4313 | to the generated code to make sure the pointer is aligned as promised.</p> |
| ... | @@ -4384,7 +4384,7 @@ comptime { | ... | @@ -4384,7 +4384,7 @@ comptime { |
| 4384 | <pre>{#syntax#}@bitCast(value: anytype) anytype{#endsyntax#}</pre> | 4384 | <pre>{#syntax#}@bitCast(value: anytype) anytype{#endsyntax#}</pre> |
| 4385 | <p> | 4385 | <p> |
| 4386 | Converts a value of one type to another type. The return type is the | 4386 | Converts a value of one type to another type. The return type is the |
| 4387 | inferred result type. | 4387 | 			inferred result type. |
| 4388 | </p> | 4388 | </p> |
| 4389 | <p> | 4389 | <p> |
| 4390 | Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}. | 4390 | Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}. |
| ... | @@ -4741,42 +4741,6 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val | ... | @@ -4741,42 +4741,6 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 4741 | {#see_also|@cVaArg|@cVaCopy|@cVaEnd#} | 4741 | {#see_also|@cVaArg|@cVaCopy|@cVaEnd#} |
| 4742 | {#header_close#} | 4742 | {#header_close#} |
| 4743 | 4743 | ||
| 4744 | {#header_open|@deprecated#} | ||
| 4745 | <pre>{#syntax#}@deprecated(value: anytype) @TypeOf(value){#endsyntax#}</pre> | ||
| 4746 | <pre>{#syntax#}@deprecated() void{#endsyntax#}</pre> | ||
| 4747 | <p> | ||
| 4748 | Marks a given code path as scheduled for removal. Evaluates to the same | ||
| 4749 | value passed in as argument, or the {#syntax#}void{#endsyntax#} value | ||
| 4750 | when given none. | ||
| 4751 | </p> | ||
| 4752 | <p> | ||
| 4753 | When a public declaration has been moved to a new location, the old | ||
| 4754 | location can be marked {#syntax#}@deprecated{#endsyntax#}: | ||
| 4755 | </p> | ||
| 4756 | {#syntax_block|zig|root.zig#} | ||
| 4757 | pub const fooToBar = @deprecated(bar.fromFoo); // moved | ||
| 4758 | {#end_syntax_block#} | ||
| 4759 | <p> | ||
| 4760 | By default deprecated code paths are disallowed in a module defined by | ||
| 4761 | the root package but allowed in modules defined by the rest of the | ||
| 4762 | dependency tree. This behavior can be overridden by passing | ||
| 4763 | <code>-fallow-deprecated</code> or <code>-fno-allow-deprecated</code> to | ||
| 4764 | <code>zig build</code>. | ||
| 4765 | </p> | ||
| 4766 | <p> | ||
| 4767 | The purpose of {#syntax#}@deprecated{#endsyntax#} is to provide at least | ||
| 4768 | one version (a "grace period") of a package that supports both old and new APIs | ||
| 4769 | simultaneously, while providing tooling for programmers to discover what needs | ||
| 4770 | to be upgraded to migrate to the new API. Such a grace period has the key property | ||
| 4771 | that it allows a project's dependency tree to be upgraded <em>one package at a time</em>. | ||
| 4772 | </p> | ||
| 4773 | <p> | ||
| 4774 | Using {#syntax#}@deprecated{#endsyntax#} without an argument can be | ||
| 4775 | useful inside of conditionally compiled blocks: | ||
| 4776 | </p> | ||
| 4777 | {#code|test_deprecated_builtin.zig#} | ||
| 4778 | {#header_close#} | ||
| 4779 | |||
| 4780 | {#header_open|@divExact#} | 4744 | {#header_open|@divExact#} |
| 4781 | <pre>{#syntax#}@divExact(numerator: T, denominator: T) T{#endsyntax#}</pre> | 4745 | <pre>{#syntax#}@divExact(numerator: T, denominator: T) T{#endsyntax#}</pre> |
| 4782 | <p> | 4746 | <p> |
| ... | @@ -4891,8 +4855,8 @@ pub const fooToBar = @deprecated(bar.fromFoo); // moved | ... | @@ -4891,8 +4855,8 @@ pub const fooToBar = @deprecated(bar.fromFoo); // moved |
| 4891 | <pre>{#syntax#}@errorCast(value: anytype) anytype{#endsyntax#}</pre> | 4855 | <pre>{#syntax#}@errorCast(value: anytype) anytype{#endsyntax#}</pre> |
| 4892 | <p> | 4856 | <p> |
| 4893 | Converts an error set or error union value from one error set to another error set. The return type is the | 4857 | Converts an error set or error union value from one error set to another error set. The return type is the |
| 4894 | inferred result type. Attempting to convert an error which is not in the destination error | 4858 | 			inferred result type. Attempting to convert an error which is not in the destination error |
| 4895 | set results in safety-checked {#link|Illegal Behavior#}. | 4859 | 			set results in safety-checked {#link|Illegal Behavior#}. |
| 4896 | </p> | 4860 | </p> |
| 4897 | {#header_close#} | 4861 | {#header_close#} |
| 4898 | 4862 | ||
| ... | @@ -4971,7 +4935,7 @@ pub const fooToBar = @deprecated(bar.fromFoo); // moved | ... | @@ -4971,7 +4935,7 @@ pub const fooToBar = @deprecated(bar.fromFoo); // moved |
| 4971 | <pre>{#syntax#}@floatFromInt(int: anytype) anytype{#endsyntax#}</pre> | 4935 | <pre>{#syntax#}@floatFromInt(int: anytype) anytype{#endsyntax#}</pre> |
| 4972 | <p> | 4936 | <p> |
| 4973 | Converts an integer to the closest floating point representation. The return type is the inferred result type. | 4937 | Converts an integer to the closest floating point representation. The return type is the inferred result type. |
| 4974 | To convert the other way, use {#link|@intFromFloat#}. This operation is legal | 4938 | 			To convert the other way, use {#link|@intFromFloat#}. This operation is legal |
| 4975 | for all values of all integer types. | 4939 | for all values of all integer types. |
| 4976 | </p> | 4940 | </p> |
| 4977 | {#header_close#} | 4941 | {#header_close#} |
| ... | @@ -5063,7 +5027,7 @@ pub const fooToBar = @deprecated(bar.fromFoo); // moved | ... | @@ -5063,7 +5027,7 @@ pub const fooToBar = @deprecated(bar.fromFoo); // moved |
| 5063 | <pre>{#syntax#}@intCast(int: anytype) anytype{#endsyntax#}</pre> | 5027 | <pre>{#syntax#}@intCast(int: anytype) anytype{#endsyntax#}</pre> |
| 5064 | <p> | 5028 | <p> |
| 5065 | Converts an integer to another integer while keeping the same numerical value. | 5029 | Converts an integer to another integer while keeping the same numerical value. |
| 5066 | The return type is the inferred result type. | 5030 | 			The return type is the inferred result type. |
| 5067 | Attempting to convert a number which is out of range of the destination type results in | 5031 | Attempting to convert a number which is out of range of the destination type results in |
| 5068 | safety-checked {#link|Illegal Behavior#}. | 5032 | safety-checked {#link|Illegal Behavior#}. |
| 5069 | </p> | 5033 | </p> |
| ... | @@ -5316,7 +5280,7 @@ pub const fooToBar = @deprecated(bar.fromFoo); // moved | ... | @@ -5316,7 +5280,7 @@ pub const fooToBar = @deprecated(bar.fromFoo); // moved |
| 5316 | <pre>{#syntax#}@ptrFromInt(address: usize) anytype{#endsyntax#}</pre> | 5280 | <pre>{#syntax#}@ptrFromInt(address: usize) anytype{#endsyntax#}</pre> |
| 5317 | <p> | 5281 | <p> |
| 5318 | Converts an integer to a {#link|pointer|Pointers#}. The return type is the inferred result type. | 5282 | Converts an integer to a {#link|pointer|Pointers#}. The return type is the inferred result type. |
| 5319 | To convert the other way, use {#link|@intFromPtr#}. Casting an address of 0 to a destination type | 5283 | 			To convert the other way, use {#link|@intFromPtr#}. Casting an address of 0 to a destination type |
| 5320 | which in not {#link|optional|Optional Pointers#} and does not have the {#syntax#}allowzero{#endsyntax#} attribute will result in a | 5284 | which in not {#link|optional|Optional Pointers#} and does not have the {#syntax#}allowzero{#endsyntax#} attribute will result in a |
| 5321 | {#link|Pointer Cast Invalid Null#} panic when runtime safety checks are enabled. | 5285 | {#link|Pointer Cast Invalid Null#} panic when runtime safety checks are enabled. |
| 5322 | </p> | 5286 | </p> |
doc/langref/test_deprecated_builtin.zig deleted-22| ... | @@ -1,22 +0,0 @@ | ||
| 1 | test "deprecated code path" { | ||
| 2 | compute(.greedy, false, 42); | ||
| 3 | } | ||
| 4 | |||
| 5 | const Strategy = enum { greedy, expensive, fast }; | ||
| 6 | fn compute(comptime strat: Strategy, comptime foo: bool, bar: usize) void { | ||
| 7 | switch (strat) { | ||
| 8 | .greedy => { | ||
| 9 | // This combination turned out to be ineffective. | ||
| 10 | if (!foo) @deprecated(); // use fast strategy when foo is false | ||
| 11 | runGreedy(foo, bar); | ||
| 12 | }, | ||
| 13 | .expensive => runExpensive(foo, bar), | ||
| 14 | .fast => runFast(foo, bar), | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | extern fn runGreedy(foo: bool, bar: usize) void; | ||
| 19 | extern fn runExpensive(foo: bool, bar: usize) void; | ||
| 20 | extern fn runFast(foo: bool, bar: usize) void; | ||
| 21 | |||
| 22 | // test_error=deprecated | ||
lib/compiler/build_runner.zig-8| ... | @@ -80,7 +80,6 @@ pub fn main() !void { | ... | @@ -80,7 +80,6 @@ pub fn main() !void { |
| 80 | .query = .{}, | 80 | .query = .{}, |
| 81 | .result = try std.zig.system.resolveTargetQuery(.{}), | 81 | .result = try std.zig.system.resolveTargetQuery(.{}), |
| 82 | }, | 82 | }, |
| 83 | .root_builder = undefined, // populated below | ||
| 84 | }; | 83 | }; |
| 85 | 84 | ||
| 86 | graph.cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() }); | 85 | graph.cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() }); |
| ... | @@ -95,7 +94,6 @@ pub fn main() !void { | ... | @@ -95,7 +94,6 @@ pub fn main() !void { |
| 95 | local_cache_directory, | 94 | local_cache_directory, |
| 96 | dependencies.root_deps, | 95 | dependencies.root_deps, |
| 97 | ); | 96 | ); |
| 98 | graph.root_builder = builder; | ||
| 99 | 97 | ||
| 100 | var targets = ArrayList([]const u8).init(arena); | 98 | var targets = ArrayList([]const u8).init(arena); |
| 101 | var debug_log_scopes = ArrayList([]const u8).init(arena); | 99 | var debug_log_scopes = ArrayList([]const u8).init(arena); |
| ... | @@ -262,10 +260,6 @@ pub fn main() !void { | ... | @@ -262,10 +260,6 @@ pub fn main() !void { |
| 262 | graph.incremental = true; | 260 | graph.incremental = true; |
| 263 | } else if (mem.eql(u8, arg, "-fno-incremental")) { | 261 | } else if (mem.eql(u8, arg, "-fno-incremental")) { |
| 264 | graph.incremental = false; | 262 | graph.incremental = false; |
| 265 | } else if (mem.eql(u8, arg, "-fallow-deprecated")) { | ||
| 266 | graph.allow_deprecated = true; | ||
| 267 | } else if (mem.eql(u8, arg, "-fno-allow-deprecated")) { | ||
| 268 | graph.allow_deprecated = false; | ||
| 269 | } else if (mem.eql(u8, arg, "-fwine")) { | 263 | } else if (mem.eql(u8, arg, "-fwine")) { |
| 270 | builder.enable_wine = true; | 264 | builder.enable_wine = true; |
| 271 | } else if (mem.eql(u8, arg, "-fno-wine")) { | 265 | } else if (mem.eql(u8, arg, "-fno-wine")) { |
| ... | @@ -1296,8 +1290,6 @@ fn usage(b: *std.Build, out_stream: anytype) !void { | ... | @@ -1296,8 +1290,6 @@ fn usage(b: *std.Build, out_stream: anytype) !void { |
| 1296 | \\ new Omit cached steps | 1290 | \\ new Omit cached steps |
| 1297 | \\ failures (Default) Only print failed steps | 1291 | \\ failures (Default) Only print failed steps |
| 1298 | \\ none Do not print the build summary | 1292 | \\ none Do not print the build summary |
| 1299 | \\ -fallow-deprecated Allow usage of deprecated code for the entire build graph | ||
| 1300 | \\ -fno-allow-deprecated Disallow usage of deprecated code for the entire build graph | ||
| 1301 | \\ -j<N> Limit concurrent jobs (default is to use all CPU cores) | 1293 | \\ -j<N> Limit concurrent jobs (default is to use all CPU cores) |
| 1302 | \\ --maxrss <bytes> Limit memory usage (default is to use available memory) | 1294 | \\ --maxrss <bytes> Limit memory usage (default is to use available memory) |
| 1303 | \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss | 1295 | \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss |
lib/std/Build.zig-2| ... | @@ -121,8 +121,6 @@ pub const Graph = struct { | ... | @@ -121,8 +121,6 @@ pub const Graph = struct { |
| 121 | random_seed: u32 = 0, | 121 | random_seed: u32 = 0, |
| 122 | dependency_cache: InitializedDepMap = .empty, | 122 | dependency_cache: InitializedDepMap = .empty, |
| 123 | allow_so_scripts: ?bool = null, | 123 | allow_so_scripts: ?bool = null, |
| 124 | allow_deprecated: ?bool = null, | ||
| 125 | root_builder: *std.Build, | ||
| 126 | }; | 124 | }; |
| 127 | 125 | ||
| 128 | const AvailableDeps = []const struct { []const u8, []const u8 }; | 126 | const AvailableDeps = []const struct { []const u8, []const u8 }; |
lib/std/Build/Module.zig-4| ... | @@ -557,10 +557,6 @@ pub fn appendZigProcessFlags( | ... | @@ -557,10 +557,6 @@ pub fn appendZigProcessFlags( |
| 557 | try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC"); | 557 | try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC"); |
| 558 | try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone"); | 558 | try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone"); |
| 559 | 559 | ||
| 560 | // -fno-allow-deprecated is the CLI default, and not inherited, so only pass the flag if true. | ||
| 561 | const allow_deprecated = m.owner.graph.allow_deprecated orelse (m.owner.graph.root_builder != m.owner); | ||
| 562 | if (allow_deprecated == true) try zig_args.append("-fallow-deprecated"); | ||
| 563 | |||
| 564 | if (m.dwarf_format) |dwarf_format| { | 560 | if (m.dwarf_format) |dwarf_format| { |
| 565 | try zig_args.append(switch (dwarf_format) { | 561 | try zig_args.append(switch (dwarf_format) { |
| 566 | .@"32" => "-gdwarf32", | 562 | .@"32" => "-gdwarf32", |
lib/std/Build/Step/Options.zig-3| ... | @@ -514,7 +514,6 @@ test Options { | ... | @@ -514,7 +514,6 @@ test Options { |
| 514 | .result = try std.zig.system.resolveTargetQuery(.{}), | 514 | .result = try std.zig.system.resolveTargetQuery(.{}), |
| 515 | }, | 515 | }, |
| 516 | .zig_lib_directory = std.Build.Cache.Directory.cwd(), | 516 | .zig_lib_directory = std.Build.Cache.Directory.cwd(), |
| 517 | .root_builder = undefined, | ||
| 518 | }; | 517 | }; |
| 519 | 518 | ||
| 520 | var builder = try std.Build.create( | 519 | var builder = try std.Build.create( |
| ... | @@ -524,8 +523,6 @@ test Options { | ... | @@ -524,8 +523,6 @@ test Options { |
| 524 | &.{}, | 523 | &.{}, |
| 525 | ); | 524 | ); |
| 526 | 525 | ||
| 527 | graph.root_builder = builder; | ||
| 528 | |||
| 529 | const options = builder.addOptions(); | 526 | const options = builder.addOptions(); |
| 530 | 527 | ||
| 531 | const KeywordEnum = enum { | 528 | const KeywordEnum = enum { |
lib/std/zig/AstGen.zig-13| ... | @@ -9695,19 +9695,6 @@ fn builtinCall( | ... | @@ -9695,19 +9695,6 @@ fn builtinCall( |
| 9695 | .volatile_cast, | 9695 | .volatile_cast, |
| 9696 | => return ptrCast(gz, scope, ri, node), | 9696 | => return ptrCast(gz, scope, ri, node), |
| 9697 | 9697 | ||
| 9698 | .deprecated => { | ||
| 9699 | _ = try gz.addExtendedNodeSmall(.deprecated, node, 0); | ||
| 9700 | switch (params.len) { | ||
| 9701 | 0 => return .void_value, | ||
| 9702 | 1 => return expr(gz, scope, ri, params[0]), | ||
| 9703 | else => return astgen.failNode( | ||
| 9704 | node, | ||
| 9705 | "expected 0 or 1 argument, found {}", | ||
| 9706 | .{params.len}, | ||
| 9707 | ), | ||
| 9708 | } | ||
| 9709 | }, | ||
| 9710 | |||
| 9711 | // zig fmt: off | 9698 | // zig fmt: off |
| 9712 | .has_decl => return hasDeclOrField(gz, scope, ri, node, params[0], params[1], .has_decl), | 9699 | .has_decl => return hasDeclOrField(gz, scope, ri, node, params[0], params[1], .has_decl), |
| 9713 | .has_field => return hasDeclOrField(gz, scope, ri, node, params[0], params[1], .has_field), | 9700 | .has_field => return hasDeclOrField(gz, scope, ri, node, params[0], params[1], .has_field), |
lib/std/zig/AstRlAnnotate.zig+2-5| ... | @@ -817,6 +817,8 @@ fn blockExpr(astrl: *AstRlAnnotate, parent_block: ?*Block, ri: ResultInfo, node: | ... | @@ -817,6 +817,8 @@ fn blockExpr(astrl: *AstRlAnnotate, parent_block: ?*Block, ri: ResultInfo, node: |
| 817 | } | 817 | } |
| 818 | 818 | ||
| 819 | fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast.Node.Index, args: []const Ast.Node.Index) !bool { | 819 | fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast.Node.Index, args: []const Ast.Node.Index) !bool { |
| 820 | _ = ri; // Currently, no builtin consumes its result location. | ||
| 821 | |||
| 820 | const tree = astrl.tree; | 822 | const tree = astrl.tree; |
| 821 | const main_tokens = tree.nodes.items(.main_token); | 823 | const main_tokens = tree.nodes.items(.main_token); |
| 822 | const builtin_token = main_tokens[node]; | 824 | const builtin_token = main_tokens[node]; |
| ... | @@ -826,11 +828,6 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast. | ... | @@ -826,11 +828,6 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast. |
| 826 | if (expected != args.len) return false; | 828 | if (expected != args.len) return false; |
| 827 | } | 829 | } |
| 828 | switch (info.tag) { | 830 | switch (info.tag) { |
| 829 | .deprecated => if (args.len >= 1) { | ||
| 830 | return astrl.expr(args[0], block, ri); | ||
| 831 | } else { | ||
| 832 | return false; | ||
| 833 | }, | ||
| 834 | .import => return false, | 831 | .import => return false, |
| 835 | .branch_hint => { | 832 | .branch_hint => { |
| 836 | _ = try astrl.expr(args[0], block, ResultInfo.type_only); | 833 | _ = try astrl.expr(args[0], block, ResultInfo.type_only); |
lib/std/zig/BuiltinFn.zig-9| ... | @@ -121,7 +121,6 @@ pub const Tag = enum { | ... | @@ -121,7 +121,6 @@ pub const Tag = enum { |
| 121 | work_item_id, | 121 | work_item_id, |
| 122 | work_group_size, | 122 | work_group_size, |
| 123 | work_group_id, | 123 | work_group_id, |
| 124 | deprecated, | ||
| 125 | }; | 124 | }; |
| 126 | 125 | ||
| 127 | pub const EvalToError = enum { | 126 | pub const EvalToError = enum { |
| ... | @@ -1017,14 +1016,6 @@ pub const list = list: { | ... | @@ -1017,14 +1016,6 @@ pub const list = list: { |
| 1017 | .illegal_outside_function = true, | 1016 | .illegal_outside_function = true, |
| 1018 | }, | 1017 | }, |
| 1019 | }, | 1018 | }, |
| 1020 | .{ | ||
| 1021 | "@deprecated", | ||
| 1022 | .{ | ||
| 1023 | .tag = .deprecated, | ||
| 1024 | .param_count = null, | ||
| 1025 | .eval_to_error = .maybe, | ||
| 1026 | }, | ||
| 1027 | }, | ||
| 1028 | }); | 1019 | }); |
| 1029 | }; | 1020 | }; |
| 1030 | 1021 |
lib/std/zig/Zir.zig-4| ... | @@ -2112,9 +2112,6 @@ pub const Inst = struct { | ... | @@ -2112,9 +2112,6 @@ pub const Inst = struct { |
| 2112 | /// any code may have gone here, avoiding false-positive "unreachable code" errors. | 2112 | /// any code may have gone here, avoiding false-positive "unreachable code" errors. |
| 2113 | astgen_error, | 2113 | astgen_error, |
| 2114 | 2114 | ||
| 2115 | /// `operand` is `src_node: i32`. | ||
| 2116 | deprecated, | ||
| 2117 | |||
| 2118 | pub const InstData = struct { | 2115 | pub const InstData = struct { |
| 2119 | opcode: Extended, | 2116 | opcode: Extended, |
| 2120 | small: u16, | 2117 | small: u16, |
| ... | @@ -4366,7 +4363,6 @@ fn findTrackableInner( | ... | @@ -4366,7 +4363,6 @@ fn findTrackableInner( |
| 4366 | .tuple_decl, | 4363 | .tuple_decl, |
| 4367 | .dbg_empty_stmt, | 4364 | .dbg_empty_stmt, |
| 4368 | .astgen_error, | 4365 | .astgen_error, |
| 4369 | .deprecated, | ||
| 4370 | => return, | 4366 | => return, |
| 4371 | 4367 | ||
| 4372 | // `@TypeOf` has a body. | 4368 | // `@TypeOf` has a body. |
src/Compilation.zig-1| ... | @@ -868,7 +868,6 @@ pub const cache_helpers = struct { | ... | @@ -868,7 +868,6 @@ pub const cache_helpers = struct { |
| 868 | hh.add(mod.sanitize_c); | 868 | hh.add(mod.sanitize_c); |
| 869 | hh.add(mod.sanitize_thread); | 869 | hh.add(mod.sanitize_thread); |
| 870 | hh.add(mod.fuzz); | 870 | hh.add(mod.fuzz); |
| 871 | hh.add(mod.allow_deprecated); | ||
| 872 | hh.add(mod.unwind_tables); | 871 | hh.add(mod.unwind_tables); |
| 873 | hh.add(mod.structured_cfg); | 872 | hh.add(mod.structured_cfg); |
| 874 | hh.add(mod.no_builtin); | 873 | hh.add(mod.no_builtin); |
src/Package/Module.zig-10| ... | @@ -27,7 +27,6 @@ red_zone: bool, | ... | @@ -27,7 +27,6 @@ red_zone: bool, |
| 27 | sanitize_c: bool, | 27 | sanitize_c: bool, |
| 28 | sanitize_thread: bool, | 28 | sanitize_thread: bool, |
| 29 | fuzz: bool, | 29 | fuzz: bool, |
| 30 | allow_deprecated: bool, | ||
| 31 | unwind_tables: std.builtin.UnwindTables, | 30 | unwind_tables: std.builtin.UnwindTables, |
| 32 | cc_argv: []const []const u8, | 31 | cc_argv: []const []const u8, |
| 33 | /// (SPIR-V) whether to generate a structured control flow graph or not | 32 | /// (SPIR-V) whether to generate a structured control flow graph or not |
| ... | @@ -96,7 +95,6 @@ pub const CreateOptions = struct { | ... | @@ -96,7 +95,6 @@ pub const CreateOptions = struct { |
| 96 | sanitize_c: ?bool = null, | 95 | sanitize_c: ?bool = null, |
| 97 | sanitize_thread: ?bool = null, | 96 | sanitize_thread: ?bool = null, |
| 98 | fuzz: ?bool = null, | 97 | fuzz: ?bool = null, |
| 99 | allow_deprecated: ?bool = null, | ||
| 100 | structured_cfg: ?bool = null, | 98 | structured_cfg: ?bool = null, |
| 101 | no_builtin: ?bool = null, | 99 | no_builtin: ?bool = null, |
| 102 | }; | 100 | }; |
| ... | @@ -236,11 +234,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { | ... | @@ -236,11 +234,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 236 | break :b false; | 234 | break :b false; |
| 237 | }; | 235 | }; |
| 238 | 236 | ||
| 239 | const allow_deprecated = b: { | ||
| 240 | if (options.inherited.allow_deprecated) |x| break :b x; | ||
| 241 | break :b false; | ||
| 242 | }; | ||
| 243 | |||
| 244 | const code_model = b: { | 237 | const code_model = b: { |
| 245 | if (options.inherited.code_model) |x| break :b x; | 238 | if (options.inherited.code_model) |x| break :b x; |
| 246 | if (options.parent) |p| break :b p.code_model; | 239 | if (options.parent) |p| break :b p.code_model; |
| ... | @@ -387,7 +380,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { | ... | @@ -387,7 +380,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 387 | .sanitize_c = sanitize_c, | 380 | .sanitize_c = sanitize_c, |
| 388 | .sanitize_thread = sanitize_thread, | 381 | .sanitize_thread = sanitize_thread, |
| 389 | .fuzz = fuzz, | 382 | .fuzz = fuzz, |
| 390 | .allow_deprecated = allow_deprecated, | ||
| 391 | .unwind_tables = unwind_tables, | 383 | .unwind_tables = unwind_tables, |
| 392 | .cc_argv = options.cc_argv, | 384 | .cc_argv = options.cc_argv, |
| 393 | .structured_cfg = structured_cfg, | 385 | .structured_cfg = structured_cfg, |
| ... | @@ -482,7 +474,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { | ... | @@ -482,7 +474,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 482 | .sanitize_c = sanitize_c, | 474 | .sanitize_c = sanitize_c, |
| 483 | .sanitize_thread = sanitize_thread, | 475 | .sanitize_thread = sanitize_thread, |
| 484 | .fuzz = fuzz, | 476 | .fuzz = fuzz, |
| 485 | .allow_deprecated = allow_deprecated, | ||
| 486 | .unwind_tables = unwind_tables, | 477 | .unwind_tables = unwind_tables, |
| 487 | .cc_argv = &.{}, | 478 | .cc_argv = &.{}, |
| 488 | .structured_cfg = structured_cfg, | 479 | .structured_cfg = structured_cfg, |
| ... | @@ -541,7 +532,6 @@ pub fn createLimited(gpa: Allocator, options: LimitedOptions) Allocator.Error!*P | ... | @@ -541,7 +532,6 @@ pub fn createLimited(gpa: Allocator, options: LimitedOptions) Allocator.Error!*P |
| 541 | .sanitize_c = undefined, | 532 | .sanitize_c = undefined, |
| 542 | .sanitize_thread = undefined, | 533 | .sanitize_thread = undefined, |
| 543 | .fuzz = undefined, | 534 | .fuzz = undefined, |
| 544 | .allow_deprecated = undefined, | ||
| 545 | .unwind_tables = undefined, | 535 | .unwind_tables = undefined, |
| 546 | .cc_argv = undefined, | 536 | .cc_argv = undefined, |
| 547 | .structured_cfg = undefined, | 537 | .structured_cfg = undefined, |
src/Sema.zig-11| ... | @@ -1091,7 +1091,6 @@ fn analyzeBodyInner( | ... | @@ -1091,7 +1091,6 @@ fn analyzeBodyInner( |
| 1091 | const map = &sema.inst_map; | 1091 | const map = &sema.inst_map; |
| 1092 | const tags = sema.code.instructions.items(.tag); | 1092 | const tags = sema.code.instructions.items(.tag); |
| 1093 | const datas = sema.code.instructions.items(.data); | 1093 | const datas = sema.code.instructions.items(.data); |
| 1094 | const mod = block.ownerModule(); | ||
| 1095 | 1094 | ||
| 1096 | var crash_info = crash_report.prepAnalyzeBody(sema, block, body); | 1095 | var crash_info = crash_report.prepAnalyzeBody(sema, block, body); |
| 1097 | crash_info.push(); | 1096 | crash_info.push(); |
| ... | @@ -1405,16 +1404,6 @@ fn analyzeBodyInner( | ... | @@ -1405,16 +1404,6 @@ fn analyzeBodyInner( |
| 1405 | i += 1; | 1404 | i += 1; |
| 1406 | continue; | 1405 | continue; |
| 1407 | }, | 1406 | }, |
| 1408 | .deprecated => { | ||
| 1409 | if (!mod.allow_deprecated) { | ||
| 1410 | const src_node: i32 = @bitCast(extended.operand); | ||
| 1411 | const src = block.nodeOffset(src_node); | ||
| 1412 | return sema.fail(block, src, "reached deprecated code", .{}); | ||
| 1413 | } | ||
| 1414 | |||
| 1415 | i += 1; | ||
| 1416 | continue; | ||
| 1417 | }, | ||
| 1418 | .disable_instrumentation => { | 1407 | .disable_instrumentation => { |
| 1419 | try sema.zirDisableInstrumentation(); | 1408 | try sema.zirDisableInstrumentation(); |
| 1420 | i += 1; | 1409 | i += 1; |
src/main.zig-6| ... | @@ -520,8 +520,6 @@ const usage_build_generic = | ... | @@ -520,8 +520,6 @@ const usage_build_generic = |
| 520 | \\ -fno-sanitize-thread Disable Thread Sanitizer | 520 | \\ -fno-sanitize-thread Disable Thread Sanitizer |
| 521 | \\ -ffuzz Enable fuzz testing instrumentation | 521 | \\ -ffuzz Enable fuzz testing instrumentation |
| 522 | \\ -fno-fuzz Disable fuzz testing instrumentation | 522 | \\ -fno-fuzz Disable fuzz testing instrumentation |
| 523 | \\ -fallow-deprecated Allow usage of deprecated code | ||
| 524 | \\ -fno-allow-deprecated Disallow usage of deprecated code | ||
| 525 | \\ -funwind-tables Always produce unwind table entries for all functions | 523 | \\ -funwind-tables Always produce unwind table entries for all functions |
| 526 | \\ -fasync-unwind-tables Always produce asynchronous unwind table entries for all functions | 524 | \\ -fasync-unwind-tables Always produce asynchronous unwind table entries for all functions |
| 527 | \\ -fno-unwind-tables Never produce unwind table entries | 525 | \\ -fno-unwind-tables Never produce unwind table entries |
| ... | @@ -1456,10 +1454,6 @@ fn buildOutputType( | ... | @@ -1456,10 +1454,6 @@ fn buildOutputType( |
| 1456 | mod_opts.fuzz = true; | 1454 | mod_opts.fuzz = true; |
| 1457 | } else if (mem.eql(u8, arg, "-fno-fuzz")) { | 1455 | } else if (mem.eql(u8, arg, "-fno-fuzz")) { |
| 1458 | mod_opts.fuzz = false; | 1456 | mod_opts.fuzz = false; |
| 1459 | } else if (mem.eql(u8, arg, "-fallow-deprecated")) { | ||
| 1460 | mod_opts.allow_deprecated = true; | ||
| 1461 | } else if (mem.eql(u8, arg, "-fno-allow-deprecated")) { | ||
| 1462 | mod_opts.allow_deprecated = false; | ||
| 1463 | } else if (mem.eql(u8, arg, "-fllvm")) { | 1457 | } else if (mem.eql(u8, arg, "-fllvm")) { |
| 1464 | create_module.opts.use_llvm = true; | 1458 | create_module.opts.use_llvm = true; |
| 1465 | } else if (mem.eql(u8, arg, "-fno-llvm")) { | 1459 | } else if (mem.eql(u8, arg, "-fno-llvm")) { |
src/print_zir.zig-1| ... | @@ -535,7 +535,6 @@ const Writer = struct { | ... | @@ -535,7 +535,6 @@ const Writer = struct { |
| 535 | .c_va_start, | 535 | .c_va_start, |
| 536 | .in_comptime, | 536 | .in_comptime, |
| 537 | .value_placeholder, | 537 | .value_placeholder, |
| 538 | .deprecated, | ||
| 539 | => try self.writeExtNode(stream, extended), | 538 | => try self.writeExtNode(stream, extended), |
| 540 | 539 | ||
| 541 | .builtin_src => { | 540 | .builtin_src => { |
test/cases/compile_errors/deprecated.zig deleted-9| ... | @@ -1,9 +0,0 @@ | ||
| 1 | const bad = @deprecated(42); | ||
| 2 | |||
| 3 | pub export fn foo() usize { | ||
| 4 | return bad; | ||
| 5 | } | ||
| 6 | |||
| 7 | // error | ||
| 8 | // | ||
| 9 | // :1:13: error: reached deprecated code | ||
test/tests.zig-94| ... | @@ -1176,100 +1176,6 @@ pub fn addCliTests(b: *std.Build) *Step { | ... | @@ -1176,100 +1176,6 @@ pub fn addCliTests(b: *std.Build) *Step { |
| 1176 | step.dependOn(&cleanup.step); | 1176 | step.dependOn(&cleanup.step); |
| 1177 | } | 1177 | } |
| 1178 | 1178 | ||
| 1179 | { | ||
| 1180 | // Test `zig build -fallow-deprecated`. | ||
| 1181 | |||
| 1182 | const deprecated_check: std.Build.Step.Run.StdIo.Check = .{ | ||
| 1183 | .expect_stderr_match = "reached deprecated code", | ||
| 1184 | }; | ||
| 1185 | |||
| 1186 | const tmp_path = b.makeTempPath(); | ||
| 1187 | |||
| 1188 | // create custom main.zig file containing a deprecated decl | ||
| 1189 | { | ||
| 1190 | const new_main_src = | ||
| 1191 | \\const bad = @deprecated(42); | ||
| 1192 | \\ | ||
| 1193 | \\pub fn main() u8 { | ||
| 1194 | \\ return bad; | ||
| 1195 | \\} | ||
| 1196 | \\ | ||
| 1197 | \\test { | ||
| 1198 | \\ if (bad != 42) return error.Bad; | ||
| 1199 | \\} | ||
| 1200 | ; | ||
| 1201 | |||
| 1202 | var src_dir = std.fs.cwd().makeOpenPath(b.pathJoin(&.{ tmp_path, "src" }), .{}) catch @panic("unable to create tmp path"); | ||
| 1203 | defer src_dir.close(); | ||
| 1204 | |||
| 1205 | var main = src_dir.createFile("main.zig", .{}) catch @panic("unable to create main.zig"); | ||
| 1206 | defer main.close(); | ||
| 1207 | |||
| 1208 | main.writeAll(new_main_src) catch @panic("unable to write to main.zig"); | ||
| 1209 | } | ||
| 1210 | |||
| 1211 | const init_exe = b.addSystemCommand(&.{ b.graph.zig_exe, "init" }); | ||
| 1212 | init_exe.setCwd(.{ .cwd_relative = tmp_path }); | ||
| 1213 | init_exe.setName("zig init"); | ||
| 1214 | init_exe.expectStdOutEqual(""); | ||
| 1215 | init_exe.expectStdErrEqual("info: created build.zig\n" ++ | ||
| 1216 | "info: created build.zig.zon\n" ++ | ||
| 1217 | "info: preserving already existing file: src" ++ s ++ "main.zig\n" ++ | ||
| 1218 | "info: created src" ++ s ++ "root.zig\n"); | ||
| 1219 | |||
| 1220 | const run_test_bad = b.addSystemCommand(&.{ b.graph.zig_exe, "build", "test", "--color", "off" }); | ||
| 1221 | run_test_bad.setCwd(.{ .cwd_relative = tmp_path }); | ||
| 1222 | run_test_bad.setName("zig build test"); | ||
| 1223 | run_test_bad.expectExitCode(1); | ||
| 1224 | run_test_bad.expectStdOutEqual(""); | ||
| 1225 | run_test_bad.addCheck(deprecated_check); | ||
| 1226 | run_test_bad.step.dependOn(&init_exe.step); | ||
| 1227 | |||
| 1228 | const run_test = b.addSystemCommand(&.{ | ||
| 1229 | b.graph.zig_exe, | ||
| 1230 | "build", | ||
| 1231 | "test", | ||
| 1232 | "--color", | ||
| 1233 | "off", | ||
| 1234 | "-fallow-deprecated", | ||
| 1235 | }); | ||
| 1236 | run_test.setCwd(.{ .cwd_relative = tmp_path }); | ||
| 1237 | run_test.setName("zig build test"); | ||
| 1238 | run_test.expectExitCode(0); | ||
| 1239 | run_test.expectStdOutEqual(""); | ||
| 1240 | run_test.expectStdErrEqual(""); | ||
| 1241 | run_test.step.dependOn(&init_exe.step); | ||
| 1242 | |||
| 1243 | const run_build_bad = b.addSystemCommand(&.{ b.graph.zig_exe, "build", "--color", "off" }); | ||
| 1244 | run_build_bad.setCwd(.{ .cwd_relative = tmp_path }); | ||
| 1245 | run_build_bad.setName("zig build test"); | ||
| 1246 | run_build_bad.expectExitCode(1); | ||
| 1247 | run_build_bad.expectStdOutEqual(""); | ||
| 1248 | run_build_bad.addCheck(deprecated_check); | ||
| 1249 | run_build_bad.step.dependOn(&init_exe.step); | ||
| 1250 | |||
| 1251 | const run_build = b.addSystemCommand(&.{ | ||
| 1252 | b.graph.zig_exe, | ||
| 1253 | "build", | ||
| 1254 | "--color", | ||
| 1255 | "off", | ||
| 1256 | "-fallow-deprecated", | ||
| 1257 | }); | ||
| 1258 | run_build.setCwd(.{ .cwd_relative = tmp_path }); | ||
| 1259 | run_build.setName("zig build test"); | ||
| 1260 | run_build.expectExitCode(0); | ||
| 1261 | run_build.expectStdOutEqual(""); | ||
| 1262 | run_build.expectStdErrEqual(""); | ||
| 1263 | run_build.step.dependOn(&init_exe.step); | ||
| 1264 | |||
| 1265 | const cleanup = b.addRemoveDirTree(.{ .cwd_relative = tmp_path }); | ||
| 1266 | cleanup.step.dependOn(&run_test.step); | ||
| 1267 | cleanup.step.dependOn(&run_test_bad.step); | ||
| 1268 | cleanup.step.dependOn(&run_build.step); | ||
| 1269 | cleanup.step.dependOn(&run_build_bad.step); | ||
| 1270 | |||
| 1271 | step.dependOn(&cleanup.step); | ||
| 1272 | } | ||
| 1273 | // Test Godbolt API | 1179 | // Test Godbolt API |
| 1274 | if (builtin.os.tag == .linux and builtin.cpu.arch == .x86_64) { | 1180 | if (builtin.os.tag == .linux and builtin.cpu.arch == .x86_64) { |
| 1275 | const tmp_path = b.makeTempPath(); | 1181 | const tmp_path = b.makeTempPath(); |