Eliminate BoundFn type from the language

Closes #9484
This commit is contained in:
Veikka Tuominen 2022-12-08 19:52:05 +02:00 committed by Andrew Kelley
parent 5831b68341
commit 9d93b2ccf1
23 changed files with 3 additions and 52 deletions

View file

@ -9366,12 +9366,7 @@ test "integer truncation" {
<li>{#link|union#}</li>
</ul>
<p>
For these types, {#syntax#}@Type{#endsyntax#} is not available:
</p>
<ul>
<li>{#link|Functions#}</li>
<li>BoundFn</li>
</ul>
{#syntax#}@Type{#endsyntax#} is not available for {#link|Functions#}.
{#header_close#}
{#header_open|@typeInfo#}
<pre>{#syntax#}@typeInfo(comptime T: type) std.builtin.Type{#endsyntax#}</pre>

View file

@ -210,7 +210,6 @@ pub const Type = union(enum) {
Enum: Enum,
Union: Union,
Fn: Fn,
BoundFn: Fn,
Opaque: Opaque,
Frame: Frame,
AnyFrame: AnyFrame,

View file

@ -101,7 +101,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
.Bool => hash(hasher, @boolToInt(key), strat),
.Enum => hash(hasher, @enumToInt(key), strat),
.ErrorSet => hash(hasher, @errorToInt(key), strat),
.AnyFrame, .BoundFn, .Fn => hash(hasher, @ptrToInt(key), strat),
.AnyFrame, .Fn => hash(hasher, @ptrToInt(key), strat),
.Pointer => @call(.{ .modifier = .always_inline }, hashPointer, .{ hasher, key, strat }),

View file

@ -308,7 +308,6 @@ pub fn zeroes(comptime T: type) T {
.ErrorUnion,
.ErrorSet,
.Fn,
.BoundFn,
.Type,
.NoReturn,
.Undefined,

View file

@ -549,7 +549,6 @@ pub fn hasUniqueRepresentation(comptime T: type) bool {
else => return false, // TODO can we know if it's true for some of these types ?
.AnyFrame,
.BoundFn,
.Enum,
.ErrorSet,
.Fn,

View file

@ -46,7 +46,6 @@ pub fn expectError(expected_error: anyerror, actual_error_union: anytype) !void
pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) !void {
switch (@typeInfo(@TypeOf(actual))) {
.NoReturn,
.BoundFn,
.Opaque,
.Frame,
.AnyFrame,

View file

@ -607,7 +607,6 @@ const DocData = struct {
is_test: bool = false,
is_extern: bool = false,
},
BoundFn: struct { name: []const u8 },
Opaque: struct {
name: []const u8,
src: usize, // index into astNodes

View file

@ -9275,7 +9275,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
dest_ty.fmt(sema.mod), container,
});
},
.BoundFn => @panic("TODO remove this type from the language and compiler"),
.Array,
.Bool,
@ -9339,7 +9338,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
operand_ty.fmt(sema.mod), container,
});
},
.BoundFn => @panic("TODO remove this type from the language and compiler"),
.Array,
.Bool,
@ -9777,7 +9775,6 @@ fn zirSwitchCond(
.Undefined,
.Null,
.Optional,
.BoundFn,
.Opaque,
.Vector,
.Frame,
@ -10361,7 +10358,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
.Undefined,
.Null,
.Optional,
.BoundFn,
.Opaque,
.Vector,
.Frame,
@ -14833,7 +14829,6 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
.NoReturn,
.Undefined,
.Null,
.BoundFn,
.Opaque,
=> return sema.fail(block, operand_src, "no size available for type '{}'", .{ty.fmt(sema.mod)}),
@ -14877,7 +14872,6 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
.NoReturn,
.Undefined,
.Null,
.BoundFn,
.Opaque,
=> return sema.fail(block, operand_src, "no size available for type '{}'", .{operand_ty.fmt(sema.mod)}),
@ -15908,7 +15902,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
}),
);
},
.BoundFn => @panic("TODO remove this type from the language and compiler"),
.Frame => return sema.failWithUseOfAsync(block, src),
.AnyFrame => return sema.failWithUseOfAsync(block, src),
}
@ -18609,7 +18602,6 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in
const ty = try Type.Tag.function.create(sema.arena, fn_info);
return sema.addType(ty);
},
.BoundFn => @panic("TODO delete BoundFn from the language"),
.Frame => return sema.failWithUseOfAsync(block, src),
}
}
@ -21790,7 +21782,6 @@ fn validateRunTimeType(
.Enum => return !(try sema.typeRequiresComptime(ty)),
.BoundFn,
.ComptimeFloat,
.ComptimeInt,
.EnumLiteral,
@ -21876,7 +21867,6 @@ fn explainWhyTypeIsComptimeInner(
try mod.errNoteNonLazy(src_loc, msg, "types are not available at runtime", .{});
},
.BoundFn,
.ComptimeFloat,
.ComptimeInt,
.EnumLiteral,
@ -21986,7 +21976,6 @@ fn validateExternType(
.Null,
.ErrorUnion,
.ErrorSet,
.BoundFn,
.Frame,
=> return false,
.Void => return position == .union_field or position == .ret_ty,
@ -22058,7 +22047,6 @@ fn explainWhyTypeIsNotExtern(
.Null,
.ErrorUnion,
.ErrorSet,
.BoundFn,
.Frame,
=> return,
@ -22116,7 +22104,6 @@ fn validatePackedType(ty: Type) bool {
.Null,
.ErrorUnion,
.ErrorSet,
.BoundFn,
.Frame,
.NoReturn,
.Opaque,
@ -22158,7 +22145,6 @@ fn explainWhyTypeIsNotPacked(
.EnumLiteral,
.Undefined,
.Null,
.BoundFn,
.Frame,
.NoReturn,
.Opaque,

View file

@ -6200,7 +6200,6 @@ fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
.NoReturn => unreachable,
.Undefined => unreachable,
.Null => unreachable,
.BoundFn => unreachable,
.Opaque => unreachable,
else => {},

View file

@ -64,7 +64,6 @@ pub fn classifyType(ty: Type, target: std.Target) Class {
.ComptimeInt,
.Undefined,
.Null,
.BoundFn,
.Fn,
.Opaque,
.EnumLiteral,

View file

@ -6156,7 +6156,6 @@ fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
.NoReturn => unreachable,
.Undefined => unreachable,
.Null => unreachable,
.BoundFn => unreachable,
.Opaque => unreachable,
else => {},

View file

@ -105,7 +105,6 @@ pub fn classifyType(ty: Type, target: std.Target, ctx: Context) Class {
.ComptimeInt,
.Undefined,
.Null,
.BoundFn,
.Fn,
.Opaque,
.EnumLiteral,

View file

@ -63,7 +63,6 @@ pub fn classifyType(ty: Type, target: std.Target) Class {
.ComptimeInt,
.Undefined,
.Null,
.BoundFn,
.Fn,
.Opaque,
.EnumLiteral,

View file

@ -1599,7 +1599,6 @@ fn isByRef(ty: Type, target: std.Target) bool {
.EnumLiteral,
.Undefined,
.Null,
.BoundFn,
.Opaque,
=> unreachable,

View file

@ -80,7 +80,6 @@ pub fn classifyType(ty: Type, target: Target) [2]Class {
.ComptimeInt,
.Undefined,
.Null,
.BoundFn,
.Fn,
.Opaque,
.EnumLiteral,

View file

@ -6942,7 +6942,6 @@ fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
.NoReturn => unreachable,
.Undefined => unreachable,
.Null => unreachable,
.BoundFn => unreachable,
.Opaque => unreachable,
else => {},

View file

@ -52,7 +52,6 @@ pub fn classifyWindows(ty: Type, target: Target) Class {
.ComptimeInt,
.Undefined,
.Null,
.BoundFn,
.Fn,
.Opaque,
.EnumLiteral,

View file

@ -866,7 +866,6 @@ pub const DeclGen = struct {
.NoReturn,
.Undefined,
.Null,
.BoundFn,
.Opaque,
=> unreachable,
@ -1320,7 +1319,6 @@ pub const DeclGen = struct {
.NoReturn => unreachable,
.Undefined => unreachable,
.Null => unreachable,
.BoundFn => unreachable,
.Opaque => unreachable,
.Frame,
@ -2050,8 +2048,6 @@ pub const DeclGen = struct {
.ComptimeInt,
.Type,
=> unreachable, // must be const or comptime
.BoundFn => unreachable, // this type will be deleted from the language
}
}

View file

@ -2341,8 +2341,6 @@ pub const Object = struct {
.Null => unreachable,
.EnumLiteral => unreachable,
.BoundFn => @panic("TODO remove BoundFn from the language"),
.Frame => @panic("TODO implement lowerDebugType for Frame types"),
.AnyFrame => @panic("TODO implement lowerDebugType for AnyFrame types"),
}
@ -3095,8 +3093,6 @@ pub const DeclGen = struct {
.Null => unreachable,
.EnumLiteral => unreachable,
.BoundFn => @panic("TODO remove BoundFn from the language"),
.Frame => @panic("TODO implement llvmType for Frame types"),
.AnyFrame => @panic("TODO implement llvmType for AnyFrame types"),
}
@ -3896,7 +3892,6 @@ pub const DeclGen = struct {
.NoReturn => unreachable,
.Undefined => unreachable,
.Null => unreachable,
.BoundFn => unreachable,
.Opaque => unreachable,
.Frame,
@ -10792,7 +10787,6 @@ fn isByRef(ty: Type) bool {
.EnumLiteral,
.Undefined,
.Null,
.BoundFn,
.Opaque,
=> unreachable,

View file

@ -538,8 +538,6 @@ pub const DeclGen = struct {
.Type,
=> unreachable, // Must be comptime.
.BoundFn => unreachable, // this type will be deleted from the language.
else => |tag| return self.todo("Implement zig type '{}'", .{tag}),
};
}

View file

@ -185,7 +185,6 @@ pub const Type = extern union {
.Void,
.ErrorSet,
.Fn,
.BoundFn,
.Opaque,
.AnyFrame,
.Enum,
@ -4074,7 +4073,6 @@ pub const Type = extern union {
=> return true,
.Opaque => return is_extern,
.BoundFn,
.ComptimeFloat,
.ComptimeInt,
.EnumLiteral,

View file

@ -2419,7 +2419,6 @@ pub const Value = extern union {
if (val.tag() == .runtime_value) return;
switch (zig_ty_tag) {
.BoundFn => unreachable, // TODO remove this from the language
.Opaque => unreachable, // Cannot hash opaque types
.Void,
@ -2566,7 +2565,6 @@ pub const Value = extern union {
if (val.tag() == .runtime_value) return;
switch (ty.zigTypeTag()) {
.BoundFn => unreachable, // TODO remove this from the language
.Opaque => unreachable, // Cannot hash opaque types
.Void,
.NoReturn,

View file

@ -252,7 +252,7 @@ fn testUnion() !void {
try expect(typeinfo_info == .Union);
try expect(typeinfo_info.Union.layout == .Auto);
try expect(typeinfo_info.Union.tag_type.? == TypeId);
try expect(typeinfo_info.Union.fields.len == 25);
try expect(typeinfo_info.Union.fields.len == 24);
try expect(typeinfo_info.Union.fields[4].field_type == @TypeOf(@typeInfo(u8).Int));
try expect(typeinfo_info.Union.decls.len == 22);