Skip to content

Commit

Permalink
Separate contract feature gates for the internal machinery
Browse files Browse the repository at this point in the history
The extended syntax for function signature that includes contract clauses
should never be user exposed versus the interface we want to ship
externally eventually.
  • Loading branch information
pnkfelix authored and gitbot committed Mar 4, 2025
1 parent 0e35731 commit e0c6bd7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions core/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub use crate::macros::builtin::contracts_requires as requires;
/// Emitted by rustc as a desugaring of `#[requires(PRED)] fn foo(x: X) { ... }`
/// into: `fn foo(x: X) { check_requires(|| PRED) ... }`
#[cfg(not(bootstrap))]
#[unstable(feature = "rustc_contracts", issue = "none" /* compiler-team#759 */)]
#[unstable(feature = "rustc_contracts_internals", issue = "133866" /* compiler-team#759 */)]
#[lang = "contract_check_requires"]
#[track_caller]
pub fn check_requires<C: FnOnce() -> bool>(c: C) {
Expand All @@ -21,7 +21,7 @@ pub fn check_requires<C: FnOnce() -> bool>(c: C) {
/// into: `fn foo() { let _check = build_check_ensures(|ret| PRED) ... [return _check(R);] ... }`
/// (including the implicit return of the tail expression, if any).
#[cfg(not(bootstrap))]
#[unstable(feature = "rustc_contracts", issue = "none" /* compiler-team#759 */)]
#[unstable(feature = "rustc_contracts_internals", issue = "133866" /* compiler-team#759 */)]
#[lang = "contract_build_check_ensures"]
#[track_caller]
pub fn build_check_ensures<Ret, C>(c: C) -> impl (FnOnce(Ret) -> Ret) + Copy
Expand Down
8 changes: 4 additions & 4 deletions core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4071,8 +4071,8 @@ pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize)
/// checking is turned on, so that we can specify contracts in libstd
/// and let an end user opt into turning them on.
#[cfg(not(bootstrap))]
#[rustc_const_unstable(feature = "rustc_contracts", issue = "none" /* compiler-team#759 */)]
#[unstable(feature = "rustc_contracts", issue = "none" /* compiler-team#759 */)]
#[rustc_const_unstable(feature = "rustc_contracts_internals", issue = "133866" /* compiler-team#759 */)]
#[unstable(feature = "rustc_contracts_internals", issue = "133866" /* compiler-team#759 */)]
#[inline(always)]
#[rustc_intrinsic]
pub const fn contract_checks() -> bool {
Expand All @@ -4083,14 +4083,14 @@ pub const fn contract_checks() -> bool {
}

#[cfg(not(bootstrap))]
#[unstable(feature = "rustc_contracts", issue = "none" /* compiler-team#759 */)]
#[unstable(feature = "rustc_contracts_internals", issue = "133866" /* compiler-team#759 */)]
#[rustc_intrinsic]
pub fn contract_check_requires<C: FnOnce() -> bool>(c: C) -> bool {
c()
}

#[cfg(not(bootstrap))]
#[unstable(feature = "rustc_contracts", issue = "none" /* compiler-team#759 */)]
#[unstable(feature = "rustc_contracts_internals", issue = "133866" /* compiler-team#759 */)]
#[rustc_intrinsic]
pub fn contract_check_ensures<'a, Ret, C: FnOnce(&'a Ret) -> bool>(ret: &'a Ret, c: C) -> bool {
c(ret)
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ pub mod autodiff {
}

#[cfg(not(bootstrap))]
#[unstable(feature = "rustc_contracts", issue = "none")]
#[unstable(feature = "rustc_contracts", issue = "133866")]
pub mod contracts;

#[unstable(feature = "cfg_match", issue = "115585")]
Expand Down
8 changes: 4 additions & 4 deletions core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1783,8 +1783,8 @@ pub(crate) mod builtin {
/// eventually parsed as a unary closure expression that is
/// invoked on a reference to the return value.
#[cfg(not(bootstrap))]
#[unstable(feature = "rustc_contracts", issue = "none")]
#[allow_internal_unstable(core_intrinsics)]
#[unstable(feature = "rustc_contracts", issue = "133866")]
#[allow_internal_unstable(rustc_contracts_internals)]
#[rustc_builtin_macro]
pub macro contracts_ensures($item:item) {
/* compiler built-in */
Expand All @@ -1796,8 +1796,8 @@ pub(crate) mod builtin {
/// eventually parsed as an boolean expression with access to the
/// function's formal parameters
#[cfg(not(bootstrap))]
#[unstable(feature = "rustc_contracts", issue = "none")]
#[allow_internal_unstable(core_intrinsics)]
#[unstable(feature = "rustc_contracts", issue = "133866")]
#[allow_internal_unstable(rustc_contracts_internals)]
#[rustc_builtin_macro]
pub macro contracts_requires($item:item) {
/* compiler built-in */
Expand Down

0 comments on commit e0c6bd7

Please sign in to comment.