| 1 | //! Unstable module containing the unstable contracts lang items and attribute macros. |
| 2 | |
| 3 | pub use crate::macros::builtin::{contracts_ensures as ensures, contracts_requires as requires}; |
| 4 | |
| 5 | /// This is an identity function used as part of the desugaring of the `#[ensures]` attribute. |
| 6 | /// |
| 7 | /// This is an existing hack to allow users to omit the type of the return value in their ensures |
| 8 | /// attribute. |
| 9 | /// |
| 10 | /// Ideally, rustc should be able to generate the type annotation. |
| 11 | /// The existing lowering logic makes it rather hard to add the explicit type annotation, |
| 12 | /// while the function call is fairly straight forward. |
| 13 | #[unstable (feature = "contracts_internals" , issue = "128044" /* compiler-team#759 */)] |
| 14 | // Similar to `contract_check_requires`, we need to use the user-facing |
| 15 | // `contracts` feature rather than the perma-unstable `contracts_internals`. |
| 16 | // Const-checking doesn't honor allow_internal_unstable logic used by contract expansion. |
| 17 | #[rustc_const_unstable (feature = "contracts" , issue = "128044" )] |
| 18 | #[lang = "contract_build_check_ensures" ] |
| 19 | pub const fn build_check_ensures<Ret, C>(cond: C) -> C |
| 20 | where |
| 21 | C: Fn(&Ret) -> bool + Copy + 'static, |
| 22 | { |
| 23 | cond |
| 24 | } |
| 25 | |