@@ -211,13 +211,15 @@ impl<'tcx> ReachableContext<'tcx> {
211
211
if !self . any_library {
212
212
// If we are building an executable, only explicitly extern
213
213
// types need to be exported.
214
- if let Node :: Item ( item) = * node {
215
- let reachable = if let hir:: ItemKind :: Fn ( ref sig, ..) = item. kind {
216
- sig. header . abi != Abi :: Rust
217
- } else {
218
- false
219
- } ;
220
- let codegen_attrs = self . tcx . codegen_fn_attrs ( item. def_id ) ;
214
+ if let Node :: Item ( hir:: Item { kind : hir:: ItemKind :: Fn ( sig, ..) , def_id, .. } )
215
+ | Node :: ImplItem ( hir:: ImplItem {
216
+ kind : hir:: ImplItemKind :: Fn ( sig, ..) ,
217
+ def_id,
218
+ ..
219
+ } ) = * node
220
+ {
221
+ let reachable = sig. header . abi != Abi :: Rust ;
222
+ let codegen_attrs = self . tcx . codegen_fn_attrs ( * def_id) ;
221
223
let is_extern = codegen_attrs. contains_extern_indicator ( ) ;
222
224
let std_internal =
223
225
codegen_attrs. flags . contains ( CodegenFnAttrFlags :: RUSTC_STD_INTERNAL_SYMBOL ) ;
@@ -335,17 +337,23 @@ struct CollectPrivateImplItemsVisitor<'a, 'tcx> {
335
337
worklist : & ' a mut Vec < LocalDefId > ,
336
338
}
337
339
338
- impl < ' a , ' tcx > ItemLikeVisitor < ' tcx > for CollectPrivateImplItemsVisitor < ' a , ' tcx > {
339
- fn visit_item ( & mut self , item : & hir :: Item < ' _ > ) {
340
+ impl CollectPrivateImplItemsVisitor < ' _ , ' _ > {
341
+ fn push_to_worklist_if_has_custom_linkage ( & mut self , def_id : LocalDefId ) {
340
342
// Anything which has custom linkage gets thrown on the worklist no
341
343
// matter where it is in the crate, along with "special std symbols"
342
344
// which are currently akin to allocator symbols.
343
- let codegen_attrs = self . tcx . codegen_fn_attrs ( item . def_id ) ;
345
+ let codegen_attrs = self . tcx . codegen_fn_attrs ( def_id) ;
344
346
if codegen_attrs. contains_extern_indicator ( )
345
347
|| codegen_attrs. flags . contains ( CodegenFnAttrFlags :: RUSTC_STD_INTERNAL_SYMBOL )
346
348
{
347
- self . worklist . push ( item . def_id ) ;
349
+ self . worklist . push ( def_id) ;
348
350
}
351
+ }
352
+ }
353
+
354
+ impl < ' a , ' tcx > ItemLikeVisitor < ' tcx > for CollectPrivateImplItemsVisitor < ' a , ' tcx > {
355
+ fn visit_item ( & mut self , item : & hir:: Item < ' _ > ) {
356
+ self . push_to_worklist_if_has_custom_linkage ( item. def_id ) ;
349
357
350
358
// We need only trait impls here, not inherent impls, and only non-exported ones
351
359
if let hir:: ItemKind :: Impl ( hir:: Impl { of_trait : Some ( ref trait_ref) , ref items, .. } ) =
@@ -375,8 +383,8 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
375
383
376
384
fn visit_trait_item ( & mut self , _trait_item : & hir:: TraitItem < ' _ > ) { }
377
385
378
- fn visit_impl_item ( & mut self , _impl_item : & hir:: ImplItem < ' _ > ) {
379
- // processed in visit_item above
386
+ fn visit_impl_item ( & mut self , impl_item : & hir:: ImplItem < ' _ > ) {
387
+ self . push_to_worklist_if_has_custom_linkage ( impl_item . def_id ) ;
380
388
}
381
389
382
390
fn visit_foreign_item ( & mut self , _foreign_item : & hir:: ForeignItem < ' _ > ) {
0 commit comments