| ... | ... | @@ -15257,46 +15257,6 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr, |
| 15257 | 15257 | } |
| 15258 | 15258 | } |
| 15259 | 15259 | |
| 15260 | | // *[N]T to E![]T |
| 15261 | | if (wanted_type->id == ZigTypeIdErrorUnion && |
| 15262 | | is_slice(wanted_type->data.error_union.payload_type) && |
| 15263 | | actual_type->id == ZigTypeIdPointer && |
| 15264 | | actual_type->data.pointer.ptr_len == PtrLenSingle && |
| 15265 | | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 15266 | | { |
| 15267 | | ZigType *slice_type = wanted_type->data.error_union.payload_type; |
| 15268 | | ZigType *slice_ptr_type = slice_type->data.structure.fields[slice_ptr_index]->type_entry; |
| 15269 | | assert(slice_ptr_type->id == ZigTypeIdPointer); |
| 15270 | | ZigType *array_type = actual_type->data.pointer.child_type; |
| 15271 | | bool const_ok = (slice_ptr_type->data.pointer.is_const || array_type->data.array.len == 0 |
| 15272 | | || !actual_type->data.pointer.is_const); |
| 15273 | | if (const_ok && types_match_const_cast_only(ira, slice_ptr_type->data.pointer.child_type, |
| 15274 | | array_type->data.array.child_type, source_node, |
| 15275 | | !slice_ptr_type->data.pointer.is_const).id == ConstCastResultIdOk) |
| 15276 | | { |
| 15277 | | // If the pointers both have ABI align, it works. |
| 15278 | | bool ok_align = slice_ptr_type->data.pointer.explicit_alignment == 0 && |
| 15279 | | actual_type->data.pointer.explicit_alignment == 0; |
| 15280 | | if (!ok_align) { |
| 15281 | | // If either one has non ABI align, we have to resolve them both |
| 15282 | | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, |
| 15283 | | ResolveStatusAlignmentKnown))) |
| 15284 | | { |
| 15285 | | return ira->codegen->invalid_inst_gen; |
| 15286 | | } |
| 15287 | | if ((err = type_resolve(ira->codegen, slice_ptr_type->data.pointer.child_type, |
| 15288 | | ResolveStatusAlignmentKnown))) |
| 15289 | | { |
| 15290 | | return ira->codegen->invalid_inst_gen; |
| 15291 | | } |
| 15292 | | ok_align = get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, slice_ptr_type); |
| 15293 | | } |
| 15294 | | if (ok_align) { |
| 15295 | | return ir_resolve_ptr_of_array_to_slice(ira, source_instr, value, slice_type, nullptr); |
| 15296 | | } |
| 15297 | | } |
| 15298 | | } |
| 15299 | | |
| 15300 | 15260 | // @Vector(N,T1) to @Vector(N,T2) |
| 15301 | 15261 | if (actual_type->id == ZigTypeIdVector && wanted_type->id == ZigTypeIdVector) { |
| 15302 | 15262 | if (actual_type->data.vector.len == wanted_type->data.vector.len && |