@@ -700,12 +700,24 @@ pub struct CanonicalUserTypeAnnotation<'tcx> {
700700/// Canonical user type annotation.
701701pub type CanonicalUserType < ' tcx > = Canonical < ' tcx , UserType < ' tcx > > ;
702702
703+ #[ derive( Copy , Clone , Debug , PartialEq , TyEncodable , TyDecodable ) ]
704+ #[ derive( Eq , Hash , HashStable , TypeFoldable , TypeVisitable ) ]
705+ pub struct UserType < ' tcx > {
706+ pub kind : UserTypeKind < ' tcx > ,
707+ }
708+
709+ impl < ' tcx > UserType < ' tcx > {
710+ pub fn new ( kind : UserTypeKind < ' tcx > ) -> UserType < ' tcx > {
711+ UserType { kind }
712+ }
713+ }
714+
703715/// A user-given type annotation attached to a constant. These arise
704716/// from constants that are named via paths, like `Foo::<A>::new` and
705717/// so forth.
706718#[ derive( Copy , Clone , Debug , PartialEq , TyEncodable , TyDecodable ) ]
707719#[ derive( Eq , Hash , HashStable , TypeFoldable , TypeVisitable ) ]
708- pub enum UserType < ' tcx > {
720+ pub enum UserTypeKind < ' tcx > {
709721 Ty ( Ty < ' tcx > ) ,
710722
711723 /// The canonical type is the result of `type_of(def_id)` with the
@@ -721,9 +733,11 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
721733 /// Returns `true` if this represents the generic parameters of the form `[?0, ?1, ?2]`,
722734 /// i.e., each thing is mapped to a canonical variable with the same index.
723735 fn is_identity ( & self ) -> bool {
724- match self . value {
725- UserType :: Ty ( _) => false ,
726- UserType :: TypeOf ( _, user_args) => {
736+ // TODO:
737+
738+ match self . value . kind {
739+ UserTypeKind :: Ty ( _) => false ,
740+ UserTypeKind :: TypeOf ( _, user_args) => {
727741 if user_args. user_self_ty . is_some ( ) {
728742 return false ;
729743 }
@@ -764,6 +778,14 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
764778}
765779
766780impl < ' tcx > std:: fmt:: Display for UserType < ' tcx > {
781+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
782+ // TODO:
783+
784+ self . kind . fmt ( f)
785+ }
786+ }
787+
788+ impl < ' tcx > std:: fmt:: Display for UserTypeKind < ' tcx > {
767789 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
768790 match self {
769791 Self :: Ty ( arg0) => {
0 commit comments