@@ -350,7 +350,7 @@ pub struct TypeckTables<'tcx> {
350
350
/// canonical substitutions would include only `for<X> { Vec<X> }`.
351
351
///
352
352
/// See also `AscribeUserType` statement in MIR.
353
- user_provided_types : ItemLocalMap < CanonicalUserTypeAnnotation < ' tcx > > ,
353
+ user_provided_types : ItemLocalMap < CanonicalUserType < ' tcx > > ,
354
354
355
355
/// Stores the canonicalized types provided by the user. See also
356
356
/// `AscribeUserType` statement in MIR.
@@ -493,7 +493,7 @@ impl<'tcx> TypeckTables<'tcx> {
493
493
494
494
pub fn user_provided_types (
495
495
& self
496
- ) -> LocalTableInContext < ' _ , CanonicalUserTypeAnnotation < ' tcx > > {
496
+ ) -> LocalTableInContext < ' _ , CanonicalUserType < ' tcx > > {
497
497
LocalTableInContext {
498
498
local_id_root : self . local_id_root ,
499
499
data : & self . user_provided_types
@@ -502,7 +502,7 @@ impl<'tcx> TypeckTables<'tcx> {
502
502
503
503
pub fn user_provided_types_mut (
504
504
& mut self
505
- ) -> LocalTableInContextMut < ' _ , CanonicalUserTypeAnnotation < ' tcx > > {
505
+ ) -> LocalTableInContextMut < ' _ , CanonicalUserType < ' tcx > > {
506
506
LocalTableInContextMut {
507
507
local_id_root : self . local_id_root ,
508
508
data : & mut self . user_provided_types
@@ -800,25 +800,46 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> {
800
800
801
801
newtype_index ! {
802
802
pub struct UserTypeAnnotationIndex {
803
- DEBUG_FORMAT = "UserTypeAnnotation ({})" ,
803
+ DEBUG_FORMAT = "UserType ({})" ,
804
804
const START_INDEX = 0 ,
805
805
}
806
806
}
807
807
808
808
/// Mapping of type annotation indices to canonical user type annotations.
809
809
pub type CanonicalUserTypeAnnotations < ' tcx > =
810
- IndexVec < UserTypeAnnotationIndex , ( Span , CanonicalUserTypeAnnotation < ' tcx > ) > ;
810
+ IndexVec < UserTypeAnnotationIndex , CanonicalUserTypeAnnotation < ' tcx > > ;
811
+
812
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
813
+ pub struct CanonicalUserTypeAnnotation < ' tcx > {
814
+ pub user_ty : CanonicalUserType < ' tcx > ,
815
+ pub span : Span ,
816
+ pub inferred_ty : Ty < ' tcx > ,
817
+ }
818
+
819
+ BraceStructTypeFoldableImpl ! {
820
+ impl <' tcx> TypeFoldable <' tcx> for CanonicalUserTypeAnnotation <' tcx> {
821
+ user_ty, span, inferred_ty
822
+ }
823
+ }
824
+
825
+ BraceStructLiftImpl ! {
826
+ impl <' a, ' tcx> Lift <' tcx> for CanonicalUserTypeAnnotation <' a> {
827
+ type Lifted = CanonicalUserTypeAnnotation <' tcx>;
828
+ user_ty, span, inferred_ty
829
+ }
830
+ }
831
+
811
832
812
833
/// Canonicalized user type annotation.
813
- pub type CanonicalUserTypeAnnotation < ' gcx > = Canonical < ' gcx , UserTypeAnnotation < ' gcx > > ;
834
+ pub type CanonicalUserType < ' gcx > = Canonical < ' gcx , UserType < ' gcx > > ;
814
835
815
- impl CanonicalUserTypeAnnotation < ' gcx > {
836
+ impl CanonicalUserType < ' gcx > {
816
837
/// Returns `true` if this represents a substitution of the form `[?0, ?1, ?2]`,
817
838
/// i.e. each thing is mapped to a canonical variable with the same index.
818
839
pub fn is_identity ( & self ) -> bool {
819
840
match self . value {
820
- UserTypeAnnotation :: Ty ( _) => false ,
821
- UserTypeAnnotation :: TypeOf ( _, user_substs) => {
841
+ UserType :: Ty ( _) => false ,
842
+ UserType :: TypeOf ( _, user_substs) => {
822
843
if user_substs. user_self_ty . is_some ( ) {
823
844
return false ;
824
845
}
@@ -853,7 +874,7 @@ impl CanonicalUserTypeAnnotation<'gcx> {
853
874
/// from constants that are named via paths, like `Foo::<A>::new` and
854
875
/// so forth.
855
876
#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
856
- pub enum UserTypeAnnotation < ' tcx > {
877
+ pub enum UserType < ' tcx > {
857
878
Ty ( Ty < ' tcx > ) ,
858
879
859
880
/// The canonical type is the result of `type_of(def_id)` with the
@@ -862,17 +883,17 @@ pub enum UserTypeAnnotation<'tcx> {
862
883
}
863
884
864
885
EnumTypeFoldableImpl ! {
865
- impl <' tcx> TypeFoldable <' tcx> for UserTypeAnnotation <' tcx> {
866
- ( UserTypeAnnotation :: Ty ) ( ty) ,
867
- ( UserTypeAnnotation :: TypeOf ) ( def, substs) ,
886
+ impl <' tcx> TypeFoldable <' tcx> for UserType <' tcx> {
887
+ ( UserType :: Ty ) ( ty) ,
888
+ ( UserType :: TypeOf ) ( def, substs) ,
868
889
}
869
890
}
870
891
871
892
EnumLiftImpl ! {
872
- impl <' a, ' tcx> Lift <' tcx> for UserTypeAnnotation <' a> {
873
- type Lifted = UserTypeAnnotation <' tcx>;
874
- ( UserTypeAnnotation :: Ty ) ( ty) ,
875
- ( UserTypeAnnotation :: TypeOf ) ( def, substs) ,
893
+ impl <' a, ' tcx> Lift <' tcx> for UserType <' a> {
894
+ type Lifted = UserType <' tcx>;
895
+ ( UserType :: Ty ) ( ty) ,
896
+ ( UserType :: TypeOf ) ( def, substs) ,
876
897
}
877
898
}
878
899
0 commit comments