mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-30 20:17:50 +00:00

Check ensures on early return due to Try / Yeet Expand these two expressions to include a call to contract checking
17 lines
327 B
Rust
17 lines
327 B
Rust
//@ run-pass
|
|
//@ compile-flags: -Zcontract-checks=yes
|
|
#![feature(rustc_contracts)]
|
|
|
|
struct Outer { outer: std::cell::Cell<i32> }
|
|
|
|
#[core::contracts::requires(x.outer.get() > 0)]
|
|
fn outer(x: Outer) {
|
|
let inner_closure = || { };
|
|
x.outer.set(0);
|
|
inner_closure();
|
|
}
|
|
|
|
fn main() {
|
|
outer(Outer { outer: 1.into() });
|
|
}
|