
Use `const_eval_select!()` macro to enable contract checking only at runtime. The existing contract logic relies on closures, which are not supported in constant functions. This commit also removes one level of indirection for ensures clauses, however, it currently has a spurious warning message when the bottom of the function is unreachable.
22 lines
781 B
Text
22 lines
781 B
Text
warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes
|
|
--> $DIR/contract-attributes-nest.rs:19:12
|
|
|
|
|
LL | #![feature(contracts)]
|
|
| ^^^^^^^^^
|
|
|
|
|
= note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information
|
|
= note: `#[warn(incomplete_features)]` on by default
|
|
|
|
warning: unreachable expression
|
|
--> $DIR/contract-attributes-nest.rs:23:1
|
|
|
|
|
LL | #[core::contracts::ensures(|ret| *ret > 100)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable expression
|
|
...
|
|
LL | return x.baz + 50;
|
|
| ----------------- any code following this expression is unreachable
|
|
|
|
|
= note: `#[warn(unreachable_code)]` on by default
|
|
|
|
warning: 2 warnings emitted
|
|
|