@@ -46,9 +46,7 @@ pub(super) fn find_opaque_ty_constraints_for_impl_trait_in_assoc_type(
46
46
for & assoc_id in tcx. associated_item_def_ids ( impl_def_id) {
47
47
let assoc = tcx. associated_item ( assoc_id) ;
48
48
match assoc. kind {
49
- ty:: AssocKind :: Const | ty:: AssocKind :: Fn => {
50
- locator. check ( assoc_id. expect_local ( ) , ImplTraitSource :: AssocTy )
51
- }
49
+ ty:: AssocKind :: Const | ty:: AssocKind :: Fn => locator. check ( assoc_id. expect_local ( ) ) ,
52
50
// Associated types don't have bodies, so they can't constrain hidden types
53
51
ty:: AssocKind :: Type => { }
54
52
}
@@ -182,15 +180,9 @@ struct TaitConstraintLocator<'tcx> {
182
180
typeck_types : Vec < ty:: OpaqueHiddenType < ' tcx > > ,
183
181
}
184
182
185
- #[ derive( Debug ) ]
186
- enum ImplTraitSource {
187
- AssocTy ,
188
- TyAlias ,
189
- }
190
-
191
183
impl TaitConstraintLocator < ' _ > {
192
184
#[ instrument( skip( self ) , level = "debug" ) ]
193
- fn check ( & mut self , item_def_id : LocalDefId , source : ImplTraitSource ) {
185
+ fn check ( & mut self , item_def_id : LocalDefId ) {
194
186
// Don't try to check items that cannot possibly constrain the type.
195
187
if !self . tcx . has_typeck_results ( item_def_id) {
196
188
debug ! ( "no constraint: no typeck results" ) ;
@@ -242,12 +234,8 @@ impl TaitConstraintLocator<'_> {
242
234
continue ;
243
235
}
244
236
constrained = true ;
245
- let opaque_types_defined_by = match source {
246
- ImplTraitSource :: AssocTy => {
247
- self . tcx . impl_trait_in_assoc_types_defined_by ( item_def_id)
248
- }
249
- ImplTraitSource :: TyAlias => self . tcx . opaque_types_defined_by ( item_def_id) ,
250
- } ;
237
+ let opaque_types_defined_by = self . tcx . opaque_types_defined_by ( item_def_id) ;
238
+
251
239
if !opaque_types_defined_by. contains ( & self . def_id ) {
252
240
self . tcx . dcx ( ) . emit_err ( TaitForwardCompat {
253
241
span : hidden_type. span ,
@@ -308,29 +296,29 @@ impl<'tcx> intravisit::Visitor<'tcx> for TaitConstraintLocator<'tcx> {
308
296
}
309
297
fn visit_expr ( & mut self , ex : & ' tcx Expr < ' tcx > ) {
310
298
if let hir:: ExprKind :: Closure ( closure) = ex. kind {
311
- self . check ( closure. def_id , ImplTraitSource :: TyAlias ) ;
299
+ self . check ( closure. def_id ) ;
312
300
}
313
301
intravisit:: walk_expr ( self , ex) ;
314
302
}
315
303
fn visit_item ( & mut self , it : & ' tcx Item < ' tcx > ) {
316
304
trace ! ( ?it. owner_id) ;
317
305
// The opaque type itself or its children are not within its reveal scope.
318
306
if it. owner_id . def_id != self . def_id {
319
- self . check ( it. owner_id . def_id , ImplTraitSource :: TyAlias ) ;
307
+ self . check ( it. owner_id . def_id ) ;
320
308
intravisit:: walk_item ( self , it) ;
321
309
}
322
310
}
323
311
fn visit_impl_item ( & mut self , it : & ' tcx ImplItem < ' tcx > ) {
324
312
trace ! ( ?it. owner_id) ;
325
313
// The opaque type itself or its children are not within its reveal scope.
326
314
if it. owner_id . def_id != self . def_id {
327
- self . check ( it. owner_id . def_id , ImplTraitSource :: TyAlias ) ;
315
+ self . check ( it. owner_id . def_id ) ;
328
316
intravisit:: walk_impl_item ( self , it) ;
329
317
}
330
318
}
331
319
fn visit_trait_item ( & mut self , it : & ' tcx TraitItem < ' tcx > ) {
332
320
trace ! ( ?it. owner_id) ;
333
- self . check ( it. owner_id . def_id , ImplTraitSource :: TyAlias ) ;
321
+ self . check ( it. owner_id . def_id ) ;
334
322
intravisit:: walk_trait_item ( self , it) ;
335
323
}
336
324
fn visit_foreign_item ( & mut self , it : & ' tcx hir:: ForeignItem < ' tcx > ) {
0 commit comments