Skip to content

Remove @OpaqueType #6208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/std/zig/render.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,10 @@ fn renderExpression(
.BuiltinCall => {
const builtin_call = @fieldParentPtr(ast.Node.BuiltinCall, "base", base);

// TODO remove after 0.7.0 release
if (mem.eql(u8, tree.tokenSlice(builtin_call.builtin_token), "@OpaqueType"))
return stream.writeAll("@Type(.Opaque)");

try renderToken(tree, stream, builtin_call.builtin_token, indent, start_col, Space.None); // @name

const src_params_trailing_comma = blk: {
Expand Down
6 changes: 0 additions & 6 deletions src/all_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,6 @@ enum BuiltinFnId {
BuiltinFnIdShrExact,
BuiltinFnIdSetEvalBranchQuota,
BuiltinFnIdAlignCast,
BuiltinFnIdOpaqueType,
BuiltinFnIdThis,
BuiltinFnIdSetAlignStack,
BuiltinFnIdExport,
Expand Down Expand Up @@ -2734,7 +2733,6 @@ enum IrInstSrcId {
IrInstSrcIdImplicitCast,
IrInstSrcIdResolveResult,
IrInstSrcIdResetResult,
IrInstSrcIdOpaqueType,
IrInstSrcIdSetAlignStack,
IrInstSrcIdArgType,
IrInstSrcIdExport,
Expand Down Expand Up @@ -4234,10 +4232,6 @@ struct IrInstGenAlignCast {
IrInstGen *target;
};

struct IrInstSrcOpaqueType {
IrInstSrc base;
};

struct IrInstSrcSetAlignStack {
IrInstSrc base;

Expand Down
1 change: 0 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8699,7 +8699,6 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdShrExact, "shrExact", 2);
create_builtin_fn(g, BuiltinFnIdSetEvalBranchQuota, "setEvalBranchQuota", 1);
create_builtin_fn(g, BuiltinFnIdAlignCast, "alignCast", 2);
create_builtin_fn(g, BuiltinFnIdOpaqueType, "OpaqueType", 0);
create_builtin_fn(g, BuiltinFnIdSetAlignStack, "setAlignStack", 1);
create_builtin_fn(g, BuiltinFnIdExport, "export", 2);
create_builtin_fn(g, BuiltinFnIdErrorReturnTrace, "errorReturnTrace", 0);
Expand Down
29 changes: 0 additions & 29 deletions src/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,6 @@ static void destroy_instruction_src(IrInstSrc *inst) {
return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcResolveResult *>(inst));
case IrInstSrcIdResetResult:
return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcResetResult *>(inst));
case IrInstSrcIdOpaqueType:
return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcOpaqueType *>(inst));
case IrInstSrcIdSetAlignStack:
return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetAlignStack *>(inst));
case IrInstSrcIdArgType:
Expand Down Expand Up @@ -1532,10 +1530,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcResetResult *) {
return IrInstSrcIdResetResult;
}

static constexpr IrInstSrcId ir_inst_id(IrInstSrcOpaqueType *) {
return IrInstSrcIdOpaqueType;
}

static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetAlignStack *) {
return IrInstSrcIdSetAlignStack;
}
Expand Down Expand Up @@ -4535,12 +4529,6 @@ static IrInstSrc *ir_build_reset_result(IrBuilderSrc *irb, Scope *scope, AstNode
return &instruction->base;
}

static IrInstSrc *ir_build_opaque_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) {
IrInstSrcOpaqueType *instruction = ir_build_instruction<IrInstSrcOpaqueType>(irb, scope, source_node);

return &instruction->base;
}

static IrInstSrc *ir_build_set_align_stack(IrBuilderSrc *irb, Scope *scope, AstNode *source_node,
IrInstSrc *align_bytes)
{
Expand Down Expand Up @@ -7310,11 +7298,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod
IrInstSrc *align_cast = ir_build_align_cast_src(irb, scope, node, arg0_value, arg1_value);
return ir_lval_wrap(irb, scope, align_cast, lval, result_loc);
}
case BuiltinFnIdOpaqueType:
{
IrInstSrc *opaque_type = ir_build_opaque_type(irb, scope, node);
return ir_lval_wrap(irb, scope, opaque_type, lval, result_loc);
}
case BuiltinFnIdThis:
{
IrInstSrc *this_inst = ir_gen_this(irb, scope, node);
Expand Down Expand Up @@ -30263,15 +30246,6 @@ static IrInstGen *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstSrcAli
return result;
}

