@@ -216,6 +216,8 @@ pub const fn identity<T>(x: T) -> T {
216
216
/// ```
217
217
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
218
218
#[ rustc_diagnostic_item = "AsRef" ]
219
+ #[ const_trait]
220
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
219
221
pub trait AsRef < T : PointeeSized > : PointeeSized {
220
222
/// Converts this type into a shared reference of the (usually inferred) input type.
221
223
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -367,6 +369,8 @@ pub trait AsRef<T: PointeeSized>: PointeeSized {
367
369
/// `&mut Vec<u8>`, for example, is the better choice (callers need to pass the correct type then).
368
370
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
369
371
#[ rustc_diagnostic_item = "AsMut" ]
372
+ #[ const_trait]
373
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
370
374
pub trait AsMut < T : PointeeSized > : PointeeSized {
371
375
/// Converts this type into a mutable reference of the (usually inferred) input type.
372
376
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -445,6 +449,8 @@ pub trait AsMut<T: PointeeSized>: PointeeSized {
445
449
#[ rustc_diagnostic_item = "Into" ]
446
450
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
447
451
#[ doc( search_unbox) ]
452
+ #[ const_trait]
453
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
448
454
pub trait Into < T > : Sized {
449
455
/// Converts this type into the (usually inferred) input type.
450
456
#[ must_use]
@@ -580,6 +586,8 @@ pub trait Into<T>: Sized {
580
586
note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix" ,
581
587
) ) ]
582
588
#[ doc( search_unbox) ]
589
+ #[ const_trait]
590
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
583
591
pub trait From < T > : Sized {
584
592
/// Converts to this type from the input type.
585
593
#[ rustc_diagnostic_item = "from_fn" ]
@@ -607,6 +615,8 @@ pub trait From<T>: Sized {
607
615
/// [`Into`], see there for details.
608
616
#[ rustc_diagnostic_item = "TryInto" ]
609
617
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
618
+ #[ const_trait]
619
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
610
620
pub trait TryInto < T > : Sized {
611
621
/// The type returned in the event of a conversion error.
612
622
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
@@ -685,6 +695,8 @@ pub trait TryInto<T>: Sized {
685
695
/// [`try_from`]: TryFrom::try_from
686
696
#[ rustc_diagnostic_item = "TryFrom" ]
687
697
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
698
+ #[ const_trait]
699
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
688
700
pub trait TryFrom < T > : Sized {
689
701
/// The type returned in the event of a conversion error.
690
702
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
@@ -702,9 +714,10 @@ pub trait TryFrom<T>: Sized {
702
714
703
715
// As lifts over &
704
716
#[ 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
706
719
where
707
- T : AsRef < U > ,
720
+ T : ~ const AsRef < U > ,
708
721
{
709
722
#[ inline]
710
723
fn as_ref ( & self ) -> & U {
@@ -714,9 +727,10 @@ where
714
727
715
728
// As lifts over &mut
716
729
#[ 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
718
732
where
719
- T : AsRef < U > ,
733
+ T : ~ const AsRef < U > ,
720
734
{
721
735
#[ inline]
722
736
fn as_ref ( & self ) -> & U {
@@ -734,9 +748,10 @@ where
734
748
735
749
// AsMut lifts over &mut
736
750
#[ 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
738
753
where
739
- T : AsMut < U > ,
754
+ T : ~ const AsMut < U > ,
740
755
{
741
756
#[ inline]
742
757
fn as_mut ( & mut self ) -> & mut U {
@@ -754,9 +769,10 @@ where
754
769
755
770
// From implies Into
756
771
#[ 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
758
774
where
759
- U : From < T > ,
775
+ U : ~ const From < T > ,
760
776
{
761
777
/// Calls `U::from(self)`.
762
778
///
@@ -771,7 +787,8 @@ where
771
787
772
788
// From (and thus Into) is reflexive
773
789
#[ 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 {
775
792
/// Returns the argument unchanged.
776
793
#[ inline( always) ]
777
794
fn from ( t : T ) -> T {
@@ -795,9 +812,10 @@ impl<T> From<!> for T {
795
812
796
813
// TryFrom implies TryInto
797
814
#[ 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
799
817
where
800
- U : TryFrom < T > ,
818
+ U : ~ const TryFrom < T > ,
801
819
{
802
820
type Error = U :: Error ;
803
821
@@ -810,9 +828,10 @@ where
810
828
// Infallible conversions are semantically equivalent to fallible conversions
811
829
// with an uninhabited error type.
812
830
#[ 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
814
833
where
815
- U : Into < T > ,
834
+ U : ~ const Into < T > ,
816
835
{
817
836
type Error = Infallible ;
818
837
@@ -827,31 +846,35 @@ where
827
846
////////////////////////////////////////////////////////////////////////////////
828
847
829
848
#[ 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 ] {
831
851
#[ inline( always) ]
832
852
fn as_ref ( & self ) -> & [ T ] {
833
853
self
834
854
}
835
855
}
836
856
837
857
#[ 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 ] {
839
860
#[ inline( always) ]
840
861
fn as_mut ( & mut self ) -> & mut [ T ] {
841
862
self
842
863
}
843
864
}
844
865
845
866
#[ 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 {
847
869
#[ inline( always) ]
848
870
fn as_ref ( & self ) -> & str {
849
871
self
850
872
}
851
873
}
852
874
853
875
#[ 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 {
855
878
#[ inline( always) ]
856
879
fn as_mut ( & mut self ) -> & mut str {
857
880
self
@@ -912,7 +935,8 @@ impl AsMut<str> for str {
912
935
pub enum Infallible { }
913
936
914
937
#[ 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 {
916
940
fn clone ( & self ) -> Infallible {
917
941
match * self { }
918
942
}
@@ -940,7 +964,8 @@ impl Error for Infallible {
940
964
}
941
965
942
966
#[ 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 {
944
969
fn eq ( & self , _: & Infallible ) -> bool {
945
970
match * self { }
946
971
}
@@ -964,7 +989,8 @@ impl Ord for Infallible {
964
989
}
965
990
966
991
#[ 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 {
968
994
#[ inline]
969
995
fn from ( x : !) -> Self {
970
996
x
0 commit comments