about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2025-06-23 16:05:09 +0000
committerCamille Gillot <gillot.camille@gmail.com>2025-09-07 13:51:53 +0000
commit4e7a068c9a155807b40a592a092d8bc77d33d47c (patch)
tree2251b84257293c7c96028d0c93d2ec3dec9a6afc /compiler/rustc_middle/src
parentbea625f3275e3c897dc965ed97a1d19ef7831f01 (diff)
downloadrust-4e7a068c9a155807b40a592a092d8bc77d33d47c.tar.gz
rust-4e7a068c9a155807b40a592a092d8bc77d33d47c.zip
Introduce PlaceContext::may_observe_address.
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/mir/visit.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs
index 904d78d69b6..b498b7b8912 100644
--- a/compiler/rustc_middle/src/mir/visit.rs
+++ b/compiler/rustc_middle/src/mir/visit.rs
@@ -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 {