about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Wood <david.wood@huawei.com>2021-10-01 14:40:42 +0000
committerDavid Wood <david.wood@huawei.com>2021-10-01 16:34:18 +0000
commit50433a0bf4a1d75f4d68c7d7b0acf5a75522421b (patch)
tree64f604470a4ef2d6a2f995e462a217a0fcd4ec97
parent4e4942dfa66667c0addfff8e0882a59b035d45ca (diff)
polymorphize: don't check foreign items
Foreign items do not have bodies and so cannot be polymorphized.

Signed-off-by: David Wood <david.wood@huawei.com>
-rw-r--r--compiler/rustc_monomorphize/src/polymorphize.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_monomorphize/src/polymorphize.rs b/compiler/rustc_monomorphize/src/polymorphize.rs
index 0f768b7819b..b5a1a1a74c8 100644
--- a/compiler/rustc_monomorphize/src/polymorphize.rs
+++ b/compiler/rustc_monomorphize/src/polymorphize.rs
@@ -52,6 +52,11 @@ fn unused_generic_params(tcx: TyCtxt<'_>, def_id: DefId) -> FiniteBitSet<u32> {
         return FiniteBitSet::new_empty();
     }
 
+    // Exit early for foreign items, these have no bodies to analyze.
+    if tcx.is_foreign_item(def_id) {
+        return FiniteBitSet::new_empty();
+    }
+
     // Exit early when there is no MIR available.
     let context = tcx.hir().body_const_context(def_id.expect_local());
     match context {