about summary refs log tree commit diff
path: root/tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2024-12-03 02:52:29 +0000
committerCelina G. Val <celinval@amazon.com>2025-02-03 13:54:32 -0800
commitae7eff0be5c4abae63c06851af14cfdf7fec3981 (patch)
tree09a71ffa488c79c19c78c6c691713833c0410af0 /tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs
parent38eff16d0aa029706a0b5845961f9b5ccddfd999 (diff)
downloadrust-ae7eff0be5c4abae63c06851af14cfdf7fec3981.tar.gz
rust-ae7eff0be5c4abae63c06851af14cfdf7fec3981.zip
Desugars contract into the internal AST extensions
Check ensures on early return due to Try / Yeet

Expand these two expressions to include a call to contract checking
Diffstat (limited to 'tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs')
-rw-r--r--tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs b/tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs
new file mode 100644
index 00000000000..9872fdb1a18
--- /dev/null
+++ b/tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs
@@ -0,0 +1,14 @@
+//@ run-pass
+//@ compile-flags: -Zcontract-checks=yes
+#![feature(rustc_contracts)]
+
+#[core::contracts::ensures(|ret| *ret > 0)]
+fn outer() -> i32 {
+    let inner_closure = || -> i32 { 0 };
+    inner_closure();
+    10
+}
+
+fn main() {
+    outer();
+}