Skip to content

Commit

Permalink
Add another checked cast
Browse files Browse the repository at this point in the history
  • Loading branch information
erer1243 committed Mar 9, 2024
1 parent 677b430 commit 44dde15
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_llvm/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ impl<'ll> BackendTypes for CodegenCx<'ll, '_> {

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

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

0 comments on commit 44dde15

Please sign in to comment.