@@ -132,6 +132,9 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
132132 | sym:: aggregate_raw_ptr
133133 | sym:: ptr_metadata
134134 | sym:: ub_checks
135+ | sym:: contract_checks
136+ | sym:: contract_check_requires
137+ | sym:: contract_check_ensures
135138 | sym:: fadd_algebraic
136139 | sym:: fsub_algebraic
137140 | sym:: fmul_algebraic
@@ -219,6 +222,18 @@ pub fn check_intrinsic_type(
219222 }
220223 } ;
221224 ( n_tps, 0 , 0 , inputs, output, hir:: Safety :: Unsafe )
225+ } else if intrinsic_name == sym:: contract_check_ensures {
226+ // contract_check_ensures::<'a, Ret, C>(&'a Ret, C) -> bool
227+ // where C: impl Fn(&'a Ret) -> bool,
228+ //
229+ // so: two type params, one lifetime param, 0 const params, two inputs, returns boolean
230+
231+ let p = generics. param_at ( 0 , tcx) ;
232+ let r = ty:: Region :: new_early_param ( tcx, p. to_early_bound_region_data ( ) ) ;
233+ let ref_ret = Ty :: new_imm_ref ( tcx, r, param ( 1 ) ) ;
234+ // let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
235+ // let ref_ret = Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
236+ ( 2 , 1 , 0 , vec ! [ ref_ret, param( 2 ) ] , tcx. types . bool , hir:: Safety :: Safe )
222237 } else {
223238 let safety = intrinsic_operation_unsafety ( tcx, intrinsic_id) ;
224239 let ( n_tps, n_cts, inputs, output) = match intrinsic_name {
@@ -610,6 +625,11 @@ pub fn check_intrinsic_type(
610625
611626 sym:: box_new => ( 1 , 0 , vec ! [ param( 0 ) ] , Ty :: new_box ( tcx, param ( 0 ) ) ) ,
612627
628+ // contract_checks() -> bool
629+ sym:: contract_checks => ( 0 , 0 , Vec :: new ( ) , tcx. types . bool ) ,
630+ // contract_check_requires::<C>(C) -> bool, where C: impl Fn() -> bool
631+ sym:: contract_check_requires => ( 1 , 0 , vec ! [ param( 0 ) ] , tcx. types . bool ) ,
632+
613633 sym:: simd_eq
614634 | sym:: simd_ne
615635 | sym:: simd_lt
0 commit comments