Introduce PlaceContext::may_observe_address.

This commit is contained in:
Camille GILLOT
2025-06-23 16:05:09 +00:00
committed by Camille Gillot
parent bea625f327
commit 4e7a068c9a
3 changed files with 23 additions and 8 deletions

View File

@@ -1415,6 +1415,24 @@ impl PlaceContext {
)
}
/// Returns `true` if this place context may be used to know the address of the given place.
#[inline]
pub fn may_observe_address(self) -> bool {
matches!(
self,
PlaceContext::NonMutatingUse(
NonMutatingUseContext::SharedBorrow
| NonMutatingUseContext::RawBorrow
| NonMutatingUseContext::FakeBorrow
) | PlaceContext::MutatingUse(
MutatingUseContext::Drop
| MutatingUseContext::Borrow
| MutatingUseContext::RawBorrow
| MutatingUseContext::AsmOutput
)
)
}
/// Returns `true` if this place context represents a storage live or storage dead marker.
#[inline]
pub fn is_storage_marker(self) -> bool {