@@ -79,9 +79,6 @@ pub(crate) fn add_constraints_from_crate<'a, 'tcx>(
7979 }
8080 }
8181 DefKind :: Fn | DefKind :: AssocFn => constraint_cx. build_constraints_for_item ( def_id) ,
82- DefKind :: TyAlias if tcx. type_alias_is_lazy ( def_id) => {
83- constraint_cx. build_constraints_for_item ( def_id)
84- }
8582 _ => { }
8683 }
8784 }
@@ -107,15 +104,6 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
107104 let current_item = & CurrentItem { inferred_start } ;
108105 let ty = tcx. type_of ( def_id) . instantiate_identity ( ) . skip_norm_wip ( ) ;
109106
110- // The type as returned by `type_of` is the underlying type and generally not a free alias.
111- // Therefore we need to check the `DefKind` first.
112- if let DefKind :: TyAlias = tcx. def_kind ( def_id)
113- && tcx. type_alias_is_lazy ( def_id)
114- {
115- self . add_constraints_from_ty ( current_item, ty, self . covariant ) ;
116- return ;
117- }
118-
119107 match ty. kind ( ) {
120108 ty:: Adt ( def, _) => {
121109 // Not entirely obvious: constraints on structs/enums do not
@@ -216,14 +204,13 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
216204 /// Adds constraints appropriate for an instance of `ty` appearing
217205 /// in a context with the generics defined in `generics` and
218206 /// ambient variance `variance`
207+ #[ instrument( level = "debug" , skip( self , current) ) ]
219208 fn add_constraints_from_ty (
220209 & mut self ,
221210 current : & CurrentItem ,
222211 ty : Ty < ' tcx > ,
223212 variance : VarianceTermPtr < ' a > ,
224213 ) {
225- debug ! ( "add_constraints_from_ty(ty={:?}, variance={:?})" , ty, variance) ;
226-
227214 match * ty. kind ( ) {
228215 ty:: Bool
229216 | ty:: Char
@@ -281,8 +268,9 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
281268 self . add_constraints_from_invariant_args ( current, args, variance) ;
282269 }
283270
284- ty:: Alias ( ty:: AliasTy { kind : ty:: Free { def_id } , args, .. } ) => {
285- self . add_constraints_from_args ( current, def_id, args, variance) ;
271+ ty:: Alias ( ty:: AliasTy { kind : ty:: Free { .. } , .. } ) => {
272+ let ty = self . tcx ( ) . expand_free_alias_tys ( ty) ;
273+ self . add_constraints_from_ty ( current, ty, variance) ;
286274 }
287275
288276 ty:: Dynamic ( data, r) => {
0 commit comments