about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-08-15 10:28:09 +0200
committerGitHub <noreply@github.com>2022-08-15 10:28:09 +0200
commitd6b650391ac5e489ecd52a4dba35db3c1395a4e1 (patch)
treeb27560c119dd03eff2e5530c9107e833804d0db0 /compiler
parent80ed61fbd64936ed676c2050e7e660b5ad78c9f2 (diff)
parentd3fee8dbf311aa916d98912261c16cad1a27b53f (diff)
downloadrust-d6b650391ac5e489ecd52a4dba35db3c1395a4e1.tar.gz
rust-d6b650391ac5e489ecd52a4dba35db3c1395a4e1.zip
Rollup merge of #100211 - cjgillot:ctfe-mir-available, r=michaelwoerister
Refuse to codegen an upstream static.

Fixes https://github.com/rust-lang/rust/issues/85401
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_monomorphize/src/collector.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs
index 68b65658c72..96bbf5802e7 100644
--- a/compiler/rustc_monomorphize/src/collector.rs
+++ b/compiler/rustc_monomorphize/src/collector.rs
@@ -1027,6 +1027,11 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) ->
         return false;
     }
 
+    if let DefKind::Static(_) = tcx.def_kind(def_id) {
+        // We cannot monomorphize statics from upstream crates.
+        return false;
+    }
+
     if !tcx.is_mir_available(def_id) {
         bug!("no MIR available for {:?}", def_id);
     }