about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorThe Miri Conjob Bot <miri@cron.bot>2023-12-05 05:15:52 +0000
committerThe Miri Conjob Bot <miri@cron.bot>2023-12-05 05:15:52 +0000
commitcf1ef1300e5c9dd4914682bd9c49b6c2f8181e1b (patch)
treef65e28951678b67516271734c37c0490e766c200 /compiler/rustc_codegen_llvm/src
parentd651eb9e23a3c9b67c50c847d7ac66965bda475c (diff)
parent317d14a56cb8c748bf0e2f2afff89c2249ab4423 (diff)
downloadrust-cf1ef1300e5c9dd4914682bd9c49b6c2f8181e1b.tar.gz
rust-cf1ef1300e5c9dd4914682bd9c49b6c2f8181e1b.zip
Merge from rustc
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/builder.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs
index 7b259055d40..acd85dd9a2d 100644
--- a/compiler/rustc_codegen_llvm/src/builder.rs
+++ b/compiler/rustc_codegen_llvm/src/builder.rs
@@ -489,6 +489,15 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
 
     #[instrument(level = "trace", skip(self))]
     fn load_operand(&mut self, place: PlaceRef<'tcx, &'ll Value>) -> OperandRef<'tcx, &'ll Value> {
+        if place.layout.is_unsized() {
+            let tail = self.tcx.struct_tail_with_normalize(place.layout.ty, |ty| ty, || {});
+            if matches!(tail.kind(), ty::Foreign(..)) {
+                // Unsized locals and, at least conceptually, even unsized arguments must be copied
+                // around, which requires dynamically determining their size. Therefore, we cannot
+                // allow `extern` types here. Consult t-opsem before removing this check.
+                panic!("unsized locals must not be `extern` types");
+            }
+        }
         assert_eq!(place.llextra.is_some(), place.layout.is_unsized());
 
         if place.layout.is_zst() {