mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 07:03:11 +00:00
std.meta: remove Vector (deprecated in 0.10)
Followup to d42d31f72f38165f70c2850e9cc63da44b3b470c. Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
This commit is contained in:
parent
df6319418a
commit
eb4439f1e4
@ -408,13 +408,13 @@ test "testHash union" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "testHash vector" {
|
test "testHash vector" {
|
||||||
const a: meta.Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };
|
const a: @Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };
|
||||||
const b: meta.Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };
|
const b: @Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };
|
||||||
try testing.expect(testHash(a) == testHash(a));
|
try testing.expect(testHash(a) == testHash(a));
|
||||||
try testing.expect(testHash(a) != testHash(b));
|
try testing.expect(testHash(a) != testHash(b));
|
||||||
|
|
||||||
const c: meta.Vector(4, u31) = [_]u31{ 1, 2, 3, 4 };
|
const c: @Vector(4, u31) = [_]u31{ 1, 2, 3, 4 };
|
||||||
const d: meta.Vector(4, u31) = [_]u31{ 1, 2, 3, 5 };
|
const d: @Vector(4, u31) = [_]u31{ 1, 2, 3, 5 };
|
||||||
try testing.expect(testHash(c) == testHash(c));
|
try testing.expect(testHash(c) == testHash(c));
|
||||||
try testing.expect(testHash(c) != testHash(d));
|
try testing.expect(testHash(c) != testHash(d));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -146,7 +146,7 @@ test "std.meta.Child" {
|
|||||||
try testing.expect(Child(*u8) == u8);
|
try testing.expect(Child(*u8) == u8);
|
||||||
try testing.expect(Child([]u8) == u8);
|
try testing.expect(Child([]u8) == u8);
|
||||||
try testing.expect(Child(?u8) == u8);
|
try testing.expect(Child(?u8) == u8);
|
||||||
try testing.expect(Child(Vector(2, u8)) == u8);
|
try testing.expect(Child(@Vector(2, u8)) == u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a "memory span" type (array, slice, vector, or pointer to such), returns the "element type".
|
/// Given a "memory span" type (array, slice, vector, or pointer to such), returns the "element type".
|
||||||
@ -173,8 +173,8 @@ test "std.meta.Elem" {
|
|||||||
try testing.expect(Elem([*]u8) == u8);
|
try testing.expect(Elem([*]u8) == u8);
|
||||||
try testing.expect(Elem([]u8) == u8);
|
try testing.expect(Elem([]u8) == u8);
|
||||||
try testing.expect(Elem(*[10]u8) == u8);
|
try testing.expect(Elem(*[10]u8) == u8);
|
||||||
try testing.expect(Elem(Vector(2, u8)) == u8);
|
try testing.expect(Elem(@Vector(2, u8)) == u8);
|
||||||
try testing.expect(Elem(*Vector(2, u8)) == u8);
|
try testing.expect(Elem(*@Vector(2, u8)) == u8);
|
||||||
try testing.expect(Elem(?[*]u8) == u8);
|
try testing.expect(Elem(?[*]u8) == u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1014,16 +1014,6 @@ test "std.meta.Float" {
|
|||||||
try testing.expectEqual(f128, Float(128));
|
try testing.expectEqual(f128, Float(128));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated. Use `@Vector`.
|
|
||||||
pub fn Vector(comptime len: u32, comptime child: type) type {
|
|
||||||
return @Type(.{
|
|
||||||
.Vector = .{
|
|
||||||
.len = len,
|
|
||||||
.child = child,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// For a given function type, returns a tuple type which fields will
|
/// For a given function type, returns a tuple type which fields will
|
||||||
/// correspond to the argument types.
|
/// correspond to the argument types.
|
||||||
///
|
///
|
||||||
|
|||||||
@ -271,7 +271,7 @@ pub fn isIndexable(comptime T: type) bool {
|
|||||||
test "isIndexable" {
|
test "isIndexable" {
|
||||||
const array = [_]u8{0} ** 10;
|
const array = [_]u8{0} ** 10;
|
||||||
const slice = @as([]const u8, &array);
|
const slice = @as([]const u8, &array);
|
||||||
const vector: meta.Vector(2, u32) = [_]u32{0} ** 2;
|
const vector: @Vector(2, u32) = [_]u32{0} ** 2;
|
||||||
const tuple = .{ 1, 2, 3 };
|
const tuple = .{ 1, 2, 3 };
|
||||||
|
|
||||||
try testing.expect(isIndexable(@TypeOf(array)));
|
try testing.expect(isIndexable(@TypeOf(array)));
|
||||||
|
|||||||
@ -2,8 +2,7 @@ export fn f1(x: u32) u32 {
|
|||||||
const y = -%x;
|
const y = -%x;
|
||||||
return -y;
|
return -y;
|
||||||
}
|
}
|
||||||
const V = @import("std").meta.Vector;
|
export fn f2(x: @Vector(4, u32)) @Vector(4, u32) {
|
||||||
export fn f2(x: V(4, u32)) V(4, u32) {
|
|
||||||
const y = -%x;
|
const y = -%x;
|
||||||
return -y;
|
return -y;
|
||||||
}
|
}
|
||||||
@ -13,4 +12,4 @@ export fn f2(x: V(4, u32)) V(4, u32) {
|
|||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :3:12: error: negation of type 'u32'
|
// :3:12: error: negation of type 'u32'
|
||||||
// :8:12: error: negation of type '@Vector(4, u32)'
|
// :7:12: error: negation of type '@Vector(4, u32)'
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
comptime {
|
comptime {
|
||||||
var a: @import("std").meta.Vector(4, u8) = [_]u8{ 1, 2, 255, 4 };
|
var a: @Vector(4, u8) = [_]u8{ 1, 2, 255, 4 };
|
||||||
var b: @import("std").meta.Vector(4, u8) = [_]u8{ 5, 6, 1, 8 };
|
var b: @Vector(4, u8) = [_]u8{ 5, 6, 1, 8 };
|
||||||
var x = a + b;
|
var x = a + b;
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
const V1 = @import("std").meta.Vector(4, u8);
|
const V1 = @Vector(4, u8);
|
||||||
const V2 = @Type(.{ .Vector = .{ .len = 4, .child = V1 } });
|
const V2 = @Type(.{ .Vector = .{ .len = 4, .child = V1 } });
|
||||||
var v: V2 = undefined;
|
var v: V2 = undefined;
|
||||||
_ = v;
|
_ = v;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
const v: @import("std").meta.Vector(4, u32) = [4]u32{ 10, 11, 12, 13 };
|
const v: @Vector(4, u32) = [4]u32{ 10, 11, 12, 13 };
|
||||||
const x: @import("std").meta.Vector(4, u32) = [4]u32{ 14, 15, 16, 17 };
|
const x: @Vector(4, u32) = [4]u32{ 14, 15, 16, 17 };
|
||||||
var z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 });
|
var z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 });
|
||||||
_ = z;
|
_ = z;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
const x = @import("std").meta.Vector(3, f32){ 25, 75, 5, 0 };
|
const x = @Vector(3, f32){ 25, 75, 5, 0 };
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7,4 +7,4 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :2:49: error: expected 3 vector elements; found 4
|
// :2:30: error: expected 3 vector elements; found 4
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user