ir: remove redundant casting code
parent
ef5d7ce463
commit
67fbb0434f
19
src/ir.cpp
19
src/ir.cpp
|
@ -10421,25 +10421,6 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cast from *const [N]T to []const T
|
|
||||||
if (is_slice(wanted_type) &&
|
|
||||||
actual_type->id == ZigTypeIdPointer &&
|
|
||||||
actual_type->data.pointer.is_const &&
|
|
||||||
actual_type->data.pointer.child_type->id == ZigTypeIdArray)
|
|
||||||
{
|
|
||||||
ZigType *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
|
|
||||||
assert(ptr_type->id == ZigTypeIdPointer);
|
|
||||||
|
|
||||||
ZigType *array_type = actual_type->data.pointer.child_type;
|
|
||||||
|
|
||||||
if ((ptr_type->data.pointer.is_const || array_type->data.array.len == 0) &&
|
|
||||||
types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, array_type->data.array.child_type,
|
|
||||||
source_node, false).id == ConstCastResultIdOk)
|
|
||||||
{
|
|
||||||
return ir_analyze_array_to_slice(ira, source_instr, value, wanted_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// cast from [N]T to ?[]const T
|
// cast from [N]T to ?[]const T
|
||||||
if (wanted_type->id == ZigTypeIdOptional &&
|
if (wanted_type->id == ZigTypeIdOptional &&
|
||||||
is_slice(wanted_type->data.maybe.child_type) &&
|
is_slice(wanted_type->data.maybe.child_type) &&
|
||||||
|
|
Loading…
Reference in New Issue