@@ -445,6 +445,8 @@ pub trait AsMut<T: PointeeSized>: PointeeSized {
445
445
#[ rustc_diagnostic_item = "Into" ]
446
446
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
447
447
#[ doc( search_unbox) ]
448
+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
449
+ #[ const_trait]
448
450
pub trait Into < T > : Sized {
449
451
/// Converts this type into the (usually inferred) input type.
450
452
#[ must_use]
@@ -580,6 +582,8 @@ pub trait Into<T>: Sized {
580
582
note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix" ,
581
583
) ) ]
582
584
#[ doc( search_unbox) ]
585
+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
586
+ #[ const_trait]
583
587
pub trait From < T > : Sized {
584
588
/// Converts to this type from the input type.
585
589
#[ rustc_diagnostic_item = "from_fn" ]
@@ -607,6 +611,8 @@ pub trait From<T>: Sized {
607
611
/// [`Into`], see there for details.
608
612
#[ rustc_diagnostic_item = "TryInto" ]
609
613
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
614
+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
615
+ #[ const_trait]
610
616
pub trait TryInto < T > : Sized {
611
617
/// The type returned in the event of a conversion error.
612
618
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
@@ -685,6 +691,8 @@ pub trait TryInto<T>: Sized {
685
691
/// [`try_from`]: TryFrom::try_from
686
692
#[ rustc_diagnostic_item = "TryFrom" ]
687
693
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
694
+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
695
+ #[ const_trait]
688
696
pub trait TryFrom < T > : Sized {
689
697
/// The type returned in the event of a conversion error.
690
698
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
@@ -754,9 +762,10 @@ where
754
762
755
763
// From implies Into
756
764
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
757
- impl < T , U > Into < U > for T
765
+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
766
+ impl < T , U > const Into < U > for T
758
767
where
759
- U : From < T > ,
768
+ U : ~ const From < T > ,
760
769
{
761
770
/// Calls `U::from(self)`.
762
771
///
@@ -771,7 +780,8 @@ where
771
780
772
781
// From (and thus Into) is reflexive
773
782
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
774
- impl < T > From < T > for T {
783
+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
784
+ impl < T > const From < T > for T {
775
785
/// Returns the argument unchanged.
776
786
#[ inline( always) ]
777
787
fn from ( t : T ) -> T {
@@ -787,17 +797,19 @@ impl<T> From<T> for T {
787
797
#[ stable( feature = "convert_infallible" , since = "1.34.0" ) ]
788
798
#[ rustc_reservation_impl = "permitting this impl would forbid us from adding \
789
799
`impl<T> From<!> for T` later; see rust-lang/rust#64715 for details"]
790
- impl < T > From < !> for T {
800
+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
801
+ impl < T > const From < !> for T {
791
802
fn from ( t : !) -> T {
792
803
t
793
804
}
794
805
}
795
806
796
807
// TryFrom implies TryInto
797
808
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
798
- impl < T , U > TryInto < U > for T
809
+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
810
+ impl < T , U > const TryInto < U > for T
799
811
where
800
- U : TryFrom < T > ,
812
+ U : ~ const TryFrom < T > ,
801
813
{
802
814
type Error = U :: Error ;
803
815
@@ -810,9 +822,10 @@ where
810
822
// Infallible conversions are semantically equivalent to fallible conversions
811
823
// with an uninhabited error type.
812
824
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
813
- impl < T , U > TryFrom < U > for T
825
+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
826
+ impl < T , U > const TryFrom < U > for T
814
827
where
815
- U : Into < T > ,
828
+ U : ~ const Into < T > ,
816
829
{
817
830
type Error = Infallible ;
818
831
0 commit comments