@@ -9,9 +9,10 @@ use rustc_type_ir_macros::{
99} ;
1010
1111use crate :: inherent:: * ;
12+ use crate :: ty:: AliasTerm ;
1213use crate :: upcast:: { Upcast , UpcastFrom } ;
1314use crate :: visit:: TypeVisitableExt as _;
14- use crate :: { self as ty, AliasTyKind , Interner , UnevaluatedConstKind } ;
15+ use crate :: { self as ty, Alias , AliasTyKind , Interner , UnevaluatedConstKind } ;
1516
1617/// `A: 'region`
1718#[ derive_where( Clone , Hash , PartialEq , Debug ; I : Interner , A ) ]
@@ -537,7 +538,7 @@ impl<I: Interner> ty::Binder<I, ExistentialProjection<I>> {
537538}
538539
539540#[ derive_where( Clone , Copy , PartialEq , Eq , Hash , Debug ; I : Interner ) ]
540- #[ derive( Lift_Generic , TypeVisitable_Generic , GenericTypeVisitable ) ]
541+ #[ derive( TypeVisitable_Generic , TypeFoldable_Generic , Lift_Generic , GenericTypeVisitable ) ]
541542#[ cfg_attr(
542543 feature = "nightly" ,
543544 derive( Encodable_NoContext , Decodable_NoContext , StableHash_NoContext )
@@ -640,41 +641,6 @@ impl<I: Interner> From<ty::UnevaluatedConstKind<I>> for AliasTermKind<I> {
640641 }
641642}
642643
643- /// Represents the unprojected term of a projection goal.
644- ///
645- /// * For a projection, this would be `<Ty as Trait<...>>::N<...>`.
646- /// * For an inherent projection, this would be `Ty::N<...>`.
647- /// * For an opaque type, there is no explicit syntax.
648- #[ derive_where( Clone , Copy , Hash , PartialEq , Debug ; I : Interner ) ]
649- #[ derive( TypeVisitable_Generic , GenericTypeVisitable , TypeFoldable_Generic , Lift_Generic ) ]
650- #[ cfg_attr(
651- feature = "nightly" ,
652- derive( Decodable_NoContext , Encodable_NoContext , StableHash_NoContext )
653- ) ]
654- pub struct AliasTerm < I : Interner > {
655- /// The parameters of the associated or opaque item.
656- ///
657- /// For a projection, these are the generic parameters for the trait and the
658- /// GAT parameters, if there are any.
659- ///
660- /// For an inherent projection, they consist of the self type and the GAT parameters,
661- /// if there are any.
662- ///
663- /// For RPIT the generic parameters are for the generics of the function,
664- /// while for TAIT it is used for the generic parameters of the alias.
665- pub args : I :: GenericArgs ,
666-
667- #[ type_foldable( identity) ]
668- #[ type_visitable( ignore) ]
669- pub kind : AliasTermKind < I > ,
670-
671- /// This field exists to prevent the creation of `AliasTerm` without using [`AliasTerm::new_from_args`].
672- #[ derive_where( skip( Debug ) ) ]
673- _use_alias_term_new_instead : ( ) ,
674- }
675-
676- impl < I : Interner > Eq for AliasTerm < I > { }
677-
678644impl < I : Interner > AliasTerm < I > {
679645 pub fn new_from_args (
680646 interner : I ,
@@ -694,7 +660,7 @@ impl<I: Interner> AliasTerm<I> {
694660 } ;
695661 interner. debug_assert_args_compatible ( def_id, args) ;
696662 }
697- AliasTerm { kind, args, _use_alias_term_new_instead : ( ) }
663+ AliasTerm { kind, args, _use_alias_new_instead : ( ) }
698664 }
699665
700666 pub fn new (
@@ -724,7 +690,7 @@ impl<I: Interner> AliasTerm<I> {
724690 panic ! ( "Cannot turn `{}` into `AliasTy`" , kind. descr( ) )
725691 }
726692 } ;
727- ty:: AliasTy { kind, args : self . args , _use_alias_ty_new_instead : ( ) }
693+ ty:: AliasTy { kind, args : self . args , _use_alias_new_instead : ( ) }
728694 }
729695
730696 pub fn expect_ct ( self ) -> ty:: UnevaluatedConst < I > {
@@ -742,7 +708,7 @@ impl<I: Interner> AliasTerm<I> {
742708 panic ! ( "Cannot turn `{}` into `UnevaluatedConst`" , kind. descr( ) )
743709 }
744710 } ;
745- ty:: UnevaluatedConst { kind, args : self . args , _use_unevaluated_const_new_instead : ( ) }
711+ ty:: UnevaluatedConst { kind, args : self . args , _use_alias_new_instead : ( ) }
746712 }
747713
748714 pub fn to_term ( self , interner : I ) -> I :: Term {
@@ -897,21 +863,13 @@ impl<I: Interner> AliasTerm<I> {
897863
898864impl < I : Interner > From < ty:: AliasTy < I > > for AliasTerm < I > {
899865 fn from ( ty : ty:: AliasTy < I > ) -> Self {
900- AliasTerm {
901- args : ty. args ,
902- kind : AliasTermKind :: from ( ty. kind ) ,
903- _use_alias_term_new_instead : ( ) ,
904- }
866+ AliasTerm { args : ty. args , kind : AliasTermKind :: from ( ty. kind ) , _use_alias_new_instead : ( ) }
905867 }
906868}
907869
908870impl < I : Interner > From < ty:: UnevaluatedConst < I > > for AliasTerm < I > {
909871 fn from ( ty : ty:: UnevaluatedConst < I > ) -> Self {
910- AliasTerm {
911- args : ty. args ,
912- kind : AliasTermKind :: from ( ty. kind ) ,
913- _use_alias_term_new_instead : ( ) ,
914- }
872+ AliasTerm { args : ty. args , kind : AliasTermKind :: from ( ty. kind ) , _use_alias_new_instead : ( ) }
915873 }
916874}
917875
@@ -990,19 +948,17 @@ impl<I: Interner> fmt::Debug for ProjectionPredicate<I> {
990948
991949/// Used by the new solver to normalize an alias. This always expects the `term` to
992950/// be an unconstrained inference variable which is used as the output.
993- #[ derive_where( Clone , Copy , Hash , PartialEq ; I : Interner ) ]
951+ #[ derive_where( Clone , Copy , Hash , Eq , PartialEq ; I : Interner , K ) ]
994952#[ derive( TypeVisitable_Generic , GenericTypeVisitable , TypeFoldable_Generic , Lift_Generic ) ]
995953#[ cfg_attr(
996954 feature = "nightly" ,
997955 derive( Decodable_NoContext , Encodable_NoContext , StableHash_NoContext )
998956) ]
999- pub struct NormalizesTo < I : Interner > {
1000- pub alias : AliasTerm < I > ,
957+ pub struct NormalizesTo < I : Interner , K = AliasTermKind < I > > {
958+ pub alias : Alias < I , K > ,
1001959 pub term : I :: Term ,
1002960}
1003961
1004- impl < I : Interner > Eq for NormalizesTo < I > { }
1005-
1006962impl < I : Interner > NormalizesTo < I > {
1007963 pub fn self_ty ( self ) -> I :: Ty {
1008964 self . alias . self_ty ( )
@@ -1017,7 +973,13 @@ impl<I: Interner> NormalizesTo<I> {
1017973 }
1018974}
1019975
1020- impl < I : Interner > fmt:: Debug for NormalizesTo < I > {
976+ impl < I : Interner , K > fmt:: Debug for NormalizesTo < I , K >
977+ where
978+ // `TypeVisitable_Generic` derived on `NormalizesTo` creates a field-level
979+ // `Alias<I, K>: TypeVisitable<I>` bound. Since `TypeVisitable<I>: fmt::Debug`,
980+ // that proves `Alias<I, K>: fmt::Debug`, but not `K: fmt::Debug`.
981+ Alias < I , K > : fmt:: Debug ,
982+ {
1021983 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1022984 write ! ( f, "NormalizesTo({:?}, {:?})" , self . alias, self . term)
1023985 }
0 commit comments