mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-11-03 22:49:17 +00:00 
			
		
		
		
	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.
		
			
				
	
	
		
			18 lines
		
	
	
		
			448 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			448 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
//@ run-pass
 | 
						|
//@ compile-flags: -Zcontract-checks=yes
 | 
						|
#![feature(contracts)]
 | 
						|
//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
 | 
						|
 | 
						|
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() });
 | 
						|
}
 |