summary refs log tree commit diff
path: root/src/librustc_mir/interpret/machine.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustc_mir/interpret/machine.rs')
-rw-r--r--src/librustc_mir/interpret/machine.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs
index 4eb95f20d93..91263932ccd 100644
--- a/src/librustc_mir/interpret/machine.rs
+++ b/src/librustc_mir/interpret/machine.rs
@@ -54,6 +54,11 @@ pub trait AllocMap<K: Hash + Eq, V> {
         k: K,
         vacant: impl FnOnce() -> Result<V, E>
     ) -> Result<&mut V, E>;
+
+    /// Read-only lookup.
+    fn get(&self, k: K) -> Option<&V> {
+        self.get_or(k, || Err(())).ok()
+    }
 }
 
 /// Methods of this trait signifies a point where CTFE evaluation would fail