Skip to content

Commit ad91a03

Browse files
committed
Remove no longer used contract_checks intrinsic
The contract_checks compiler flag is now used to determine if runtime contract checks should be enabled, as opposed to the compiler intrinsic as previously. Remove remaining contract_check cfg flags
1 parent da80def commit ad91a03

34 files changed

+31
-132
lines changed

compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
115115
| sym::assert_mem_uninitialized_valid
116116
| sym::assert_inhabited
117117
| sym::ub_checks
118-
| sym::contract_checks
119118
| sym::atomic_fence
120119
| sym::atomic_singlethreadfence
121120
| sym::caller_location => {}

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const GATED_CFGS: &[GatedCfg] = &[
2222
// (name in cfg, feature, function to check if the feature is enabled)
2323
(sym::overflow_checks, sym::cfg_overflow_checks, Features::cfg_overflow_checks),
2424
(sym::ub_checks, sym::cfg_ub_checks, Features::cfg_ub_checks),
25-
(sym::contract_checks, sym::cfg_contract_checks, Features::cfg_contract_checks),
2625
(sym::target_thread_local, sym::cfg_target_thread_local, Features::cfg_target_thread_local),
2726
(
2827
sym::target_has_atomic_equal_alignment,

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ declare_features! (
400400
(unstable, avx10_target_feature, "1.88.0", Some(138843)),
401401
/// Allows using C-variadics.
402402
(unstable, c_variadic, "1.34.0", Some(44930)),
403-
/// Allows the use of `#[cfg(contract_checks)` to check if contract checks are enabled.
404-
(unstable, cfg_contract_checks, "1.86.0", Some(128044)),
405403
/// Allows the use of `#[cfg(overflow_checks)` to check if integer overflow behaviour.
406404
(unstable, cfg_overflow_checks, "1.71.0", Some(111466)),
407405
/// Provides the relocation model information as cfg entry

compiler/rustc_hir/src/lang_items.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ language_item_table! {
429429
// Experimental lang items for implementing contract pre- and post-condition checking.
430430
ContractBuildCheckEnsures, sym::contract_build_check_ensures, contract_build_check_ensures_fn, Target::Fn, GenericRequirement::None;
431431
ContractCheckRequires, sym::contract_check_requires, contract_check_requires_fn, Target::Fn, GenericRequirement::None;
432-
ContractChecks, sym::contract_checks, contract_checks_fn, Target::Fn, GenericRequirement::None;
433432

434433
// Experimental lang items for `MCP: Low level components for async drop`(https://github.com/rust-lang/compiler-team/issues/727)
435434
DefaultTrait4, sym::default_trait4, default_trait4_trait, Target::Trait, GenericRequirement::None;

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
8989
| sym::const_eval_select
9090
| sym::contract_check_ensures
9191
| sym::contract_check_requires
92-
| sym::contract_checks
9392
| sym::cosf16
9493
| sym::cosf32
9594
| sym::cosf64
@@ -639,8 +638,6 @@ pub(crate) fn check_intrinsic_type(
639638

640639
sym::box_new => (1, 0, vec![param(0)], Ty::new_box(tcx, param(0))),
641640

642-
// contract_checks() -> bool
643-
sym::contract_checks => (0, 0, Vec::new(), tcx.types.bool),
644641
// contract_check_requires::<C>(C) -> bool, where C: impl Fn() -> bool
645642
sym::contract_check_requires => (1, 0, vec![param(0)], tcx.types.unit),
646643
sym::contract_check_ensures => {

compiler/rustc_mir_transform/src/lower_intrinsics.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@ impl<'tcx> crate::MirPass<'tcx> for LowerIntrinsics {
3434
));
3535
terminator.kind = TerminatorKind::Goto { target };
3636
}
37-
sym::contract_checks => {
38-
let target = target.unwrap();
39-
block.statements.push(Statement::new(
40-
terminator.source_info,
41-
StatementKind::Assign(Box::new((
42-
*destination,
43-
Rvalue::NullaryOp(NullOp::ContractChecks, tcx.types.bool),
44-
))),
45-
));
46-
terminator.kind = TerminatorKind::Goto { target };
47-
}
4837
sym::forget => {
4938
let target = target.unwrap();
5039
block.statements.push(Statement::new(

compiler/rustc_session/src/config/cfg.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) {
118118
(sym::overflow_checks, None) => disallow(cfg, "-C overflow-checks"),
119119
(sym::debug_assertions, None) => disallow(cfg, "-C debug-assertions"),
120120
(sym::ub_checks, None) => disallow(cfg, "-Z ub-checks"),
121-
(sym::contract_checks, None) => disallow(cfg, "-Z contract-checks"),
122121
(sym::sanitize, None | Some(_)) => disallow(cfg, "-Z sanitizer"),
123122
(
124123
sym::sanitizer_cfi_generalize_pointers | sym::sanitizer_cfi_normalize_integers,
@@ -314,10 +313,6 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
314313
ins_none!(sym::emscripten_wasm_eh);
315314
}
316315

317-
if sess.contract_checks() {
318-
ins_none!(sym::contract_checks);
319-
}
320-
321316
ret
322317
}
323318

@@ -480,7 +475,6 @@ impl CheckCfg {
480475
ins!(sym::target_thread_local, no_values);
481476

482477
ins!(sym::ub_checks, no_values);
483-
ins!(sym::contract_checks, no_values);
484478

485479
ins!(sym::unix, no_values);
486480
ins!(sym::windows, no_values);

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,6 @@ symbols! {
623623
cfg_attr_multi,
624624
cfg_attr_trace: "<cfg_attr>", // must not be a valid identifier
625625
cfg_boolean_literals,
626-
cfg_contract_checks,
627626
cfg_doctest,
628627
cfg_emscripten_wasm_eh,
629628
cfg_eval,
@@ -747,7 +746,6 @@ symbols! {
747746
contract_build_check_ensures,
748747
contract_check_ensures,
749748
contract_check_requires,
750-
contract_checks,
751749
contracts,
752750
contracts_ensures,
753751
contracts_internals,

library/core/src/intrinsics/mod.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,24 +2631,6 @@ pub const unsafe fn const_make_global(ptr: *mut u8) -> *const u8 {
26312631
ptr
26322632
}
26332633

2634-
/// Returns whether we should perform contract-checking at runtime.
2635-
///
2636-
/// This is meant to be similar to the ub_checks intrinsic, in terms
2637-
/// of not prematurely committing at compile-time to whether contract
2638-
/// checking is turned on, so that we can specify contracts in libstd
2639-
/// and let an end user opt into turning them on.
2640-
#[unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)]
2641-
#[rustc_const_unstable(feature = "contracts", issue = "128044")]
2642-
#[inline(always)]
2643-
#[lang = "contract_checks"]
2644-
#[rustc_intrinsic]
2645-
pub const fn contract_checks() -> bool {
2646-
// FIXME: should this be `false` or `cfg!(contract_checks)`?
2647-
2648-
// cfg!(contract_checks)
2649-
false
2650-
}
2651-
26522634
/// Check if the pre-condition `cond` has been met.
26532635
///
26542636
/// By default, if `contract_checks` is enabled, this will panic with no unwind if the condition

src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ warning: unexpected `cfg` condition name: `bootstrap`
1313
1 | #[cfg(bootstrap)]
1414
| ^^^^^^^^^
1515
|
16-
= help: expected names are: `docsrs`, `feature`, and `test` and 31 more
16+
= help: expected names are: `docsrs`, `feature`, and `test` and 30 more
1717
= help: consider using a Cargo feature instead
1818
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
1919
[lints.rust]

0 commit comments

Comments
 (0)