diff options
| author | Ralf Jung <post@ralfj.de> | 2023-12-02 22:25:14 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-12-03 08:11:15 +0100 |
| commit | 5a20bac6b3ff61acc3cd68bed0eb3fa598181f17 (patch) | |
| tree | d2fd3b80c9651b0630d3e6aee00c3d6cdacd2ffb /compiler/rustc_codegen_llvm/src/builder.rs | |
| parent | 0908f173fd884ae90584e0b0bca83cb270c23936 (diff) | |
| download | rust-5a20bac6b3ff61acc3cd68bed0eb3fa598181f17.tar.gz rust-5a20bac6b3ff61acc3cd68bed0eb3fa598181f17.zip | |
more targeted errors when extern types end up in places they should not
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/builder.rs | 9 |
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() { |
