Commit e077a44656
Changed files (3)
src/all_types.hpp
@@ -605,7 +605,6 @@ enum CastOp {
CastOpFloatToInt,
CastOpBoolToInt,
CastOpResizeSlice,
- CastOpBytesToSlice,
CastOpNumLitToConcrete,
CastOpErrSet,
CastOpBitCast,
src/codegen.cpp
@@ -2882,32 +2882,6 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
gen_store_untyped(g, new_len, dest_len_ptr, 0, false);
- return cast_instruction->tmp_ptr;
- }
- case CastOpBytesToSlice:
- {
- assert(cast_instruction->tmp_ptr);
- assert(wanted_type->id == ZigTypeIdStruct);
- assert(wanted_type->data.structure.is_slice);
- assert(actual_type->id == ZigTypeIdArray);
-
- ZigType *wanted_pointer_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
- ZigType *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
-
-
- size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index;
- LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
- (unsigned)wanted_ptr_index, "");
- LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, expr_val, wanted_pointer_type->type_ref, "");
- gen_store_untyped(g, src_ptr_casted, dest_ptr_ptr, 0, false);
-
- size_t wanted_len_index = wanted_type->data.structure.fields[1].gen_index;
- LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
- (unsigned)wanted_len_index, "");
- LLVMValueRef len_val = LLVMConstInt(g->builtin_types.entry_usize->type_ref,
- actual_type->data.array.len / type_size(g, wanted_child_type), false);
- gen_store_untyped(g, len_val, len_ptr, 0, false);
-
return cast_instruction->tmp_ptr;
}
case CastOpIntToFloat:
src/ir.cpp
@@ -9339,7 +9339,6 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_
const_val->type = new_type;
break;
case CastOpResizeSlice:
- case CastOpBytesToSlice:
// can't do it
zig_unreachable();
case CastOpIntToFloat:
@@ -9396,7 +9395,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst
ZigType *wanted_type, CastOp cast_op, bool need_alloca)
{
if ((instr_is_comptime(value) || !type_has_bits(wanted_type)) &&
- cast_op != CastOpResizeSlice && cast_op != CastOpBytesToSlice)
+ cast_op != CastOpResizeSlice)
{
IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
source_instr->source_node, wanted_type);