about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2024-12-02 20:35:13 +0000
committerCelina G. Val <celinval@amazon.com>2025-02-03 12:53:57 -0800
commitfa43703573a44cc7302bbe7ef29ce7b6f80a77ad (patch)
tree32edcabb40cd389278bc91d257d0f317dd9bf50b
parent84595c2b1ea8f349f5a8da2084021855262b51f8 (diff)
downloadrust-fa43703573a44cc7302bbe7ef29ce7b6f80a77ad.tar.gz
rust-fa43703573a44cc7302bbe7ef29ce7b6f80a77ad.zip
Contracts core intrinsics.
These are hooks to:

  1. control whether contract checks are run
  2. allow 3rd party tools to intercept and reintepret the results of running contracts.
-rw-r--r--src/base.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/base.rs b/src/base.rs
index 7a40d236b92..de2ce1768fa 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -874,6 +874,15 @@ fn codegen_stmt<'tcx>(
                             lval.write_cvalue(fx, val);
                             return;
                         }
+                        NullOp::ContractChecks => {
+                            let val = fx.tcx.sess.contract_checks();
+                            let val = CValue::by_val(
+                                fx.bcx.ins().iconst(types::I8, i64::try_from(val).unwrap()),
+                                fx.layout_of(fx.tcx.types.bool),
+                            );
+                            lval.write_cvalue(fx, val);
+                            return;
+                        }
                     };
                     let val = CValue::by_val(
                         fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(val).unwrap()),