about summary refs log tree commit diff
path: root/compiler/rustc_passes
diff options
context:
space:
mode:
authorhyd-dev <yd-huang@outlook.com>2021-08-14 23:24:33 +0800
committerhyd-dev <yd-huang@outlook.com>2021-08-15 02:59:53 +0800
commit29b73ee5fa04e4ccbd1468e50fb88470b03d4d27 (patch)
treec54de097386027c21da41d4881a397367148944e /compiler/rustc_passes
parent9315a0cd4c3b9568e66cf613fecad1bfac214f53 (diff)
downloadrust-29b73ee5fa04e4ccbd1468e50fb88470b03d4d27.tar.gz
rust-29b73ee5fa04e4ccbd1468e50fb88470b03d4d27.zip
Fix `reachable_set` for non-function items in non-library crates
Diffstat (limited to 'compiler/rustc_passes')
-rw-r--r--compiler/rustc_passes/src/reachable.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs
index 963153a01a0..5ca098c2287 100644
--- a/compiler/rustc_passes/src/reachable.rs
+++ b/compiler/rustc_passes/src/reachable.rs
@@ -211,21 +211,22 @@ impl<'tcx> ReachableContext<'tcx> {
         if !self.any_library {
             // If we are building an executable, only explicitly extern
             // types need to be exported.
-            if let Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, ..), def_id, .. })
-            | Node::ImplItem(hir::ImplItem {
-                kind: hir::ImplItemKind::Fn(sig, ..),
-                def_id,
-                ..
-            }) = *node
-            {
-                let reachable = sig.header.abi != Abi::Rust;
-                let codegen_attrs = self.tcx.codegen_fn_attrs(*def_id);
-                let is_extern = codegen_attrs.contains_extern_indicator();
-                let std_internal =
-                    codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
-                if reachable || is_extern || std_internal {
-                    self.reachable_symbols.insert(search_item);
-                }
+            let reachable =
+                if let Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, ..), .. })
+                | Node::ImplItem(hir::ImplItem {
+                    kind: hir::ImplItemKind::Fn(sig, ..), ..
+                }) = *node
+                {
+                    sig.header.abi != Abi::Rust
+                } else {
+                    false
+                };
+            let codegen_attrs = self.tcx.codegen_fn_attrs(search_item);
+            let is_extern = codegen_attrs.contains_extern_indicator();
+            let std_internal =
+                codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
+            if reachable || is_extern || std_internal {
+                self.reachable_symbols.insert(search_item);
             }
         } else {
             // If we are building a library, then reachable symbols will