static IrInstGen *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInstSrcOpaqueType *instruction) {
Buf *bare_name = buf_alloc();
Buf *full_name = get_anon_type_name(ira->codegen, ira->old_irb.exec, "opaque",
instruction->base.base.scope, instruction->base.base.source_node, bare_name);
ZigType *result_type = get_opaque_type(ira->codegen, instruction->base.base.scope,
instruction->base.base.source_node, buf_ptr(full_name), bare_name);
return ir_const_type(ira, &instruction->base.base, result_type);
}

static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstSrcSetAlignStack *instruction) {
uint32_t align_bytes;
IrInstGen *align_bytes_inst = instruction->align_bytes->child;
Expand Down Expand Up @@ -31736,8 +31710,6 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
return ir_analyze_instruction_resolve_result(ira, (IrInstSrcResolveResult *)instruction);
case IrInstSrcIdResetResult:
return ir_analyze_instruction_reset_result(ira, (IrInstSrcResetResult *)instruction);
case IrInstSrcIdOpaqueType:
return ir_analyze_instruction_opaque_type(ira, (IrInstSrcOpaqueType *)instruction);
case IrInstSrcIdSetAlignStack:
return ir_analyze_instruction_set_align_stack(ira, (IrInstSrcSetAlignStack *)instruction);
case IrInstSrcIdArgType:
Expand Down Expand Up @@ -32181,7 +32153,6 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) {
case IrInstSrcIdAlignCast:
case IrInstSrcIdImplicitCast:
case IrInstSrcIdResolveResult:
case IrInstSrcIdOpaqueType:
case IrInstSrcIdArgType:
case IrInstSrcIdTagType:
case IrInstSrcIdErrorReturnTrace:
Expand Down
9 changes: 0 additions & 9 deletions src/ir_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
return "SrcResolveResult";
case IrInstSrcIdResetResult:
return "SrcResetResult";
case IrInstSrcIdOpaqueType:
return "SrcOpaqueType";
case IrInstSrcIdSetAlignStack:
return "SrcSetAlignStack";
case IrInstSrcIdArgType:
Expand Down Expand Up @@ -2315,10 +2313,6 @@ static void ir_print_reset_result(IrPrintSrc *irp, IrInstSrcResetResult *instruc
fprintf(irp->f, ")");
}

static void ir_print_opaque_type(IrPrintSrc *irp, IrInstSrcOpaqueType *instruction) {
fprintf(irp->f, "@OpaqueType()");
}

static void ir_print_set_align_stack(IrPrintSrc *irp, IrInstSrcSetAlignStack *instruction) {
fprintf(irp->f, "@setAlignStack(");
ir_print_other_inst_src(irp, instruction->align_bytes);
Expand Down Expand Up @@ -2911,9 +2905,6 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
case IrInstSrcIdResetResult:
ir_print_reset_result(irp, (IrInstSrcResetResult *)instruction);
break;
case IrInstSrcIdOpaqueType:
ir_print_opaque_type(irp, (IrInstSrcOpaqueType *)instruction);
break;
case IrInstSrcIdSetAlignStack:
ir_print_set_align_stack(irp, (IrInstSrcSetAlignStack *)instruction);
break;
Expand Down
2 changes: 1 addition & 1 deletion test/compile_errors.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7394,7 +7394,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
});

cases.add("function parameter is opaque",
\\const FooType = @OpaqueType();
\\const FooType = @Type(.Opaque);
\\export fn entry1() void {
\\ const someFuncPtr: fn (FooType) void = undefined;
\\}
Expand Down
1 change: 0 additions & 1 deletion test/stage1/behavior/type.zig
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ test "Type.ErrorUnion" {
}

test "Type.Opaque" {
testing.expect(@OpaqueType() != @Type(.Opaque));
testing.expect(@Type(.Opaque) != @Type(.Opaque));
testing.expect(@typeInfo(@Type(.Opaque)) == .Opaque);
}
Expand Down