rust/tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs
Celina G. Val ddbf54b67d Rename rustc_contract to contract
This has now been approved as a language feature and no longer needs
a `rustc_` prefix.

Also change the `contracts` feature to be marked as incomplete and
`contracts_internals` as internal.
2025-02-03 13:55:15 -08:00

18 lines
327 B
Rust

//@ 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() });
}