@@ -3288,20 +3288,55 @@ pub const fn contract_checks() -> bool {
32883288/// 
32893289/// By default, if `contract_checks` is enabled, this will panic with no unwind if the condition 
32903290/// returns false. 
3291- #[ unstable( feature = "contracts_internals" ,  issue = "128044"  /* compiler-team#759 */ ) ]  
3291+ /// 
3292+ /// Note that this function is a no-op during constant evaluation. 
3293+ #[ unstable( feature = "contracts_internals" ,  issue = "128044" ) ]  
3294+ #[ rustc_const_unstable( feature = "contracts" ,  issue = "128044" ) ]  
32923295#[ lang = "contract_check_requires" ]  
32933296#[ rustc_intrinsic]  
3294- pub  fn  contract_check_requires < C :  Fn ( )  -> bool > ( cond :  C )  { 
3295-     if  contract_checks ( )  && !cond ( )  { 
3296-         // Emit no unwind panic in case this was a safety requirement. 
3297-         crate :: panicking:: panic_nounwind ( "failed requires check" ) ; 
3298-     } 
3297+ pub  const  fn  contract_check_requires < C :  Fn ( )  -> bool  + Copy > ( cond :  C )  { 
3298+     const_eval_select ! ( 
3299+         @capture[ C :  Fn ( )  -> bool  + Copy ]  {  cond:  C  }  : 
3300+         if  const  { 
3301+                 // Do nothing 
3302+         }  else { 
3303+             if  contract_checks( )  && !cond( )  { 
3304+                 // Emit no unwind panic in case this was a safety requirement. 
3305+                 crate :: panicking:: panic_nounwind( "failed requires check" ) ; 
3306+             } 
3307+         } 
3308+     ) 
32993309} 
33003310
33013311/// Check if the post-condition `cond` has been met. 
33023312/// 
33033313/// By default, if `contract_checks` is enabled, this will panic with no unwind if the condition 
33043314/// returns false. 
3315+ /// 
3316+ /// Note that this function is a no-op during constant evaluation. 
3317+ #[ cfg( not( bootstrap) ) ]  
3318+ #[ unstable( feature = "contracts_internals" ,  issue = "128044" ) ]  
3319+ #[ rustc_const_unstable( feature = "contracts" ,  issue = "128044" ) ]  
3320+ #[ lang = "contract_check_ensures" ]  
3321+ #[ rustc_intrinsic]  
3322+ pub  const  fn  contract_check_ensures < Ret ,  C :  Fn ( & Ret )  -> bool  + Copy > ( ret :  Ret ,  cond :  C )  -> Ret  { 
3323+     const_eval_select ! ( 
3324+         @capture[ Ret ,  C :  Fn ( & Ret )  -> bool  + Copy ]  {  ret:  Ret ,  cond:  C  }  -> Ret  : 
3325+         if  const  { 
3326+             // Do nothing 
3327+             ret
3328+         }  else { 
3329+             if  contract_checks( )  && !cond( & ret)  { 
3330+                 // Emit no unwind panic in case this was a safety requirement. 
3331+                 crate :: panicking:: panic_nounwind( "failed ensures check" ) ; 
3332+             } 
3333+             ret
3334+         } 
3335+     ) 
3336+ } 
3337+ 
3338+ /// This is the old version of contract_check_ensures kept here for bootstrap only. 
3339+ #[ cfg( bootstrap) ]  
33053340#[ unstable( feature = "contracts_internals" ,  issue = "128044"  /* compiler-team#759 */ ) ]  
33063341#[ rustc_intrinsic]  
33073342pub  fn  contract_check_ensures < ' a ,  Ret ,  C :  Fn ( & ' a  Ret )  -> bool > ( ret :  & ' a  Ret ,  cond :  C )  { 
0 commit comments