Skip to content

Commit 0267e75

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.
1 parent 1f32e37 commit 0267e75

31 files changed

+30
-110
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_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
@@ -123,7 +123,6 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
123123
| sym::aggregate_raw_ptr
124124
| sym::ptr_metadata
125125
| sym::ub_checks
126-
| sym::contract_checks
127126
| sym::contract_check_requires
128127
| sym::contract_check_ensures
129128
| sym::fadd_algebraic
@@ -568,8 +567,6 @@ pub(crate) fn check_intrinsic_type(
568567

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

571-
// contract_checks() -> bool
572-
sym::contract_checks => (0, 0, Vec::new(), tcx.types.bool),
573570
// contract_check_requires::<C>(C) -> bool, where C: impl Fn() -> bool
574571
sym::contract_check_requires => (1, 0, vec![param(0)], tcx.types.unit),
575572
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,
@@ -305,10 +304,6 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
305304
ins_none!(sym::emscripten_wasm_eh);
306305
}
307306

308-
if sess.contract_checks() {
309-
ins_none!(sym::contract_checks);
310-
}
311-
312307
ret
313308
}
314309

@@ -469,7 +464,6 @@ impl CheckCfg {
469464
ins!(sym::target_thread_local, no_values);
470465

471466
ins!(sym::ub_checks, no_values);
472-
ins!(sym::contract_checks, no_values);
473467

474468
ins!(sym::unix, no_values);
475469
ins!(sym::windows, no_values);

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,6 @@ symbols! {
747747
contract_build_check_ensures,
748748
contract_check_ensures,
749749
contract_check_requires,
750-
contract_checks,
751750
contracts,
752751
contracts_ensures,
753752
contracts_internals,

library/core/src/intrinsics/mod.rs

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

2579-
/// Returns whether we should perform contract-checking at runtime.
2580-
///
2581-
/// This is meant to be similar to the ub_checks intrinsic, in terms
2582-
/// of not prematurely committing at compile-time to whether contract
2583-
/// checking is turned on, so that we can specify contracts in libstd
2584-
/// and let an end user opt into turning them on.
2585-
#[unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)]
2586-
#[rustc_const_unstable(feature = "contracts", issue = "128044")]
2587-
#[inline(always)]
2588-
#[lang = "contract_checks"]
2589-
#[rustc_intrinsic]
2590-
pub const fn contract_checks() -> bool {
2591-
// FIXME: should this be `false` or `cfg!(contract_checks)`?
2592-
2593-
// cfg!(contract_checks)
2594-
false
2595-
}
2596-
25972579
/// Check if the pre-condition `cond` has been met.
25982580
///
25992581
/// 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]

tests/rustdoc-ui/doc-cfg.stderr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ warning: unexpected `cfg` condition name: `foo`
2828
LL | #[doc(cfg(foo), cfg(bar))]
2929
| ^^^
3030
|
31-
= help: expected names are: `FALSE` and `test` and 31 more
31+
= help: expected names are: `FALSE` and `test` and 30 more
3232
= help: to expect this configuration use `--check-cfg=cfg(foo)`
3333
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
3434
= note: `#[warn(unexpected_cfgs)]` on by default
@@ -43,4 +43,3 @@ LL | #[doc(cfg(foo), cfg(bar))]
4343
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
4444

4545
error: aborting due to 4 previous errors; 2 warnings emitted
46-

0 commit comments

Comments
 (0)