summary refs log tree commit diff
path: root/src/librustc_mir/interpret/machine.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-08-13 06:25:52 +0000
committerbors <bors@rust-lang.org>2019-08-13 06:25:52 +0000
commiteae3437dfe991621e8afdc82734f4a172d7ddf9b (patch)
tree8936a353a9fe2195322baf40de256354626bbbcc /src/librustc_mir/interpret/machine.rs
parent3f55461efb25b3c8b5c5c3d829065cb032ec953b (diff)
parentc9be294d11352614f6f0eaa7161df325b9300de2 (diff)
downloadrust-1.37.0.tar.gz
rust-1.37.0.zip
Auto merge of #63498 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum 1.37.0
1.37.0 stable

This promotes beta to stable and backports a few PRs:

 - Avoid ICE when referencing desugared local binding in borrow error (#63051)
 - Don't access a static just for its size and alignment (#62982) via 331e09b143aebfcf82dc1f9b69b31ee0083cbf0b
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