Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions crates/hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5693,6 +5693,18 @@ impl<'db> Type<'db> {
matches!(self.ty.kind(), TyKind::RawPtr(..))
}

pub fn is_mutable_raw_ptr(&self) -> bool {
// Used outside of rust-analyzer (e.g. by `ra_ap_hir` consumers).
matches!(self.ty.kind(), TyKind::RawPtr(.., hir_ty::next_solver::Mutability::Mut))
}

pub fn as_raw_ptr(&self) -> Option<(Type<'db>, Mutability)> {
// Used outside of rust-analyzer (e.g. by `ra_ap_hir` consumers).
let TyKind::RawPtr(ty, m) = self.ty.kind() else { return None };
let m = Mutability::from_mutable(matches!(m, hir_ty::next_solver::Mutability::Mut));
Some((self.derived(ty), m))
}

pub fn remove_raw_ptr(&self) -> Option<Type<'db>> {
if let TyKind::RawPtr(ty, _) = self.ty.kind() { Some(self.derived(ty)) } else { None }
}
Expand Down
Loading