@@ -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
@@ -218,6 +221,18 @@ pub fn check_intrinsic_type(
218221 }
219222 } ;
220223 ( n_tps, 0 , 0 , inputs, output, hir:: Safety :: Unsafe )
224+ } else if intrinsic_name == sym:: contract_check_ensures {
225+ // contract_check_ensures::<'a, Ret, C>(&'a Ret, C) -> bool
226+ // where C: impl Fn(&'a Ret) -> bool,
227+ //
228+ // so: two type params, one lifetime param, 0 const params, two inputs, returns boolean
229+
230+ let p = generics. param_at ( 0 , tcx) ;
231+ let r = ty:: Region :: new_early_param ( tcx, p. to_early_bound_region_data ( ) ) ;
232+ let ref_ret = Ty :: new_imm_ref ( tcx, r, param ( 1 ) ) ;
233+ // let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
234+ // let ref_ret = Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
235+ ( 2 , 1 , 0 , vec ! [ ref_ret, param( 2 ) ] , tcx. types . bool , hir:: Safety :: Safe )
221236 } else {
222237 let safety = intrinsic_operation_unsafety ( tcx, intrinsic_id) ;
223238 let ( n_tps, n_cts, inputs, output) = match intrinsic_name {
@@ -609,6 +624,11 @@ pub fn check_intrinsic_type(
609624
610625 sym:: box_new => ( 1 , 0 , vec ! [ param( 0 ) ] , Ty :: new_box ( tcx, param ( 0 ) ) ) ,
611626
627+ // contract_checks() -> bool
628+ sym:: contract_checks => ( 0 , 0 , Vec :: new ( ) , tcx. types . bool ) ,
629+ // contract_check_requires::<C>(C) -> bool, where C: impl Fn() -> bool
630+ sym:: contract_check_requires => ( 1 , 0 , vec ! [ param( 0 ) ] , tcx. types . bool ) ,
631+
612632 sym:: simd_eq
613633 | sym:: simd_ne
614634 | sym:: simd_lt
0 commit comments