@@ -700,12 +700,24 @@ pub struct CanonicalUserTypeAnnotation<'tcx> {
700
700
/// Canonical user type annotation.
701
701
pub type CanonicalUserType < ' tcx > = Canonical < ' tcx , UserType < ' tcx > > ;
702
702
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
+
703
715
/// A user-given type annotation attached to a constant. These arise
704
716
/// from constants that are named via paths, like `Foo::<A>::new` and
705
717
/// so forth.
706
718
#[ derive( Copy , Clone , Debug , PartialEq , TyEncodable , TyDecodable ) ]
707
719
#[ derive( Eq , Hash , HashStable , TypeFoldable , TypeVisitable ) ]
708
- pub enum UserType < ' tcx > {
720
+ pub enum UserTypeKind < ' tcx > {
709
721
Ty ( Ty < ' tcx > ) ,
710
722
711
723
/// The canonical type is the result of `type_of(def_id)` with the
@@ -721,9 +733,11 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
721
733
/// Returns `true` if this represents the generic parameters of the form `[?0, ?1, ?2]`,
722
734
/// i.e., each thing is mapped to a canonical variable with the same index.
723
735
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) => {
727
741
if user_args. user_self_ty . is_some ( ) {
728
742
return false ;
729
743
}
@@ -764,6 +778,14 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
764
778
}
765
779
766
780
impl < ' 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 > {
767
789
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
768
790
match self {
769
791
Self :: Ty ( arg0) => {
0 commit comments