Skip to content

Commit

Permalink
add more detailed error messages for type enum conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev authored and TheDan64 committed May 31, 2021
1 parent 662d841 commit 7df64d4
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/types/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,63 +128,63 @@ impl<'ctx> AnyTypeEnum<'ctx> {
if let AnyTypeEnum::ArrayType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the ArrayType variant", self);
}
}

pub fn into_float_type(self) -> FloatType<'ctx> {
if let AnyTypeEnum::FloatType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the FloatType variant", self);
}
}

pub fn into_function_type(self) -> FunctionType<'ctx> {
if let AnyTypeEnum::FunctionType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the FunctionType variant", self);
}
}

pub fn into_int_type(self) -> IntType<'ctx> {
if let AnyTypeEnum::IntType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the IntType variant", self);
}
}

pub fn into_pointer_type(self) -> PointerType<'ctx> {
if let AnyTypeEnum::PointerType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the PointerType variant", self);
}
}

pub fn into_struct_type(self) -> StructType<'ctx> {
if let AnyTypeEnum::StructType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the StructType variant", self);
}
}

pub fn into_vector_type(self) -> VectorType<'ctx> {
if let AnyTypeEnum::VectorType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the VectorType variant", self);
}
}

pub fn into_void_type(self) -> VoidType<'ctx> {
if let AnyTypeEnum::VoidType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the VoidType variant", self);
}
}

Expand Down Expand Up @@ -266,47 +266,47 @@ impl<'ctx> BasicTypeEnum<'ctx> {
if let BasicTypeEnum::ArrayType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the ArrayType variant", self);
}
}

pub fn into_float_type(self) -> FloatType<'ctx> {
if let BasicTypeEnum::FloatType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the FloatType variant", self);
}
}

pub fn into_int_type(self) -> IntType<'ctx> {
if let BasicTypeEnum::IntType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the IntType variant", self);
}
}

pub fn into_pointer_type(self) -> PointerType<'ctx> {
if let BasicTypeEnum::PointerType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the PointerType variant", self);
}
}

pub fn into_struct_type(self) -> StructType<'ctx> {
if let BasicTypeEnum::StructType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the StructType variant", self);
}
}

pub fn into_vector_type(self) -> VectorType<'ctx> {
if let BasicTypeEnum::VectorType(t) = self {
t
} else {
panic!("Found {:?} but expected another variant", self);
panic!("Found {:?} but expected the VectorType variant", self);
}
}

Expand Down

0 comments on commit 7df64d4

Please sign in to comment.