@@ -180,8 +180,9 @@ impl Duration {
180
180
/// ```
181
181
#[ stable( feature = "duration" , since = "1.3.0" ) ]
182
182
#[ inline]
183
- #[ rustc_const_unstable( feature = "duration_consts_2" , issue = "72440" ) ]
184
183
#[ must_use]
184
+ #[ rustc_const_stable( feature = "duration_consts_2" , since = "1.58.0" ) ]
185
+ #[ cfg_attr( bootstrap, rustc_allow_const_fn_unstable( const_panic) ) ]
185
186
pub const fn new ( secs : u64 , nanos : u32 ) -> Duration {
186
187
let secs = match secs. checked_add ( ( nanos / NANOS_PER_SEC ) as u64 ) {
187
188
Some ( secs) => secs,
@@ -480,7 +481,8 @@ impl Duration {
480
481
#[ must_use = "this returns the result of the operation, \
481
482
without modifying the original"]
482
483
#[ inline]
483
- #[ rustc_const_unstable( feature = "duration_consts_2" , issue = "72440" ) ]
484
+ #[ rustc_const_stable( feature = "duration_consts_2" , since = "1.58.0" ) ]
485
+ #[ cfg_attr( bootstrap, rustc_allow_const_fn_unstable( const_panic) ) ]
484
486
pub const fn checked_add ( self , rhs : Duration ) -> Option < Duration > {
485
487
if let Some ( mut secs) = self . secs . checked_add ( rhs. secs ) {
486
488
let mut nanos = self . nanos + rhs. nanos ;
@@ -515,7 +517,7 @@ impl Duration {
515
517
#[ must_use = "this returns the result of the operation, \
516
518
without modifying the original"]
517
519
#[ inline]
518
- #[ rustc_const_unstable ( feature = "duration_consts_2" , issue = "72440 " ) ]
520
+ #[ rustc_const_stable ( feature = "duration_consts_2" , since = "1.58.0 " ) ]
519
521
pub const fn saturating_add ( self , rhs : Duration ) -> Duration {
520
522
match self . checked_add ( rhs) {
521
523
Some ( res) => res,
@@ -540,7 +542,8 @@ impl Duration {
540
542
#[ must_use = "this returns the result of the operation, \
541
543
without modifying the original"]
542
544
#[ inline]
543
- #[ rustc_const_unstable( feature = "duration_consts_2" , issue = "72440" ) ]
545
+ #[ rustc_const_stable( feature = "duration_consts_2" , since = "1.58.0" ) ]
546
+ #[ cfg_attr( bootstrap, rustc_allow_const_fn_unstable( const_panic) ) ]
544
547
pub const fn checked_sub ( self , rhs : Duration ) -> Option < Duration > {
545
548
if let Some ( mut secs) = self . secs . checked_sub ( rhs. secs ) {
546
549
let nanos = if self . nanos >= rhs. nanos {
@@ -573,7 +576,7 @@ impl Duration {
573
576
#[ must_use = "this returns the result of the operation, \
574
577
without modifying the original"]
575
578
#[ inline]
576
- #[ rustc_const_unstable ( feature = "duration_consts_2" , issue = "72440 " ) ]
579
+ #[ rustc_const_stable ( feature = "duration_consts_2" , since = "1.58.0 " ) ]
577
580
pub const fn saturating_sub ( self , rhs : Duration ) -> Duration {
578
581
match self . checked_sub ( rhs) {
579
582
Some ( res) => res,
@@ -598,7 +601,8 @@ impl Duration {
598
601
#[ must_use = "this returns the result of the operation, \
599
602
without modifying the original"]
600
603
#[ inline]
601
- #[ rustc_const_unstable( feature = "duration_consts_2" , issue = "72440" ) ]
604
+ #[ rustc_const_stable( feature = "duration_consts_2" , since = "1.58.0" ) ]
605
+ #[ cfg_attr( bootstrap, rustc_allow_const_fn_unstable( const_panic) ) ]
602
606
pub const fn checked_mul ( self , rhs : u32 ) -> Option < Duration > {
603
607
// Multiply nanoseconds as u64, because it cannot overflow that way.
604
608
let total_nanos = self . nanos as u64 * rhs as u64 ;
@@ -629,7 +633,7 @@ impl Duration {
629
633
#[ must_use = "this returns the result of the operation, \
630
634
without modifying the original"]
631
635
#[ inline]
632
- #[ rustc_const_unstable ( feature = "duration_consts_2" , issue = "72440 " ) ]
636
+ #[ rustc_const_stable ( feature = "duration_consts_2" , since = "1.58.0 " ) ]
633
637
pub const fn saturating_mul ( self , rhs : u32 ) -> Duration {
634
638
match self . checked_mul ( rhs) {
635
639
Some ( res) => res,
@@ -655,7 +659,8 @@ impl Duration {
655
659
#[ must_use = "this returns the result of the operation, \
656
660
without modifying the original"]
657
661
#[ inline]
658
- #[ rustc_const_unstable( feature = "duration_consts_2" , issue = "72440" ) ]
662
+ #[ rustc_const_stable( feature = "duration_consts_2" , since = "1.58.0" ) ]
663
+ #[ cfg_attr( bootstrap, rustc_allow_const_fn_unstable( const_panic) ) ]
659
664
pub const fn checked_div ( self , rhs : u32 ) -> Option < Duration > {
660
665
if rhs != 0 {
661
666
let secs = self . secs / ( rhs as u64 ) ;
@@ -683,7 +688,7 @@ impl Duration {
683
688
#[ stable( feature = "duration_float" , since = "1.38.0" ) ]
684
689
#[ must_use]
685
690
#[ inline]
686
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
691
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
687
692
pub const fn as_secs_f64 ( & self ) -> f64 {
688
693
( self . secs as f64 ) + ( self . nanos as f64 ) / ( NANOS_PER_SEC as f64 )
689
694
}
@@ -702,7 +707,7 @@ impl Duration {
702
707
#[ stable( feature = "duration_float" , since = "1.38.0" ) ]
703
708
#[ must_use]
704
709
#[ inline]
705
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
710
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
706
711
pub const fn as_secs_f32 ( & self ) -> f32 {
707
712
( self . secs as f32 ) + ( self . nanos as f32 ) / ( NANOS_PER_SEC as f32 )
708
713
}
@@ -723,7 +728,7 @@ impl Duration {
723
728
#[ stable( feature = "duration_float" , since = "1.38.0" ) ]
724
729
#[ must_use]
725
730
#[ inline]
726
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
731
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
727
732
pub const fn from_secs_f64 ( secs : f64 ) -> Duration {
728
733
match Duration :: try_from_secs_f64 ( secs) {
729
734
Ok ( v) => v,
@@ -784,7 +789,7 @@ impl Duration {
784
789
#[ stable( feature = "duration_float" , since = "1.38.0" ) ]
785
790
#[ must_use]
786
791
#[ inline]
787
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
792
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
788
793
pub const fn from_secs_f32 ( secs : f32 ) -> Duration {
789
794
match Duration :: try_from_secs_f32 ( secs) {
790
795
Ok ( v) => v,
@@ -846,7 +851,7 @@ impl Duration {
846
851
#[ must_use = "this returns the result of the operation, \
847
852
without modifying the original"]
848
853
#[ inline]
849
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
854
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
850
855
pub const fn mul_f64 ( self , rhs : f64 ) -> Duration {
851
856
Duration :: from_secs_f64 ( rhs * self . as_secs_f64 ( ) )
852
857
}
@@ -870,7 +875,7 @@ impl Duration {
870
875
#[ must_use = "this returns the result of the operation, \
871
876
without modifying the original"]
872
877
#[ inline]
873
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
878
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
874
879
pub const fn mul_f32 ( self , rhs : f32 ) -> Duration {
875
880
Duration :: from_secs_f32 ( rhs * self . as_secs_f32 ( ) )
876
881
}
@@ -893,7 +898,7 @@ impl Duration {
893
898
#[ must_use = "this returns the result of the operation, \
894
899
without modifying the original"]
895
900
#[ inline]
896
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
901
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
897
902
pub const fn div_f64 ( self , rhs : f64 ) -> Duration {
898
903
Duration :: from_secs_f64 ( self . as_secs_f64 ( ) / rhs)
899
904
}
@@ -918,7 +923,7 @@ impl Duration {
918
923
#[ must_use = "this returns the result of the operation, \
919
924
without modifying the original"]
920
925
#[ inline]
921
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
926
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
922
927
pub const fn div_f32 ( self , rhs : f32 ) -> Duration {
923
928
Duration :: from_secs_f32 ( self . as_secs_f32 ( ) / rhs)
924
929
}
@@ -938,7 +943,7 @@ impl Duration {
938
943
#[ must_use = "this returns the result of the operation, \
939
944
without modifying the original"]
940
945
#[ inline]
941
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
946
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
942
947
pub const fn div_duration_f64 ( self , rhs : Duration ) -> f64 {
943
948
self . as_secs_f64 ( ) / rhs. as_secs_f64 ( )
944
949
}
@@ -958,7 +963,7 @@ impl Duration {
958
963
#[ must_use = "this returns the result of the operation, \
959
964
without modifying the original"]
960
965
#[ inline]
961
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
966
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
962
967
pub const fn div_duration_f32 ( self , rhs : Duration ) -> f32 {
963
968
self . as_secs_f32 ( ) / rhs. as_secs_f32 ( )
964
969
}
0 commit comments