@@ -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,
@@ -477,7 +478,8 @@ impl Duration {
477
478
#[ must_use = "this returns the result of the operation, \
478
479
without modifying the original"]
479
480
#[ inline]
480
- #[ rustc_const_unstable( feature = "duration_consts_2" , issue = "72440" ) ]
481
+ #[ rustc_const_stable( feature = "duration_consts_2" , since = "1.58.0" ) ]
482
+ #[ cfg_attr( bootstrap, rustc_allow_const_fn_unstable( const_panic) ) ]
481
483
pub const fn checked_add ( self , rhs : Duration ) -> Option < Duration > {
482
484
if let Some ( mut secs) = self . secs . checked_add ( rhs. secs ) {
483
485
let mut nanos = self . nanos + rhs. nanos ;
@@ -512,7 +514,7 @@ impl Duration {
512
514
#[ must_use = "this returns the result of the operation, \
513
515
without modifying the original"]
514
516
#[ inline]
515
- #[ rustc_const_unstable ( feature = "duration_consts_2" , issue = "72440 " ) ]
517
+ #[ rustc_const_stable ( feature = "duration_consts_2" , since = "1.58.0 " ) ]
516
518
pub const fn saturating_add ( self , rhs : Duration ) -> Duration {
517
519
match self . checked_add ( rhs) {
518
520
Some ( res) => res,
@@ -537,7 +539,8 @@ impl Duration {
537
539
#[ must_use = "this returns the result of the operation, \
538
540
without modifying the original"]
539
541
#[ inline]
540
- #[ rustc_const_unstable( feature = "duration_consts_2" , issue = "72440" ) ]
542
+ #[ rustc_const_stable( feature = "duration_consts_2" , since = "1.58.0" ) ]
543
+ #[ cfg_attr( bootstrap, rustc_allow_const_fn_unstable( const_panic) ) ]
541
544
pub const fn checked_sub ( self , rhs : Duration ) -> Option < Duration > {
542
545
if let Some ( mut secs) = self . secs . checked_sub ( rhs. secs ) {
543
546
let nanos = if self . nanos >= rhs. nanos {
@@ -570,7 +573,7 @@ impl Duration {
570
573
#[ must_use = "this returns the result of the operation, \
571
574
without modifying the original"]
572
575
#[ inline]
573
- #[ rustc_const_unstable ( feature = "duration_consts_2" , issue = "72440 " ) ]
576
+ #[ rustc_const_stable ( feature = "duration_consts_2" , since = "1.58.0 " ) ]
574
577
pub const fn saturating_sub ( self , rhs : Duration ) -> Duration {
575
578
match self . checked_sub ( rhs) {
576
579
Some ( res) => res,
@@ -595,7 +598,8 @@ impl Duration {
595
598
#[ must_use = "this returns the result of the operation, \
596
599
without modifying the original"]
597
600
#[ inline]
598
- #[ rustc_const_unstable( feature = "duration_consts_2" , issue = "72440" ) ]
601
+ #[ rustc_const_stable( feature = "duration_consts_2" , since = "1.58.0" ) ]
602
+ #[ cfg_attr( bootstrap, rustc_allow_const_fn_unstable( const_panic) ) ]
599
603
pub const fn checked_mul ( self , rhs : u32 ) -> Option < Duration > {
600
604
// Multiply nanoseconds as u64, because it cannot overflow that way.
601
605
let total_nanos = self . nanos as u64 * rhs as u64 ;
@@ -626,7 +630,7 @@ impl Duration {
626
630
#[ must_use = "this returns the result of the operation, \
627
631
without modifying the original"]
628
632
#[ inline]
629
- #[ rustc_const_unstable ( feature = "duration_consts_2" , issue = "72440 " ) ]
633
+ #[ rustc_const_stable ( feature = "duration_consts_2" , since = "1.58.0 " ) ]
630
634
pub const fn saturating_mul ( self , rhs : u32 ) -> Duration {
631
635
match self . checked_mul ( rhs) {
632
636
Some ( res) => res,
@@ -652,7 +656,8 @@ impl Duration {
652
656
#[ must_use = "this returns the result of the operation, \
653
657
without modifying the original"]
654
658
#[ inline]
655
- #[ rustc_const_unstable( feature = "duration_consts_2" , issue = "72440" ) ]
659
+ #[ rustc_const_stable( feature = "duration_consts_2" , since = "1.58.0" ) ]
660
+ #[ cfg_attr( bootstrap, rustc_allow_const_fn_unstable( const_panic) ) ]
656
661
pub const fn checked_div ( self , rhs : u32 ) -> Option < Duration > {
657
662
if rhs != 0 {
658
663
let secs = self . secs / ( rhs as u64 ) ;
@@ -680,7 +685,7 @@ impl Duration {
680
685
#[ stable( feature = "duration_float" , since = "1.38.0" ) ]
681
686
#[ must_use]
682
687
#[ inline]
683
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
688
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
684
689
pub const fn as_secs_f64 ( & self ) -> f64 {
685
690
( self . secs as f64 ) + ( self . nanos as f64 ) / ( NANOS_PER_SEC as f64 )
686
691
}
@@ -699,7 +704,7 @@ impl Duration {
699
704
#[ stable( feature = "duration_float" , since = "1.38.0" ) ]
700
705
#[ must_use]
701
706
#[ inline]
702
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
707
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
703
708
pub const fn as_secs_f32 ( & self ) -> f32 {
704
709
( self . secs as f32 ) + ( self . nanos as f32 ) / ( NANOS_PER_SEC as f32 )
705
710
}
@@ -720,7 +725,7 @@ impl Duration {
720
725
#[ stable( feature = "duration_float" , since = "1.38.0" ) ]
721
726
#[ must_use]
722
727
#[ inline]
723
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
728
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
724
729
pub const fn from_secs_f64 ( secs : f64 ) -> Duration {
725
730
match Duration :: try_from_secs_f64 ( secs) {
726
731
Ok ( v) => v,
@@ -781,7 +786,7 @@ impl Duration {
781
786
#[ stable( feature = "duration_float" , since = "1.38.0" ) ]
782
787
#[ must_use]
783
788
#[ inline]
784
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
789
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
785
790
pub const fn from_secs_f32 ( secs : f32 ) -> Duration {
786
791
match Duration :: try_from_secs_f32 ( secs) {
787
792
Ok ( v) => v,
@@ -843,7 +848,7 @@ impl Duration {
843
848
#[ must_use = "this returns the result of the operation, \
844
849
without modifying the original"]
845
850
#[ inline]
846
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
851
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
847
852
pub const fn mul_f64 ( self , rhs : f64 ) -> Duration {
848
853
Duration :: from_secs_f64 ( rhs * self . as_secs_f64 ( ) )
849
854
}
@@ -867,7 +872,7 @@ impl Duration {
867
872
#[ must_use = "this returns the result of the operation, \
868
873
without modifying the original"]
869
874
#[ inline]
870
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
875
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
871
876
pub const fn mul_f32 ( self , rhs : f32 ) -> Duration {
872
877
Duration :: from_secs_f32 ( rhs * self . as_secs_f32 ( ) )
873
878
}
@@ -890,7 +895,7 @@ impl Duration {
890
895
#[ must_use = "this returns the result of the operation, \
891
896
without modifying the original"]
892
897
#[ inline]
893
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
898
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
894
899
pub const fn div_f64 ( self , rhs : f64 ) -> Duration {
895
900
Duration :: from_secs_f64 ( self . as_secs_f64 ( ) / rhs)
896
901
}
@@ -915,7 +920,7 @@ impl Duration {
915
920
#[ must_use = "this returns the result of the operation, \
916
921
without modifying the original"]
917
922
#[ inline]
918
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
923
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
919
924
pub const fn div_f32 ( self , rhs : f32 ) -> Duration {
920
925
Duration :: from_secs_f32 ( self . as_secs_f32 ( ) / rhs)
921
926
}
@@ -935,7 +940,7 @@ impl Duration {
935
940
#[ must_use = "this returns the result of the operation, \
936
941
without modifying the original"]
937
942
#[ inline]
938
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
943
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
939
944
pub const fn div_duration_f64 ( self , rhs : Duration ) -> f64 {
940
945
self . as_secs_f64 ( ) / rhs. as_secs_f64 ( )
941
946
}
@@ -955,7 +960,7 @@ impl Duration {
955
960
#[ must_use = "this returns the result of the operation, \
956
961
without modifying the original"]
957
962
#[ inline]
958
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
963
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
959
964
pub const fn div_duration_f32 ( self , rhs : Duration ) -> f32 {
960
965
self . as_secs_f32 ( ) / rhs. as_secs_f32 ( )
961
966
}
0 commit comments