@@ -16,7 +16,7 @@ use rustc::mir::{ConstraintCategory, UserTypeAnnotation};
16
16
use rustc:: traits:: query:: Fallible ;
17
17
use rustc:: ty:: relate:: TypeRelation ;
18
18
use rustc:: ty:: subst:: { Subst , UserSelfTy , UserSubsts } ;
19
- use rustc:: ty:: { self , Ty } ;
19
+ use rustc:: ty:: { self , Ty , TypeFoldable } ;
20
20
use syntax_pos:: DUMMY_SP ;
21
21
22
22
/// Adds sufficient constraints to ensure that `a <: b`.
@@ -109,6 +109,18 @@ pub(super) fn relate_type_and_user_type<'tcx>(
109
109
{
110
110
let impl_self_ty = infcx. tcx . type_of ( impl_def_id) ;
111
111
let impl_self_ty = impl_self_ty. subst ( infcx. tcx , & substs) ;
112
+
113
+ // There may be type variables in `substs` and hence
114
+ // in `impl_self_ty`, but they should all have been
115
+ // resolved to some fixed value during the first call
116
+ // to `relate`, above. Therefore, if we use
117
+ // `resolve_type_vars_if_possible` we should get to
118
+ // something without type variables. This is important
119
+ // because the `b` type in `relate_with_variance`
120
+ // below is not permitted to have inference variables.
121
+ let impl_self_ty = infcx. resolve_type_vars_if_possible ( & impl_self_ty) ;
122
+ assert ! ( !impl_self_ty. has_infer_types( ) ) ;
123
+
112
124
type_relating. relate_with_variance (
113
125
ty:: Variance :: Invariant ,
114
126
& self_ty,
0 commit comments