1
Fork 0

Add sanity check to BinOp::ty()

This commit is contained in:
Celina G. Val 2023-12-06 22:13:07 -08:00
parent 77d7e44573
commit 4616b9fd1d
2 changed files with 27 additions and 8 deletions

View file

@ -244,6 +244,19 @@ impl TyKind {
matches!(self, TyKind::RigidTy(RigidTy::FnPtr(..)))
}
pub fn is_primitive(&self) -> bool {
matches!(
self,
TyKind::RigidTy(
RigidTy::Bool
| RigidTy::Char
| RigidTy::Int(_)
| RigidTy::Uint(_)
| RigidTy::Float(_)
)
)
}
pub fn trait_principal(&self) -> Option<Binder<ExistentialTraitRef>> {
if let TyKind::RigidTy(RigidTy::Dynamic(predicates, _, _)) = self {
if let Some(Binder { value: ExistentialPredicate::Trait(trait_ref), bound_vars }) =