Skip to content

Commit 44dde15

Browse files
committed
Add another checked cast
1 parent 677b430 commit 44dde15

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/rustc_codegen_llvm/src/common.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ impl<'ll> BackendTypes for CodegenCx<'ll, '_> {
9595

9696
impl<'ll> CodegenCx<'ll, '_> {
9797
pub fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
98-
unsafe { llvm::LLVMConstArray2(ty, elts.as_ptr(), elts.len()) }
98+
let len = u64::try_from(elts.len()).expect("LLVMConstArray2 elements len overflow");
99+
unsafe { llvm::LLVMConstArray2(ty, elts.as_ptr(), len) }
99100
}
100101

101102
pub fn const_vector(&self, elts: &[&'ll Value]) -> &'ll Value {

0 commit comments

Comments
 (0)