about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2016-05-11 21:54:12 +0200
committerFelix S. Klock II <pnkfelix@pnkfx.org>2016-05-16 13:34:33 +0200
commit3bb598429afacd0416c0c9bc5d0a4520d17de901 (patch)
tree7771115c1ba499684a6b1ca8f71ab7131963113a
parentc73f3517a24a87763c7b81228816959ad7fef2e9 (diff)
downloadrust-3bb598429afacd0416c0c9bc5d0a4520d17de901.tar.gz
rust-3bb598429afacd0416c0c9bc5d0a4520d17de901.zip
Adding magic `rustc_peek` intrinsic that other code can repurpose to
its own needs based on attributes attached to the function where it
appears.
-rw-r--r--src/libcore/intrinsics.rs10
-rw-r--r--src/librustc_typeck/check/intrinsic.rs1
2 files changed, 11 insertions, 0 deletions
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index 8a9f662bf83..225929fb350 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -168,6 +168,16 @@ extern "rust-intrinsic" {
     pub fn atomic_singlethreadfence_rel();
     pub fn atomic_singlethreadfence_acqrel();
 
+    /// Magic intrinsic that derives its meaning from attributes
+    /// attached to the function.
+    ///
+    /// For example, dataflow uses this to inject static assertions so
+    /// that `rustc_oeek(potentially_uninitialized)` would actually
+    /// double-check that dataflow did indeed compute that it is
+    /// uninitialized at that point in the control flow.
+    #[cfg(not(stage0))]
+    pub fn rustc_peek<T>(_: T) -> T;
+
     /// Aborts the execution of the process.
     pub fn abort() -> !;
 
diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs
index c02139140ae..f120e38630b 100644
--- a/src/librustc_typeck/check/intrinsic.rs
+++ b/src/librustc_typeck/check/intrinsic.rs
@@ -117,6 +117,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) {
                                     param(ccx, 0))
                  ], ccx.tcx.types.usize)
             }
+            "rustc_peek" => (1, vec![param(ccx, 0)], param(ccx, 0)),
             "init" | "init_dropped" => (1, Vec::new(), param(ccx, 0)),
             "uninit" => (1, Vec::new(), param(ccx, 0)),
             "forget" => (1, vec!( param(ccx, 0) ), tcx.mk_nil()),