@@ -46,9 +46,7 @@ pub(super) fn find_opaque_ty_constraints_for_impl_trait_in_assoc_type(
4646 for & assoc_id in tcx. associated_item_def_ids ( impl_def_id) {
4747 let assoc = tcx. associated_item ( assoc_id) ;
4848 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 ( ) ) ,
5250 // Associated types don't have bodies, so they can't constrain hidden types
5351 ty:: AssocKind :: Type => { }
5452 }
@@ -182,15 +180,9 @@ struct TaitConstraintLocator<'tcx> {
182180 typeck_types : Vec < ty:: OpaqueHiddenType < ' tcx > > ,
183181}
184182
185- #[ derive( Debug ) ]
186- enum ImplTraitSource {
187- AssocTy ,
188- TyAlias ,
189- }
190-
191183impl TaitConstraintLocator < ' _ > {
192184 #[ 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 ) {
194186 // Don't try to check items that cannot possibly constrain the type.
195187 if !self . tcx . has_typeck_results ( item_def_id) {
196188 debug ! ( "no constraint: no typeck results" ) ;
@@ -242,12 +234,8 @@ impl TaitConstraintLocator<'_> {
242234 continue ;
243235 }
244236 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+
251239 if !opaque_types_defined_by. contains ( & self . def_id ) {
252240 self . tcx . dcx ( ) . emit_err ( TaitForwardCompat {
253241 span : hidden_type. span ,
@@ -308,29 +296,29 @@ impl<'tcx> intravisit::Visitor<'tcx> for TaitConstraintLocator<'tcx> {
308296 }
309297 fn visit_expr ( & mut self , ex : & ' tcx Expr < ' tcx > ) {
310298 if let hir:: ExprKind :: Closure ( closure) = ex. kind {
311- self . check ( closure. def_id , ImplTraitSource :: TyAlias ) ;
299+ self . check ( closure. def_id ) ;
312300 }
313301 intravisit:: walk_expr ( self , ex) ;
314302 }
315303 fn visit_item ( & mut self , it : & ' tcx Item < ' tcx > ) {
316304 trace ! ( ?it. owner_id) ;
317305 // The opaque type itself or its children are not within its reveal scope.
318306 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 ) ;
320308 intravisit:: walk_item ( self , it) ;
321309 }
322310 }
323311 fn visit_impl_item ( & mut self , it : & ' tcx ImplItem < ' tcx > ) {
324312 trace ! ( ?it. owner_id) ;
325313 // The opaque type itself or its children are not within its reveal scope.
326314 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 ) ;
328316 intravisit:: walk_impl_item ( self , it) ;
329317 }
330318 }
331319 fn visit_trait_item ( & mut self , it : & ' tcx TraitItem < ' tcx > ) {
332320 trace ! ( ?it. owner_id) ;
333- self . check ( it. owner_id . def_id , ImplTraitSource :: TyAlias ) ;
321+ self . check ( it. owner_id . def_id ) ;
334322 intravisit:: walk_trait_item ( self , it) ;
335323 }
336324 fn visit_foreign_item ( & mut self , it : & ' tcx hir:: ForeignItem < ' tcx > ) {
0 commit comments