@@ -216,6 +216,8 @@ pub const fn identity<T>(x: T) -> T {
216216/// ```
217217#[ stable( feature = "rust1" , since = "1.0.0" ) ]
218218#[ rustc_diagnostic_item = "AsRef" ]
219+ #[ const_trait]
220+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
219221pub trait AsRef < T : PointeeSized > : PointeeSized {
220222 /// Converts this type into a shared reference of the (usually inferred) input type.
221223 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -367,6 +369,8 @@ pub trait AsRef<T: PointeeSized>: PointeeSized {
367369/// `&mut Vec<u8>`, for example, is the better choice (callers need to pass the correct type then).
368370#[ stable( feature = "rust1" , since = "1.0.0" ) ]
369371#[ rustc_diagnostic_item = "AsMut" ]
372+ #[ const_trait]
373+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
370374pub trait AsMut < T : PointeeSized > : PointeeSized {
371375 /// Converts this type into a mutable reference of the (usually inferred) input type.
372376 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -445,6 +449,8 @@ pub trait AsMut<T: PointeeSized>: PointeeSized {
445449#[ rustc_diagnostic_item = "Into" ]
446450#[ stable( feature = "rust1" , since = "1.0.0" ) ]
447451#[ doc( search_unbox) ]
452+ #[ const_trait]
453+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
448454pub trait Into < T > : Sized {
449455 /// Converts this type into the (usually inferred) input type.
450456 #[ must_use]
@@ -580,6 +586,8 @@ pub trait Into<T>: Sized {
580586 note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix" ,
581587) ) ]
582588#[ doc( search_unbox) ]
589+ #[ const_trait]
590+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
583591pub trait From < T > : Sized {
584592 /// Converts to this type from the input type.
585593 #[ rustc_diagnostic_item = "from_fn" ]
@@ -607,6 +615,8 @@ pub trait From<T>: Sized {
607615/// [`Into`], see there for details.
608616#[ rustc_diagnostic_item = "TryInto" ]
609617#[ stable( feature = "try_from" , since = "1.34.0" ) ]
618+ #[ const_trait]
619+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
610620pub trait TryInto < T > : Sized {
611621 /// The type returned in the event of a conversion error.
612622 #[ stable( feature = "try_from" , since = "1.34.0" ) ]
@@ -685,6 +695,8 @@ pub trait TryInto<T>: Sized {
685695/// [`try_from`]: TryFrom::try_from
686696#[ rustc_diagnostic_item = "TryFrom" ]
687697#[ stable( feature = "try_from" , since = "1.34.0" ) ]
698+ #[ const_trait]
699+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
688700pub trait TryFrom < T > : Sized {
689701 /// The type returned in the event of a conversion error.
690702 #[ stable( feature = "try_from" , since = "1.34.0" ) ]
@@ -702,9 +714,10 @@ pub trait TryFrom<T>: Sized {
702714
703715// As lifts over &
704716#[ stable( feature = "rust1" , since = "1.0.0" ) ]
705- impl < T : PointeeSized , U : PointeeSized > AsRef < U > for & T
717+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
718+ impl < T : PointeeSized , U : PointeeSized > const AsRef < U > for & T
706719where
707- T : AsRef < U > ,
720+ T : ~ const AsRef < U > ,
708721{
709722 #[ inline]
710723 fn as_ref ( & self ) -> & U {
@@ -714,9 +727,10 @@ where
714727
715728// As lifts over &mut
716729#[ stable( feature = "rust1" , since = "1.0.0" ) ]
717- impl < T : PointeeSized , U : PointeeSized > AsRef < U > for & mut T
730+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
731+ impl < T : PointeeSized , U : PointeeSized > const AsRef < U > for & mut T
718732where
719- T : AsRef < U > ,
733+ T : ~ const AsRef < U > ,
720734{
721735 #[ inline]
722736 fn as_ref ( & self ) -> & U {
@@ -734,9 +748,10 @@ where
734748
735749// AsMut lifts over &mut
736750#[ stable( feature = "rust1" , since = "1.0.0" ) ]
737- impl < T : PointeeSized , U : PointeeSized > AsMut < U > for & mut T
751+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
752+ impl < T : PointeeSized , U : PointeeSized > const AsMut < U > for & mut T
738753where
739- T : AsMut < U > ,
754+ T : ~ const AsMut < U > ,
740755{
741756 #[ inline]
742757 fn as_mut ( & mut self ) -> & mut U {
@@ -754,9 +769,10 @@ where
754769
755770// From implies Into
756771#[ stable( feature = "rust1" , since = "1.0.0" ) ]
757- impl < T , U > Into < U > for T
772+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
773+ impl < T , U > const Into < U > for T
758774where
759- U : From < T > ,
775+ U : ~ const From < T > ,
760776{
761777 /// Calls `U::from(self)`.
762778 ///
@@ -771,7 +787,8 @@ where
771787
772788// From (and thus Into) is reflexive
773789#[ stable( feature = "rust1" , since = "1.0.0" ) ]
774- impl < T > From < T > for T {
790+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
791+ impl < T > const From < T > for T {
775792 /// Returns the argument unchanged.
776793 #[ inline( always) ]
777794 fn from ( t : T ) -> T {
@@ -795,9 +812,10 @@ impl<T> From<!> for T {
795812
796813// TryFrom implies TryInto
797814#[ stable( feature = "try_from" , since = "1.34.0" ) ]
798- impl < T , U > TryInto < U > for T
815+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
816+ impl < T , U > const TryInto < U > for T
799817where
800- U : TryFrom < T > ,
818+ U : ~ const TryFrom < T > ,
801819{
802820 type Error = U :: Error ;
803821
@@ -810,9 +828,10 @@ where
810828// Infallible conversions are semantically equivalent to fallible conversions
811829// with an uninhabited error type.
812830#[ stable( feature = "try_from" , since = "1.34.0" ) ]
813- impl < T , U > TryFrom < U > for T
831+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
832+ impl < T , U > const TryFrom < U > for T
814833where
815- U : Into < T > ,
834+ U : ~ const Into < T > ,
816835{
817836 type Error = Infallible ;
818837
@@ -827,31 +846,35 @@ where
827846////////////////////////////////////////////////////////////////////////////////
828847
829848#[ stable( feature = "rust1" , since = "1.0.0" ) ]
830- impl < T > AsRef < [ T ] > for [ T ] {
849+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
850+ impl < T > const AsRef < [ T ] > for [ T ] {
831851 #[ inline( always) ]
832852 fn as_ref ( & self ) -> & [ T ] {
833853 self
834854 }
835855}
836856
837857#[ stable( feature = "rust1" , since = "1.0.0" ) ]
838- impl < T > AsMut < [ T ] > for [ T ] {
858+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
859+ impl < T > const AsMut < [ T ] > for [ T ] {
839860 #[ inline( always) ]
840861 fn as_mut ( & mut self ) -> & mut [ T ] {
841862 self
842863 }
843864}
844865
845866#[ stable( feature = "rust1" , since = "1.0.0" ) ]
846- impl AsRef < str > for str {
867+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
868+ impl const AsRef < str > for str {
847869 #[ inline( always) ]
848870 fn as_ref ( & self ) -> & str {
849871 self
850872 }
851873}
852874
853875#[ stable( feature = "as_mut_str_for_str" , since = "1.51.0" ) ]
854- impl AsMut < str > for str {
876+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
877+ impl const AsMut < str > for str {
855878 #[ inline( always) ]
856879 fn as_mut ( & mut self ) -> & mut str {
857880 self
@@ -912,7 +935,8 @@ impl AsMut<str> for str {
912935pub enum Infallible { }
913936
914937#[ stable( feature = "convert_infallible" , since = "1.34.0" ) ]
915- impl Clone for Infallible {
938+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
939+ impl const Clone for Infallible {
916940 fn clone ( & self ) -> Infallible {
917941 match * self { }
918942 }
@@ -940,7 +964,8 @@ impl Error for Infallible {
940964}
941965
942966#[ stable( feature = "convert_infallible" , since = "1.34.0" ) ]
943- impl PartialEq for Infallible {
967+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "92391" ) ]
968+ impl const PartialEq for Infallible {
944969 fn eq ( & self , _: & Infallible ) -> bool {
945970 match * self { }
946971 }
@@ -964,7 +989,8 @@ impl Ord for Infallible {
964989}
965990
966991#[ stable( feature = "convert_infallible" , since = "1.34.0" ) ]
967- impl From < !> for Infallible {
992+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
993+ impl const From < !> for Infallible {
968994 #[ inline]
969995 fn from ( x : !) -> Self {
970996 x
0 commit comments