aboutsummaryrefslogtreecommitdiff
path: root/lib/std/meta.zig
diff options
context:
space:
mode:
authorLachlan Easton <lachlan@lakebythewoods.xyz>2020-09-03 20:16:12 +1000
committerAndrew Kelley <andrew@ziglang.org>2020-09-03 14:11:04 -0400
commit2a58e30bd5f522bf3077f556f47a1e28c537627e (patch)
treefc3d6ee155a6b8ecc7287cc308f330da410a1acb /lib/std/meta.zig
parent39a80cf59e082b57606e5ddc074b5ae1337c0d79 (diff)
downloadzig-2a58e30bd5f522bf3077f556f47a1e28c537627e.tar.gz
zig-2a58e30bd5f522bf3077f556f47a1e28c537627e.zip
std meta: fix use of alignOf in meta.cast
Diffstat (limited to 'lib/std/meta.zig')
-rw-r--r--lib/std/meta.zig16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index aaa8e7ca78..73e0661498 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -705,34 +705,34 @@ pub fn Vector(comptime len: u32, comptime child: type) type {
pub fn cast(comptime DestType: type, target: anytype) DestType {
const TargetType = @TypeOf(target);
switch (@typeInfo(DestType)) {
- .Pointer => {
+ .Pointer => |dest_ptr| {
switch (@typeInfo(TargetType)) {
.Int, .ComptimeInt => {
return @intToPtr(DestType, target);
},
.Pointer => |ptr| {
- return @ptrCast(DestType, @alignCast(ptr.alignment, target));
+ return @ptrCast(DestType, @alignCast(dest_ptr.alignment, target));
},
.Optional => |opt| {
if (@typeInfo(opt.child) == .Pointer) {
- return @ptrCast(DestType, @alignCast(@alignOf(opt.child.Child), target));
+ return @ptrCast(DestType, @alignCast(dest_ptr, target));
}
},
else => {},
}
},
- .Optional => |opt| {
- if (@typeInfo(opt.child) == .Pointer) {
+ .Optional => |dest_opt| {
+ if (@typeInfo(dest_opt.child) == .Pointer) {
switch (@typeInfo(TargetType)) {
.Int, .ComptimeInt => {
return @intToPtr(DestType, target);
},
- .Pointer => |ptr| {
- return @ptrCast(DestType, @alignCast(ptr.alignment, target));
+ .Pointer => {
+ return @ptrCast(DestType, @alignCast(@alignOf(dest_opt.child.Child), target));
},
.Optional => |target_opt| {
if (@typeInfo(target_opt.child) == .Pointer) {
- return @ptrCast(DestType, @alignCast(@alignOf(target_opt.child.Child), target));
+ return @ptrCast(DestType, @alignCast(@alignOf(dest_opt.child.Child), target));
}
},
else => {},