Commit d3d24874c9

Andrew Kelley <andrew@ziglang.org>
2022-09-16 04:40:04
std: remove deprecated API for the upcoming release
See #3811
1 parent 7b32aac
lib/std/crypto/25519/edwards25519.zig
@@ -69,7 +69,6 @@ pub const Edwards25519 = struct {
         .is_base = true,
     };
 
-    pub const neutralElement = @compileError("deprecated: use identityElement instead");
     pub const identityElement = Edwards25519{ .x = Fe.zero, .y = Fe.one, .z = Fe.one, .t = Fe.zero };
 
     /// Reject the neutral element.
lib/std/math/complex.zig
@@ -34,8 +34,6 @@ pub fn Complex(comptime T: type) type {
         /// Imaginary part.
         im: T,
 
-        pub const new = @compileError("deprecated; use init()");
-
         /// Create a new Complex number from the given real and imaginary parts.
         pub fn init(re: T, im: T) Self {
             return Self{
lib/std/array_hash_map.zig
@@ -201,8 +201,6 @@ pub fn ArrayHashMap(
             return self.unmanaged.getOrPutValueContext(self.allocator, key, value, self.ctx);
         }
 
-        pub const ensureCapacity = @compileError("deprecated; call `ensureUnusedCapacity` or `ensureTotalCapacity`");
-
         /// Increases capacity, guaranteeing that insertions up until the
         /// `expected_count` will not cause an allocation, and therefore cannot fail.
         pub fn ensureTotalCapacity(self: *Self, new_capacity: usize) !void {
@@ -755,8 +753,6 @@ pub fn ArrayHashMapUnmanaged(
             return res;
         }
 
-        pub const ensureCapacity = @compileError("deprecated; call `ensureUnusedCapacity` or `ensureTotalCapacity`");
-
         /// Increases capacity, guaranteeing that insertions up until the
         /// `expected_count` will not cause an allocation, and therefore cannot fail.
         pub fn ensureTotalCapacity(self: *Self, allocator: Allocator, new_capacity: usize) !void {
lib/std/array_list.zig
@@ -83,8 +83,6 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
             };
         }
 
-        pub const toUnmanaged = @compileError("deprecated; use `moveToUnmanaged` which has different semantics.");
-
         /// Initializes an ArrayListUnmanaged with the `items` and `capacity` fields
         /// of this ArrayList. Empties this ArrayList.
         pub fn moveToUnmanaged(self: *Self) ArrayListAlignedUnmanaged(T, alignment) {
@@ -325,8 +323,6 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
             self.capacity = 0;
         }
 
-        pub const ensureCapacity = @compileError("deprecated; call `ensureUnusedCapacity` or `ensureTotalCapacity`");
-
         /// Modify the array so that it can hold at least `new_capacity` items.
         /// Invalidates pointers if additional memory is needed.
         pub fn ensureTotalCapacity(self: *Self, new_capacity: usize) Allocator.Error!void {
@@ -721,8 +717,6 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
             self.capacity = 0;
         }
 
-        pub const ensureCapacity = @compileError("deprecated; call `ensureUnusedCapacity` or `ensureTotalCapacity`");
-
         /// Modify the array so that it can hold at least `new_capacity` items.
         /// Invalidates pointers if additional memory is needed.
         pub fn ensureTotalCapacity(self: *Self, allocator: Allocator, new_capacity: usize) Allocator.Error!void {
lib/std/base64.zig
@@ -69,10 +69,6 @@ pub const url_safe_no_pad = Codecs{
     .Decoder = Base64Decoder.init(url_safe_alphabet_chars, null),
 };
 
-pub const standard_pad_char = @compileError("deprecated; use standard.pad_char");
-pub const standard_encoder = @compileError("deprecated; use standard.Encoder");
-pub const standard_decoder = @compileError("deprecated; use standard.Decoder");
-
 pub const Base64Encoder = struct {
     alphabet_chars: [64]u8,
     pad_char: ?u8,
lib/std/build.zig
@@ -1339,13 +1339,6 @@ test "builder.findProgram compiles" {
     _ = builder.findProgram(&[_][]const u8{}, &[_][]const u8{}) catch null;
 }
 
-/// TODO: propose some kind of `@deprecate` builtin so that we can deprecate
-/// this while still having somewhat non-lazy decls. In this file we wanted to do
-/// refAllDecls for example which makes it trigger `@compileError` if you try
-/// to use that strategy.
-pub const Version = @compileError("deprecated; Use `std.builtin.Version`");
-pub const Target = @compileError("deprecated; Use `std.zig.CrossTarget`");
-
 pub const Pkg = struct {
     name: []const u8,
     source: FileSource,
@@ -2314,29 +2307,19 @@ pub const LibExeObjStep = struct {
         self.linkLibraryOrObject(obj);
     }
 
-    /// TODO deprecated, use `addSystemIncludePath`.
-    pub fn addSystemIncludeDir(self: *LibExeObjStep, path: []const u8) void {
-        self.addSystemIncludePath(path);
-    }
+    pub const addSystemIncludeDir = @compileError("deprecated; use addSystemIncludePath");
+    pub const addIncludeDir = @compileError("deprecated; use addIncludePath");
+    pub const addLibPath = @compileError("deprecated, use addLibraryPath");
+    pub const addFrameworkDir = @compileError("deprecated, use addFrameworkPath");
 
     pub fn addSystemIncludePath(self: *LibExeObjStep, path: []const u8) void {
         self.include_dirs.append(IncludeDir{ .raw_path_system = self.builder.dupe(path) }) catch unreachable;
     }
 
-    /// TODO deprecated, use `addIncludePath`.
-    pub fn addIncludeDir(self: *LibExeObjStep, path: []const u8) void {
-        self.addIncludePath(path);
-    }
-
     pub fn addIncludePath(self: *LibExeObjStep, path: []const u8) void {
         self.include_dirs.append(IncludeDir{ .raw_path = self.builder.dupe(path) }) catch unreachable;
     }
 
-    /// TODO deprecated, use `addLibraryPath`.
-    pub fn addLibPath(self: *LibExeObjStep, path: []const u8) void {
-        self.addLibraryPath(path);
-    }
-
     pub fn addLibraryPath(self: *LibExeObjStep, path: []const u8) void {
         self.lib_paths.append(self.builder.dupe(path)) catch unreachable;
     }
@@ -2345,11 +2328,6 @@ pub const LibExeObjStep = struct {
         self.rpaths.append(self.builder.dupe(path)) catch unreachable;
     }
 
-    /// TODO deprecated, use `addFrameworkPath`.
-    pub fn addFrameworkDir(self: *LibExeObjStep, dir_path: []const u8) void {
-        self.addFrameworkPath(dir_path);
-    }
-
     pub fn addFrameworkPath(self: *LibExeObjStep, dir_path: []const u8) void {
         self.framework_dirs.append(self.builder.dupe(dir_path)) catch unreachable;
     }
lib/std/builtin.zig
@@ -184,9 +184,7 @@ pub const SourceLocation = struct {
 };
 
 pub const TypeId = std.meta.Tag(Type);
-
-/// TODO deprecated, use `Type`
-pub const TypeInfo = Type;
+pub const TypeInfo = @compileError("deprecated; use Type");
 
 /// This data structure is used by the Zig language code generation and
 /// therefore must be kept in sync with the compiler implementation.
@@ -359,8 +357,7 @@ pub const Type = union(enum) {
         decls: []const Declaration,
     };
 
-    /// TODO deprecated use Fn.Param
-    pub const FnArg = Fn.Param;
+    pub const FnArg = @compileError("deprecated; use Fn.Param");
 
     /// This data structure is used by the Zig language code generation and
     /// therefore must be kept in sync with the compiler implementation.
lib/std/fmt.zig
@@ -1885,7 +1885,6 @@ test "parseUnsigned" {
 }
 
 pub const parseFloat = @import("fmt/parse_float.zig").parseFloat;
-pub const parseHexFloat = @compileError("deprecated; use `parseFloat`");
 pub const ParseFloatError = @import("fmt/parse_float.zig").ParseFloatError;
 
 test {
@@ -1948,8 +1947,6 @@ pub fn allocPrint(allocator: mem.Allocator, comptime fmt: []const u8, args: anyt
     };
 }
 
-pub const allocPrint0 = @compileError("deprecated; use allocPrintZ");
-
 pub fn allocPrintZ(allocator: mem.Allocator, comptime fmt: []const u8, args: anytype) AllocPrintError![:0]u8 {
     const result = try allocPrint(allocator, fmt ++ "\x00", args);
     return result[0 .. result.len - 1 :0];
lib/std/hash_map.zig
@@ -120,8 +120,6 @@ pub const StringIndexAdapter = struct {
     }
 };
 
-pub const DefaultMaxLoadPercentage = @compileError("deprecated; use `default_max_load_percentage`");
-
 pub const default_max_load_percentage = 80;
 
 /// This function issues a compile error with a helpful message if there
@@ -517,8 +515,6 @@ pub fn HashMap(
             return self.unmanaged.getOrPutValueContext(self.allocator, key, value, self.ctx);
         }
 
-        pub const ensureCapacity = @compileError("deprecated; call `ensureUnusedCapacity` or `ensureTotalCapacity`");
-
         /// Increases capacity, guaranteeing that insertions up until the
         /// `expected_count` will not cause an allocation, and therefore cannot fail.
         pub fn ensureTotalCapacity(self: *Self, expected_count: Size) Allocator.Error!void {
@@ -900,8 +896,6 @@ pub fn HashMapUnmanaged(
             return new_cap;
         }
 
-        pub const ensureCapacity = @compileError("deprecated; call `ensureUnusedCapacity` or `ensureTotalCapacity`");
-
         pub fn ensureTotalCapacity(self: *Self, allocator: Allocator, new_size: Size) Allocator.Error!void {
             if (@sizeOf(Context) != 0)
                 @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call ensureTotalCapacityContext instead.");
lib/std/log.zig
@@ -169,10 +169,6 @@ pub fn defaultLog(
 /// provided here.
 pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
     return struct {
-        pub const emerg = @compileError("deprecated; use err instead of emerg");
-        pub const alert = @compileError("deprecated; use err instead of alert");
-        pub const crit = @compileError("deprecated; use err instead of crit");
-
         /// Log an error message. This log level is intended to be used
         /// when something has gone wrong. This might be recoverable or might
         /// be followed by the program exiting.
@@ -194,8 +190,6 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
             log(.warn, scope, format, args);
         }
 
-        pub const notice = @compileError("deprecated; use info instead of notice");
-
         /// Log an info message. This log level is intended to be used for
         /// general messages about the state of the program.
         pub fn info(
@@ -219,10 +213,6 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
 /// The default scoped logging namespace.
 pub const default = scoped(.default);
 
-pub const emerg = @compileError("deprecated; use err instead of emerg");
-pub const alert = @compileError("deprecated; use err instead of alert");
-pub const crit = @compileError("deprecated; use err instead of crit");
-
 /// Log an error message using the default scope. This log level is intended to
 /// be used when something has gone wrong. This might be recoverable or might
 /// be followed by the program exiting.
@@ -233,8 +223,6 @@ pub const err = default.err;
 /// the circumstances would be worth investigating.
 pub const warn = default.warn;
 
-pub const notice = @compileError("deprecated; use info instead of notice");
-
 /// Log an info message using the default scope. This log level is intended to
 /// be used for general messages about the state of the program.
 pub const info = default.info;
lib/std/math.zig
@@ -170,13 +170,6 @@ pub fn approxEqRel(comptime T: type, x: T, y: T, tolerance: T) bool {
     return @fabs(x - y) <= max(@fabs(x), @fabs(y)) * tolerance;
 }
 
-pub fn approxEq(comptime T: type, x: T, y: T, tolerance: T) bool {
-    _ = x;
-    _ = y;
-    _ = tolerance;
-    @compileError("deprecated; use `approxEqAbs` or `approxEqRel`");
-}
-
 test "approxEqAbs and approxEqRel" {
     inline for ([_]type{ f16, f32, f64, f128 }) |T| {
         const eps_value = comptime floatEps(T);
lib/std/mem.zig
@@ -702,8 +702,6 @@ test "span" {
     try testing.expectEqual(@as(?[:0]u16, null), span(@as(?[*:0]u16, null)));
 }
 
-pub const spanZ = @compileError("deprecated; use use std.mem.span() or std.mem.sliceTo()");
-
 /// Helper for the return type of sliceTo()
 fn SliceTo(comptime T: type, comptime end: meta.Elem(T)) type {
     switch (@typeInfo(T)) {
@@ -957,8 +955,6 @@ test "len" {
     }
 }
 
-pub const lenZ = @compileError("deprecated; use std.mem.len() or std.mem.sliceTo().len");
-
 pub fn indexOfSentinel(comptime Elem: type, comptime sentinel: Elem, ptr: [*:sentinel]const Elem) usize {
     var i: usize = 0;
     while (ptr[i] != sentinel) {
@@ -975,9 +971,6 @@ pub fn allEqual(comptime T: type, slice: []const T, scalar: T) bool {
     return true;
 }
 
-pub const dupe = @compileError("deprecated; use `Allocator.dupe`");
-pub const dupeZ = @compileError("deprecated; use `Allocator.dupeZ`");
-
 /// Remove values from the beginning of a slice.
 pub fn trimLeft(comptime T: type, slice: []const T, values_to_strip: []const T) []const T {
     var begin: usize = 0;
@@ -1567,9 +1560,6 @@ test "writeIntBig and writeIntLittle" {
     try testing.expect(eql(u8, buf2[0..], &[_]u8{ 0xfc, 0xff }));
 }
 
-/// TODO delete this deprecated declaration after 0.10.0 is released
-pub const bswapAllFields = @compileError("bswapAllFields has been renamed to byteSwapAllFields");
-
 /// Swap the byte order of all the members of the fields of a struct
 /// (Changing their endianess)
 pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {
lib/std/multi_array_list.zig
@@ -334,8 +334,6 @@ pub fn MultiArrayList(comptime S: type) type {
             self.len = new_len;
         }
 
-        pub const ensureCapacity = @compileError("deprecated; call `ensureUnusedCapacity` or `ensureTotalCapacity`");
-
         /// Modify the array so that it can hold at least `new_capacity` items.
         /// Implements super-linear growth to achieve amortized O(1) append operations.
         /// Invalidates pointers if additional memory is needed.
lib/std/priority_dequeue.zig
@@ -357,8 +357,6 @@ pub fn PriorityDequeue(comptime T: type, comptime Context: type, comptime compar
             return queue;
         }
 
-        pub const ensureCapacity = @compileError("deprecated; call `ensureUnusedCapacity` or `ensureTotalCapacity`");
-
         /// Ensure that the dequeue can fit at least `new_capacity` items.
         pub fn ensureTotalCapacity(self: *Self, new_capacity: usize) !void {
             var better_capacity = self.capacity();
lib/std/priority_queue.zig
@@ -185,8 +185,6 @@ pub fn PriorityQueue(comptime T: type, comptime Context: type, comptime compareF
             return queue;
         }
 
-        pub const ensureCapacity = @compileError("deprecated; use ensureUnusedCapacity or ensureTotalCapacity");
-
         /// Ensure that the queue can fit at least `new_capacity` items.
         pub fn ensureTotalCapacity(self: *Self, new_capacity: usize) !void {
             var better_capacity = self.capacity();
src/Autodoc.zig
@@ -531,7 +531,7 @@ const DocData = struct {
         Int: struct { name: []const u8 },
         Float: struct { name: []const u8 },
         Pointer: struct {
-            size: std.builtin.TypeInfo.Pointer.Size,
+            size: std.builtin.Type.Pointer.Size,
             child: Expr,
             sentinel: ?Expr = null,
             @"align": ?Expr = null,
@@ -641,7 +641,7 @@ const DocData = struct {
                     const current_value = @field(self, case.name);
                     inline for (comptime std.meta.fields(case.field_type)) |f| {
                         try jsw.arrayElem();
-                        if (f.field_type == std.builtin.TypeInfo.Pointer.Size) {
+                        if (f.field_type == std.builtin.Type.Pointer.Size) {
                             try jsw.emitNumber(@enumToInt(@field(current_value, f.name)));
                         } else {
                             try std.json.stringify(@field(current_value, f.name), opts, w);