core: refactor to use PrimitiveDefinition::contains_id
This commit is contained in:
parent
38981445ae
commit
b6ded9a869
|
@ -435,7 +435,7 @@ fn get_llvm_type<'ctx, G: CodeGenerator + ?Sized>(
|
|||
let result = match &*ty_enum {
|
||||
TObj { obj_id, fields, .. } => {
|
||||
// check to avoid treating non-class primitives as classes
|
||||
if obj_id.0 <= PrimitiveDefinition::max_id().0 {
|
||||
if PrimitiveDefinition::contains_id(*obj_id) {
|
||||
return match &*unifier.get_ty_immutable(ty) {
|
||||
TObj { obj_id, params, .. } if *obj_id == PrimitiveDefinition::Option.id() => {
|
||||
get_llvm_type(
|
||||
|
|
|
@ -35,8 +35,8 @@ impl PrimitiveDefinition {
|
|||
return DefinitionId(self as usize);
|
||||
}
|
||||
|
||||
pub fn max_id() -> DefinitionId {
|
||||
Self::iter().map(|prim| prim.id()).max().unwrap()
|
||||
pub fn contains_id(id: DefinitionId) -> bool {
|
||||
Self::iter().any(|prim| prim.id() == id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue