diff options
| author | Josh Stone <jistone@redhat.com> | 2021-08-05 11:06:32 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2021-08-05 11:06:32 -0700 |
| commit | a29239085455964176ab0ad59b097da725813f6f (patch) | |
| tree | 2108e3c4118e4eccbeeceb57ca9ce303a6e1bc2f /compiler/rustc_codegen_llvm/src | |
| parent | 41f27d903a2f6e81fbd082235fbdaacc0d356d1e (diff) | |
| download | rust-a29239085455964176ab0ad59b097da725813f6f.tar.gz rust-a29239085455964176ab0ad59b097da725813f6f.zip | |
Only allow LLVM element_type on Array and Vector
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/type_.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/type_.rs b/compiler/rustc_codegen_llvm/src/type_.rs index 69787df5e07..52ae56b89b3 100644 --- a/compiler/rustc_codegen_llvm/src/type_.rs +++ b/compiler/rustc_codegen_llvm/src/type_.rs @@ -203,7 +203,11 @@ impl BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> { } fn element_type(&self, ty: &'ll Type) -> &'ll Type { - unsafe { llvm::LLVMGetElementType(ty) } + match self.type_kind(ty) { + TypeKind::Array | TypeKind::Vector => unsafe { llvm::LLVMGetElementType(ty) }, + TypeKind::Pointer => bug!("element_type is not supported for opaque pointers"), + other => bug!("element_type called on unsupported type {:?}", other), + } } fn vector_length(&self, ty: &'ll Type) -> usize { |
