authorgravatar for lachlan@lakebythewoods.xyzLachlan Easton <lachlan@lakebythewoods.xyz> 2020-09-03 20:16:12+10:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-03 14:11:04-04:00
log2a58e30bd5f522bf3077f556f47a1e28c537627e
treefc3d6ee155a6b8ecc7287cc308f330da410a1acb
parent39a80cf59e082b57606e5ddc074b5ae1337c0d79

std meta: fix use of alignOf in meta.cast


1 files changed, 8 insertions(+), 8 deletions(-)

lib/std/meta.zig+8-8
......@@ -705,34 +705,34 @@ pub fn Vector(comptime len: u32, comptime child: type) type {
705705pub fn cast(comptime DestType: type, target: anytype) DestType {
706706 const TargetType = @TypeOf(target);
707707 switch (@typeInfo(DestType)) {
708 .Pointer => {
708 .Pointer => |dest_ptr| {
709709 switch (@typeInfo(TargetType)) {
710710 .Int, .ComptimeInt => {
711711 return @intToPtr(DestType, target);
712712 },
713713 .Pointer => |ptr| {
714 return @ptrCast(DestType, @alignCast(ptr.alignment, target));
714 return @ptrCast(DestType, @alignCast(dest_ptr.alignment, target));
715715 },
716716 .Optional => |opt| {
717717 if (@typeInfo(opt.child) == .Pointer) {
718 return @ptrCast(DestType, @alignCast(@alignOf(opt.child.Child), target));
718 return @ptrCast(DestType, @alignCast(dest_ptr, target));
719719 }
720720 },
721721 else => {},
722722 }
723723 },
724 .Optional => |opt| {
725 if (@typeInfo(opt.child) == .Pointer) {
724 .Optional => |dest_opt| {
725 if (@typeInfo(dest_opt.child) == .Pointer) {
726726 switch (@typeInfo(TargetType)) {
727727 .Int, .ComptimeInt => {
728728 return @intToPtr(DestType, target);
729729 },
730 .Pointer => |ptr| {
731 return @ptrCast(DestType, @alignCast(ptr.alignment, target));
730 .Pointer => {
731 return @ptrCast(DestType, @alignCast(@alignOf(dest_opt.child.Child), target));
732732 },
733733 .Optional => |target_opt| {
734734 if (@typeInfo(target_opt.child) == .Pointer) {
735 return @ptrCast(DestType, @alignCast(@alignOf(target_opt.child.Child), target));
735 return @ptrCast(DestType, @alignCast(@alignOf(dest_opt.child.Child), target));
736736 }
737737 },
738738 else => {},