Skip to content

Commit a292390

Browse files
committed
Only allow LLVM element_type on Array and Vector
1 parent 41f27d9 commit a292390

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/rustc_codegen_llvm/src/type_.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,11 @@ impl BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
203203
}
204204

205205
fn element_type(&self, ty: &'ll Type) -> &'ll Type {
206-
unsafe { llvm::LLVMGetElementType(ty) }
206+
match self.type_kind(ty) {
207+
TypeKind::Array | TypeKind::Vector => unsafe { llvm::LLVMGetElementType(ty) },
208+
TypeKind::Pointer => bug!("element_type is not supported for opaque pointers"),
209+
other => bug!("element_type called on unsupported type {:?}", other),
210+
}
207211
}
208212

209213
fn vector_length(&self, ty: &'ll Type) -> usize {

0 commit comments

Comments
 (0)