Merge pull request #18729 from Vexu/fixes

Fix some generic{Reader,Writer} related issues
This commit is contained in:
Andrew Kelley
2024-01-29 13:07:37 -08:00
committed by GitHub
6 changed files with 113 additions and 3 deletions

View File

@@ -22368,7 +22368,10 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData
try sema.requireRuntimeBlock(block, src, operand_src);
const err_int_ty = try mod.errorIntType();
if (block.wantSafety() and !dest_ty.isAnyError(mod) and sema.mod.backendSupportsFeature(.error_set_has_value)) {
if (block.wantSafety() and !dest_ty.isAnyError(mod) and
dest_ty.toIntern() != .adhoc_inferred_error_set_type and
sema.mod.backendSupportsFeature(.error_set_has_value))
{
if (dest_tag == .ErrorUnion) {
const err_code = try sema.analyzeErrUnionCode(block, operand_src, operand);
const err_int = try block.addBitCast(err_int_ty, err_code);

View File

@@ -8694,10 +8694,10 @@ pub const FuncGen = struct {
if (!result_is_ref) {
return self.dg.todo("implement bitcast vector to non-ref array", .{});
}
const array_ptr = try self.buildAllocaWorkaround(inst_ty, .default);
const alignment = inst_ty.abiAlignment(mod).toLlvm();
const array_ptr = try self.buildAllocaWorkaround(inst_ty, alignment);
const bitcast_ok = elem_ty.bitSize(mod) == elem_ty.abiSize(mod) * 8;
if (bitcast_ok) {
const alignment = inst_ty.abiAlignment(mod).toLlvm();
_ = try self.wip.store(.normal, operand, array_ptr, alignment);
} else {
// If the ABI size of the element type is not evenly divisible by size in bits;

View File

@@ -1550,6 +1550,8 @@ pub const Value = struct {
},
.ptr => |ptr| switch (ptr.addr) {
.eu_payload, .opt_payload => |base| Value.fromInterned(base).canMutateComptimeVarState(mod),
.anon_decl => |anon_decl| Value.fromInterned(anon_decl.val).canMutateComptimeVarState(mod),
.elem, .field => |base_index| Value.fromInterned(base_index.base).canMutateComptimeVarState(mod),
else => false,
},
.opt => |opt| switch (opt.val) {