rust/tests/ui/contracts/internal_machinery/contracts-lowering-ensures-is-not-inherited-when-nesting.rs
Dawid Lachowicz aeae085dc3
Add contract variable declarations
Contract variables can be declared in the `requires` clause and
can be referenced both in `requires` and `ensures`, subject to usual
borrow checking rules.

This allows any setup common to both the `requires` and `ensures`
clauses to only be done once.
2025-10-18 15:00:34 +01:00

16 lines
247 B
Rust

//@ run-pass
//@ compile-flags: -Zcontract-checks=yes
#![feature(contracts_internals)]
fn outer() -> i32
contract_ensures { |ret| *ret > 0 }
{
let inner_closure = || -> i32 { 0 };
inner_closure();
10
}
fn main() {
outer();
}