@@ -4086,28 +4086,55 @@ pub const fn contract_checks() -> bool {
40864086/// 
40874087/// By default, if `contract_checks` is enabled, this will panic with no unwind if the condition 
40884088/// returns false. 
4089+ /// 
4090+ /// Note that this function is a no-op during constant evaluation. 
40894091#[ cfg( not( bootstrap) ) ]  
4090- #[ unstable( feature = "contracts_internals" ,  issue = "128044"  /* compiler-team#759 */ ) ]  
4092+ #[ unstable( feature = "contracts_internals" ,  issue = "128044" ) ]  
4093+ #[ rustc_const_unstable( feature = "contracts" ,  issue = "128044" ) ]  
40914094#[ lang = "contract_check_requires" ]  
40924095#[ rustc_intrinsic]  
4093- pub  fn  contract_check_requires < C :  Fn ( )  -> bool > ( cond :  C )  { 
4094-     if  contract_checks ( )  && !cond ( )  { 
4095-         // Emit no unwind panic in case this was a safety requirement. 
4096-         crate :: panicking:: panic_nounwind ( "failed requires check" ) ; 
4097-     } 
4096+ pub  const  fn  contract_check_requires < C :  Fn ( )  -> bool  + Copy > ( cond :  C )  { 
4097+     const_eval_select ! ( 
4098+         @capture[ C :  Fn ( )  -> bool  + Copy ]  {  cond:  C  }  : 
4099+         if  const  { 
4100+                 // Do nothing 
4101+         }  else { 
4102+             if  contract_checks( )  && !cond( )  { 
4103+                 // Emit no unwind panic in case this was a safety requirement. 
4104+                 crate :: panicking:: panic_nounwind( "failed requires check" ) ; 
4105+             } 
4106+         } 
4107+     ) 
40984108} 
40994109
41004110/// Check if the post-condition `cond` has been met. 
41014111/// 
41024112/// By default, if `contract_checks` is enabled, this will panic with no unwind if the condition 
41034113/// returns false. 
4114+ /// 
4115+ /// Note that this function is a no-op during constant evaluation. 
41044116#[ cfg( not( bootstrap) ) ]  
4105- #[ unstable( feature = "contracts_internals" ,  issue = "128044"  /* compiler-team#759 */ ) ]  
4106- #[ rustc_intrinsic]  
4107- pub  fn  contract_check_ensures < ' a ,  Ret ,  C :  Fn ( & ' a  Ret )  -> bool > ( ret :  & ' a  Ret ,  cond :  C )  { 
4108-     if  contract_checks ( )  && !cond ( ret)  { 
4109-         crate :: panicking:: panic_nounwind ( "failed ensures check" ) ; 
4110-     } 
4117+ #[ unstable( feature = "contracts_internals" ,  issue = "128044" ) ]  
4118+ #[ rustc_const_unstable( feature = "contracts" ,  issue = "128044" ) ]  
4119+ #[ lang = "contract_check_ensures" ]  
4120+ #[ rustc_intrinsic]  
4121+ pub  const  fn  contract_check_ensures < Ret ,  C :  for < ' a >  Fn ( & ' a  Ret )  -> bool  + Copy > ( 
4122+     ret :  Ret , 
4123+     cond :  C , 
4124+ )  -> Ret  { 
4125+     const_eval_select ! ( 
4126+         @capture[ Ret ,  C :  for <' a> Fn ( & ' a Ret )  -> bool  + Copy ]  {  ret:  Ret ,  cond:  C  }  -> Ret  : 
4127+         if  const  { 
4128+             // Do nothing 
4129+             ret
4130+         }  else { 
4131+             if  contract_checks( )  && !cond( & ret)  { 
4132+                 // Emit no unwind panic in case this was a safety requirement. 
4133+                 crate :: panicking:: panic_nounwind( "failed ensures check" ) ; 
4134+             } 
4135+             ret
4136+         } 
4137+     ) 
41114138} 
41124139
41134140/// The intrinsic will return the size stored in that vtable. 
0 commit comments