From 9a481d1ecf0f11b4a5bd0220eec3fd93c997b033 Mon Sep 17 00:00:00 2001 From: Swarnim Arun Date: Mon, 27 Feb 2023 10:59:20 +0530 Subject: [PATCH 1/2] add: clean api to get `raw_ptr` type --- crates/hir/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 2cb4ed2c335..fba61a2d5b5 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -3190,6 +3190,14 @@ impl Type { matches!(self.ty.kind(Interner), TyKind::Raw(..)) } + pub fn as_raw_ptr_ty(&self) -> Option { + 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`. From 832f8bfe2ba4fcd8ac36e01a8a99d84cbcf6c762 Mon Sep 17 00:00:00 2001 From: Swarnim Arun Date: Mon, 27 Feb 2023 15:57:26 +0530 Subject: [PATCH 2/2] rename: `as_raw_ptr_ty` to `remove_raw_ptr` --- crates/hir/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index fba61a2d5b5..163a3194435 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -3190,7 +3190,7 @@ impl Type { matches!(self.ty.kind(Interner), TyKind::Raw(..)) } - pub fn as_raw_ptr_ty(&self) -> Option { + pub fn remove_raw_ptr(&self) -> Option { if let TyKind::Raw(_, ty) = self.ty.kind(Interner) { Some(self.derived(ty.clone())) } else {