add: clean api to get raw_ptr type

This commit is contained in:
Swarnim Arun 2023-02-27 10:59:20 +05:30
parent 4e29820f6d
commit 9a481d1ecf
No known key found for this signature in database
GPG key ID: C4DD2E124886C2D2

View file

@ -3190,6 +3190,14 @@ impl Type {
matches!(self.ty.kind(Interner), TyKind::Raw(..))
}
pub fn as_raw_ptr_ty(&self) -> Option<Type> {
if let TyKind::Raw(_, ty) = self.ty.kind(Interner) {
Some(self.derived(ty.clone()))
} else {
None
}
}
pub fn contains_unknown(&self) -> bool {
// FIXME: When we get rid of `ConstScalar::Unknown`, we can just look at precomputed
// `TypeFlags` in `TyData`.