about summary refs log tree commit diff
path: root/compiler/stable_mir
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
commitbcb8565f301b579dee60fffe87d5a329cc69fefa (patch)
treeeb7f0ec9b3ee08283342608c5bbe0eb316834f54 /compiler/stable_mir
parent534d79adf938fc3839fad47832c7cf2b4927d7d9 (diff)
downloadrust-bcb8565f301b579dee60fffe87d5a329cc69fefa.tar.gz
rust-bcb8565f301b579dee60fffe87d5a329cc69fefa.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.
Diffstat (limited to 'compiler/stable_mir')
-rw-r--r--compiler/stable_mir/src/mir/body.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs
index eec6cd8d49b..a6406e9db8e 100644
--- a/compiler/stable_mir/src/mir/body.rs
+++ b/compiler/stable_mir/src/mir/body.rs
@@ -608,7 +608,8 @@ impl Rvalue {
             Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::OffsetOf(..), _) => {
                 Ok(Ty::usize_ty())
             }
-            Rvalue::NullaryOp(NullOp::UbChecks, _) => Ok(Ty::bool_ty()),
+            Rvalue::NullaryOp(NullOp::ContractChecks, _)
+            | Rvalue::NullaryOp(NullOp::UbChecks, _) => Ok(Ty::bool_ty()),
             Rvalue::Aggregate(ak, ops) => match *ak {
                 AggregateKind::Array(ty) => Ty::try_new_array(ty, ops.len() as u64),
                 AggregateKind::Tuple => Ok(Ty::new_tuple(
@@ -1007,6 +1008,8 @@ pub enum NullOp {
     OffsetOf(Vec<(VariantIdx, FieldIdx)>),
     /// cfg!(ub_checks), but at codegen time
     UbChecks,
+    /// cfg!(contract_checks), but at codegen time
+    ContractChecks,
 }
 
 impl Operand {