diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2024-12-03 02:52:29 +0000 | 
|---|---|---|
| committer | Celina G. Val <celinval@amazon.com> | 2025-02-03 13:54:32 -0800 | 
| commit | ae7eff0be5c4abae63c06851af14cfdf7fec3981 (patch) | |
| tree | 09a71ffa488c79c19c78c6c691713833c0410af0 /tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs | |
| parent | 38eff16d0aa029706a0b5845961f9b5ccddfd999 (diff) | |
| download | rust-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.rs | 14 | 
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(); +} | 
