diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 61002848..432b358b 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -2244,7 +2244,7 @@ fn gen_ndarray_subscript_expr<'ctx, G: CodeGenerator>( ctx, sizet_model.constant(tyctx, ctx.ctx, dst_ndims as u64), "subndarray", - )?; + ); // Prepare the subscripts let (num_ndindexes, ndindexes) = RustNDIndex::alloca_ndindexes(tyctx, ctx, &rust_ndindexes); diff --git a/nac3core/src/codegen/numpy_new/factory.rs b/nac3core/src/codegen/numpy_new/factory.rs index 2c52d9a7..26ded7da 100644 --- a/nac3core/src/codegen/numpy_new/factory.rs +++ b/nac3core/src/codegen/numpy_new/factory.rs @@ -43,7 +43,7 @@ where let shape_writer = make_shape_writer(generator, ctx, shape, shape_ty); let ndims = shape_writer.len; - let ndarray = alloca_ndarray(generator, ctx, ndims, name)?; + let ndarray = alloca_ndarray(generator, ctx, ndims, name); init_ndarray_shape(generator, ctx, ndarray, &shape_writer)?; let itemsize = ctx.get_llvm_type(generator, elem_ty).size_of().unwrap(); diff --git a/nac3core/src/codegen/numpy_new/util.rs b/nac3core/src/codegen/numpy_new/util.rs index a9cf7c73..3b5f3b31 100644 --- a/nac3core/src/codegen/numpy_new/util.rs +++ b/nac3core/src/codegen/numpy_new/util.rs @@ -34,7 +34,7 @@ pub fn alloca_ndarray<'ctx, G>( ctx: &mut CodeGenContext<'ctx, '_>, ndims: Int<'ctx, SizeT>, name: &str, -) -> Result>, String> +) -> Ptr<'ctx, StructModel> where G: CodeGenerator + ?Sized, { @@ -54,7 +54,7 @@ where ndarray_ptr.gep(ctx, |f| f.shape).store(ctx, shape); ndarray_ptr.gep(ctx, |f| f.strides).store(ctx, strides); - Ok(ndarray_ptr) + ndarray_ptr } /// Initialize an ndarray's `shape` and asserts on. @@ -107,7 +107,7 @@ pub fn as_ndarray<'ctx, G: CodeGenerator + ?Sized>( ctx: &mut CodeGenContext<'ctx, '_>, input: BasicValueEnum<'ctx>, input_ty: Type, -) -> Result<(Ptr<'ctx, StructModel>, Type), String> { +) -> (Ptr<'ctx, StructModel>, Type) { let tyctx = generator.type_context(ctx.ctx); let sizet_model = IntModel(SizeT); let pbyte_model = PtrModel(IntModel(Byte)); @@ -120,11 +120,11 @@ pub fn as_ndarray<'ctx, G: CodeGenerator + ?Sized>( { let pndarray = pndarray_model.check_value(tyctx, ctx.ctx, input).unwrap(); let (elem_ty, _) = unpack_ndarray_var_tys(&mut ctx.unifier, input_ty); - Ok((pndarray, elem_ty)) + (pndarray, elem_ty) } _ => { let ndims = sizet_model.const_0(tyctx, ctx.ctx); - let pndarray = alloca_ndarray(generator, ctx, ndims, "ndarray")?; + let pndarray = alloca_ndarray(generator, ctx, ndims, "ndarray"); // We have to put `input` onto the stack to get a data pointer. let data = ctx.builder.build_alloca(input.get_type(), "as_ndarray_scalar").unwrap(); @@ -137,7 +137,7 @@ pub fn as_ndarray<'ctx, G: CodeGenerator + ?Sized>( let itemsize = sizet_model.check_value(tyctx, ctx.ctx, itemsize).unwrap(); pndarray.gep(ctx, |f| f.itemsize).store(ctx, itemsize); - Ok((pndarray, input_ty)) + (pndarray, input_ty) } } } diff --git a/nac3core/src/codegen/numpy_new/view.rs b/nac3core/src/codegen/numpy_new/view.rs index 368adbfd..d897e636 100644 --- a/nac3core/src/codegen/numpy_new/view.rs +++ b/nac3core/src/codegen/numpy_new/view.rs @@ -37,7 +37,7 @@ fn gen_reshape_ndarray_or_copy<'ctx, G: CodeGenerator + ?Sized>( let end_bb = ctx.ctx.insert_basic_block_after(else_bb, "end_bb"); // Inserting into current_bb - let dst_ndarray = alloca_ndarray(generator, ctx, new_shape.len, "ndarray").unwrap(); + let dst_ndarray = alloca_ndarray(generator, ctx, new_shape.len, "ndarray"); // Set shape - directly from user input init_ndarray_shape(generator, ctx, dst_ndarray, new_shape)?;