@@ -72,26 +72,6 @@ pub(super) fn relate_type_and_user_type<'tcx>(
72
72
a, v, user_ty, locations
73
73
) ;
74
74
75
- let b = match user_ty {
76
- UserTypeAnnotation :: Ty ( canonical_ty) => {
77
- let ( ty, _) =
78
- infcx. instantiate_canonical_with_fresh_inference_vars ( DUMMY_SP , & canonical_ty) ;
79
- ty
80
- }
81
- UserTypeAnnotation :: FnDef ( def_id, canonical_substs) => {
82
- let ( UserSubsts { substs, user_self_ty } , _) =
83
- infcx. instantiate_canonical_with_fresh_inference_vars ( DUMMY_SP , & canonical_substs) ;
84
- assert ! ( user_self_ty. is_none( ) ) ; // TODO for now
85
- infcx. tcx . mk_fn_def ( def_id, substs)
86
- }
87
- UserTypeAnnotation :: AdtDef ( adt_def, canonical_substs) => {
88
- let ( UserSubsts { substs, user_self_ty } , _) =
89
- infcx. instantiate_canonical_with_fresh_inference_vars ( DUMMY_SP , & canonical_substs) ;
90
- assert ! ( user_self_ty. is_none( ) ) ; // TODO for now
91
- infcx. tcx . mk_adt ( adt_def, substs)
92
- }
93
- } ;
94
-
95
75
// The `TypeRelating` code assumes that the "canonical variables"
96
76
// appear in the "a" side, so flip `Contravariant` ambient
97
77
// variance to get the right relationship.
@@ -102,9 +82,41 @@ pub(super) fn relate_type_and_user_type<'tcx>(
102
82
NllTypeRelatingDelegate :: new ( infcx, borrowck_context, locations, category) ,
103
83
v1,
104
84
) ;
105
- type_relating. relate ( & b, & a) ?;
106
85
107
- Ok ( b)
86
+ match user_ty {
87
+ UserTypeAnnotation :: Ty ( canonical_ty) => {
88
+ let ( ty, _) =
89
+ infcx. instantiate_canonical_with_fresh_inference_vars ( DUMMY_SP , & canonical_ty) ;
90
+ type_relating. relate ( & ty, & a) ?;
91
+ Ok ( ty)
92
+ }
93
+ UserTypeAnnotation :: FnDef ( def_id, canonical_substs) => {
94
+ let (
95
+ UserSubsts {
96
+ substs,
97
+ user_self_ty,
98
+ } ,
99
+ _,
100
+ ) = infcx. instantiate_canonical_with_fresh_inference_vars ( DUMMY_SP , & canonical_substs) ;
101
+ assert ! ( user_self_ty. is_none( ) ) ; // TODO for now
102
+ let ty = infcx. tcx . mk_fn_def ( def_id, substs) ;
103
+ type_relating. relate ( & ty, & a) ?;
104
+ Ok ( ty)
105
+ }
106
+ UserTypeAnnotation :: AdtDef ( adt_def, canonical_substs) => {
107
+ let (
108
+ UserSubsts {
109
+ substs,
110
+ user_self_ty,
111
+ } ,
112
+ _,
113
+ ) = infcx. instantiate_canonical_with_fresh_inference_vars ( DUMMY_SP , & canonical_substs) ;
114
+ assert ! ( user_self_ty. is_none( ) ) ; // TODO for now
115
+ let ty = infcx. tcx . mk_adt ( adt_def, substs) ;
116
+ type_relating. relate ( & ty, & a) ?;
117
+ Ok ( ty)
118
+ }
119
+ }
108
120
}
109
121
110
122
struct NllTypeRelatingDelegate < ' me , ' bccx : ' me , ' gcx : ' tcx , ' tcx : ' bccx > {
0 commit comments