about summary refs log tree commit diff
path: root/tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs')
-rw-r--r--tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs b/tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs
new file mode 100644
index 00000000000..bee703de16a
--- /dev/null
+++ b/tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs
@@ -0,0 +1,17 @@
+//@ run-pass
+//@ compile-flags: -Zcontract-checks=yes
+#![feature(contracts_internals)]
+
+struct Outer { outer: std::cell::Cell<i32> }
+
+fn outer(x: Outer)
+    contract_requires(|| x.outer.get() > 0)
+{
+    let inner_closure = || { };
+    x.outer.set(0);
+    inner_closure();
+}
+
+fn main() {
+    outer(Outer { outer: 1.into() });
+}