@@ -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 ( ) ;
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
@@ -273,12 +260,13 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
273260 self . add_constraints_from_args ( current, def. did ( ) , args, variance) ;
274261 }
275262
276- ty:: Alias ( ty:: Projection | ty:: Inherent | ty:: Opaque , ref data) => {
277- self . add_constraints_from_invariant_args ( current, data. args , variance) ;
263+ ty:: Alias ( ty:: Free , alias_ty) => {
264+ let ty = self . tcx ( ) . type_of ( alias_ty. def_id ) . instantiate ( self . tcx ( ) , alias_ty. args ) ;
265+ self . add_constraints_from_ty ( current, ty, variance) ;
278266 }
279267
280- ty:: Alias ( ty :: Free , ref data ) => {
281- self . add_constraints_from_args ( current, data . def_id , data . args , variance) ;
268+ ty:: Alias ( _ , ref alias_ty ) => {
269+ self . add_constraints_from_invariant_args ( current, alias_ty . args , variance) ;
282270 }
283271
284272 ty:: Dynamic ( data, r, _) => {
0 commit comments