@@ -445,6 +445,8 @@ pub trait AsMut<T: PointeeSized>: PointeeSized {
445445#[ rustc_diagnostic_item = "Into" ]
446446#[ stable( feature = "rust1" , since = "1.0.0" ) ]
447447#[ doc( search_unbox) ]
448+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
449+ #[ const_trait]
448450pub trait Into < T > : Sized {
449451 /// Converts this type into the (usually inferred) input type.
450452 #[ must_use]
@@ -580,6 +582,8 @@ pub trait Into<T>: Sized {
580582 note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix" ,
581583) ) ]
582584#[ doc( search_unbox) ]
585+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
586+ #[ const_trait]
583587pub trait From < T > : Sized {
584588 /// Converts to this type from the input type.
585589 #[ rustc_diagnostic_item = "from_fn" ]
@@ -607,6 +611,8 @@ pub trait From<T>: Sized {
607611/// [`Into`], see there for details.
608612#[ rustc_diagnostic_item = "TryInto" ]
609613#[ stable( feature = "try_from" , since = "1.34.0" ) ]
614+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
615+ #[ const_trait]
610616pub trait TryInto < T > : Sized {
611617 /// The type returned in the event of a conversion error.
612618 #[ stable( feature = "try_from" , since = "1.34.0" ) ]
@@ -685,6 +691,8 @@ pub trait TryInto<T>: Sized {
685691/// [`try_from`]: TryFrom::try_from
686692#[ rustc_diagnostic_item = "TryFrom" ]
687693#[ stable( feature = "try_from" , since = "1.34.0" ) ]
694+ #[ rustc_const_unstable( feature = "const_from" , issue = "143773" ) ]
695+ #[ const_trait]
688696pub trait TryFrom < T > : Sized {
689697 /// The type returned in the event of a conversion error.
690698 #[ stable( feature = "try_from" , since = "1.34.0" ) ]
@@ -754,9 +762,10 @@ where
754762
755763// From implies Into
756764#[ 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
758767where
759- U : From < T > ,
768+ U : ~ const From < T > ,
760769{
761770 /// Calls `U::from(self)`.
762771 ///
@@ -771,7 +780,8 @@ where
771780
772781// From (and thus Into) is reflexive
773782#[ 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 {
775785 /// Returns the argument unchanged.
776786 #[ inline( always) ]
777787 fn from ( t : T ) -> T {
@@ -787,17 +797,19 @@ impl<T> From<T> for T {
787797#[ stable( feature = "convert_infallible" , since = "1.34.0" ) ]
788798#[ rustc_reservation_impl = "permitting this impl would forbid us from adding \
789799 `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 {
791802 fn from ( t : !) -> T {
792803 t
793804 }
794805}
795806
796807// TryFrom implies TryInto
797808#[ 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
799811where
800- U : TryFrom < T > ,
812+ U : ~ const TryFrom < T > ,
801813{
802814 type Error = U :: Error ;
803815
@@ -810,9 +822,10 @@ where
810822// Infallible conversions are semantically equivalent to fallible conversions
811823// with an uninhabited error type.
812824#[ 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
814827where
815- U : Into < T > ,
828+ U : ~ const Into < T > ,
816829{
817830 type Error = Infallible ;
818831
0 commit comments