@@ -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,
@@ -782,7 +787,7 @@ impl Duration {
782
787
#[ stable( feature = "duration_float" , since = "1.38.0" ) ]
783
788
#[ must_use]
784
789
#[ inline]
785
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
790
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
786
791
pub const fn from_secs_f32 ( secs : f32 ) -> Duration {
787
792
match Duration :: try_from_secs_f32 ( secs) {
788
793
Ok ( v) => v,
@@ -845,7 +850,7 @@ impl Duration {
845
850
#[ must_use = "this returns the result of the operation, \
846
851
without modifying the original"]
847
852
#[ inline]
848
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
853
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
849
854
pub const fn mul_f64 ( self , rhs : f64 ) -> Duration {
850
855
Duration :: from_secs_f64 ( rhs * self . as_secs_f64 ( ) )
851
856
}
@@ -869,7 +874,7 @@ impl Duration {
869
874
#[ must_use = "this returns the result of the operation, \
870
875
without modifying the original"]
871
876
#[ inline]
872
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
877
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
873
878
pub const fn mul_f32 ( self , rhs : f32 ) -> Duration {
874
879
Duration :: from_secs_f32 ( rhs * self . as_secs_f32 ( ) )
875
880
}
@@ -892,7 +897,7 @@ impl Duration {
892
897
#[ must_use = "this returns the result of the operation, \
893
898
without modifying the original"]
894
899
#[ inline]
895
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
900
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
896
901
pub const fn div_f64 ( self , rhs : f64 ) -> Duration {
897
902
Duration :: from_secs_f64 ( self . as_secs_f64 ( ) / rhs)
898
903
}
@@ -917,7 +922,7 @@ impl Duration {
917
922
#[ must_use = "this returns the result of the operation, \
918
923
without modifying the original"]
919
924
#[ inline]
920
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
925
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
921
926
pub const fn div_f32 ( self , rhs : f32 ) -> Duration {
922
927
Duration :: from_secs_f32 ( self . as_secs_f32 ( ) / rhs)
923
928
}
@@ -937,7 +942,7 @@ impl Duration {
937
942
#[ must_use = "this returns the result of the operation, \
938
943
without modifying the original"]
939
944
#[ inline]
940
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
945
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
941
946
pub const fn div_duration_f64 ( self , rhs : Duration ) -> f64 {
942
947
self . as_secs_f64 ( ) / rhs. as_secs_f64 ( )
943
948
}
@@ -957,7 +962,7 @@ impl Duration {
957
962
#[ must_use = "this returns the result of the operation, \
958
963
without modifying the original"]
959
964
#[ inline]
960
- #[ rustc_const_unstable( feature = "duration_consts_2 " , issue = "72440" ) ]
965
+ #[ rustc_const_unstable( feature = "duration_consts_float " , issue = "72440" ) ]
961
966
pub const fn div_duration_f32 ( self , rhs : Duration ) -> f32 {
962
967
self . as_secs_f32 ( ) / rhs. as_secs_f32 ( )
963
968
}
0 commit comments