remove PhantomEmptyStruct

This commit is contained in:
Folkert 2021-05-26 14:12:53 +02:00
parent e8e83513e9
commit ca5e9518d9
8 changed files with 1 additions and 38 deletions

View File

@ -125,12 +125,6 @@ fn jit_to_ast_help<'a>(
Layout::Builtin(other) => {
todo!("add support for rendering builtin {:?} to the REPL", other)
}
Layout::PhantomEmptyStruct => Ok(run_jit_function!(lib, main_fn_name, &u8, |_| {
Expr::Record {
fields: &[],
final_comments: env.arena.alloc([]),
}
})),
Layout::Struct(field_layouts) => {
let ptr_to_ast = |ptr: *const u8| match content {
Content::Structure(FlatType::Record(fields, _)) => {

View File

@ -3360,7 +3360,6 @@ pub fn build_proc<'a, 'ctx, 'env>(
}
Layout::Builtin(_) => {}
Layout::PhantomEmptyStruct => {}
Layout::Struct(_) => {}
Layout::Union(_) => {}
Layout::RecursivePointer => {}

View File

@ -56,11 +56,6 @@ fn build_hash_layout<'a, 'ctx, 'env>(
val.into_struct_value(),
),
Layout::PhantomEmptyStruct => {
// just does nothing and returns the seed
seed
}
Layout::Union(union_layout) => {
build_hash_tag(env, layout_ids, layout, union_layout, seed, val)
}

View File

@ -159,11 +159,6 @@ fn build_eq<'a, 'ctx, 'env>(
rhs_val,
),
Layout::PhantomEmptyStruct => {
// always equal to itself
env.context.bool_type().const_int(1, false).into()
}
Layout::RecursivePointer => match when_recursive {
WhenRecursive::Unreachable => {
unreachable!("recursion pointers should never be compared directly")
@ -338,11 +333,6 @@ fn build_neq<'a, 'ctx, 'env>(
result.into()
}
Layout::PhantomEmptyStruct => {
// always equal to itself
env.context.bool_type().const_int(1, false).into()
}
Layout::RecursivePointer => {
unreachable!("recursion pointers should never be compared directly")
}

View File

@ -115,7 +115,6 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>(
Pointer(layout) => basic_type_from_layout(env, &layout)
.ptr_type(AddressSpace::Generic)
.into(),
PhantomEmptyStruct => env.context.struct_type(&[], false).into(),
Struct(sorted_fields) => basic_type_from_record(env, sorted_fields),
Union(variant) => {
use UnionLayout::*;

View File

@ -724,8 +724,6 @@ fn modify_refcount_layout_build_function<'a, 'ctx, 'env>(
Some(function)
}
PhantomEmptyStruct => None,
Layout::RecursivePointer => match when_recursive {
WhenRecursive::Unreachable => {
unreachable!("recursion pointers should never be hashed directly")

View File

@ -525,7 +525,6 @@ fn layout_spec(builder: &mut FuncDefBuilder, layout: &Layout) -> Result<TypeId>
match layout {
Builtin(builtin) => builtin_spec(builder, builtin),
PhantomEmptyStruct => todo!(),
Struct(fields) => build_tuple_type(builder, fields),
Union(union_layout) => {
let variant_types = build_variant_types_help(builder, union_layout)?;

View File

@ -36,7 +36,6 @@ pub enum Layout<'a> {
/// A layout that is empty (turns into the empty struct in LLVM IR
/// but for our purposes, not zero-sized, so it does not get dropped from data structures
/// this is important for closures that capture zero-sized values
PhantomEmptyStruct,
Struct(&'a [Layout<'a>]),
Union(UnionLayout<'a>),
RecursivePointer,
@ -479,7 +478,6 @@ impl<'a> Layout<'a> {
match self {
Builtin(builtin) => builtin.safe_to_memcpy(),
PhantomEmptyStruct => true,
Struct(fields) => fields
.iter()
.all(|field_layout| field_layout.safe_to_memcpy()),
@ -519,12 +517,7 @@ impl<'a> Layout<'a> {
// For this calculation, we don't need an accurate
// stack size, we just need to know whether it's zero,
// so it's fine to use a pointer size of 1.
if let Layout::PhantomEmptyStruct = self {
false
} else {
// self.stack_size(1) == 0
false
}
false
}
pub fn stack_size(&self, pointer_size: u32) -> u32 {
@ -532,7 +525,6 @@ impl<'a> Layout<'a> {
match self {
Builtin(builtin) => builtin.stack_size(pointer_size),
PhantomEmptyStruct => 0,
Struct(fields) => {
let mut sum = 0;
@ -596,7 +588,6 @@ impl<'a> Layout<'a> {
}
}
Layout::Builtin(builtin) => builtin.alignment_bytes(pointer_size),
Layout::PhantomEmptyStruct => 0,
Layout::RecursivePointer => pointer_size,
Layout::FunctionPointer(_, _) => pointer_size,
Layout::Pointer(_) => pointer_size,
@ -636,7 +627,6 @@ impl<'a> Layout<'a> {
match self {
Builtin(builtin) => builtin.is_refcounted(),
PhantomEmptyStruct => false,
Struct(fields) => fields.iter().any(|f| f.contains_refcounted()),
Union(variant) => {
use UnionLayout::*;
@ -669,7 +659,6 @@ impl<'a> Layout<'a> {
match self {
Builtin(builtin) => builtin.to_doc(alloc, parens),
PhantomEmptyStruct => alloc.text("{}"),
Struct(fields) => {
let fields_doc = fields.iter().map(|x| x.to_doc(alloc, parens));