Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libfuncs/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ pub fn build_get<'ctx, 'this>(
// Drop the input array.
metadata
.get::<DropOverridesMeta>()
.unwrap()
.to_native_assert_error("drop overrides metadata should be available")?
.invoke_override(
context,
valid_block,
Expand Down
8 changes: 4 additions & 4 deletions src/libfuncs/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use super::LibfuncHelper;
use crate::{
error::Result,
error::{panic::ToNativeAssertError, Result},
metadata::MetadataStorage,
types::TypeBuilder,
utils::{BlockExt, ProgramRegistryExt},
Expand Down Expand Up @@ -94,7 +94,7 @@ fn build_bool_binary<'ctx, 'this>(
let enum_ty = registry.get_type(&info.param_signatures()[0].ty)?;
let tag_bits = enum_ty
.variants()
.expect("bool is a enum and has variants")
.to_native_assert_error("bool is a enum and has variants")?
.len()
.next_power_of_two()
.trailing_zeros();
Expand Down Expand Up @@ -143,7 +143,7 @@ pub fn build_bool_not<'ctx, 'this>(
let enum_ty = registry.get_type(&info.param_signatures()[0].ty)?;
let tag_bits = enum_ty
.variants()
.expect("bool is a enum and has variants")
.to_native_assert_error("bool is a enum and has variants")?
.len()
.next_power_of_two()
.trailing_zeros();
Expand Down Expand Up @@ -192,7 +192,7 @@ pub fn build_bool_to_felt252<'ctx, 'this>(

let tag_bits = enum_ty
.variants()
.expect("bool is a enum and has variants")
.to_native_assert_error("bool is a enum and has variants")?
.len()
.next_power_of_two()
.trailing_zeros();
Expand Down
4 changes: 2 additions & 2 deletions src/libfuncs/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use super::LibfuncHelper;
use crate::{
error::{Error, Result},
error::{panic::ToNativeAssertError, Error, Result},
metadata::{
drop_overrides::DropOverridesMeta, runtime_bindings::RuntimeBindingsMeta, MetadataStorage,
},
Expand Down Expand Up @@ -82,7 +82,7 @@ pub fn build_print<'ctx>(

let runtime_bindings = metadata
.get_mut::<RuntimeBindingsMeta>()
.expect("Runtime library not available.");
.to_native_assert_error("runtime library should be available")?;

let values_len = entry.append_op_result(arith::subi(values_end, values_start, location))?;

Expand Down
10 changes: 2 additions & 8 deletions src/libfuncs/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,7 @@ pub fn build_enum_value<'ctx, 'this>(
let tag_val = entry
.append_operation(arith::constant(
context,
IntegerAttribute::new(
tag_ty,
variant_index
.try_into()
.expect("couldnt convert index to i64"),
)
.into(),
IntegerAttribute::new(tag_ty, variant_index.try_into()?).into(),
location,
))
.result(0)?
Expand Down Expand Up @@ -425,7 +419,7 @@ pub fn build_snapshot_match<'ctx, 'this>(
.get::<EnumSnapshotVariantsMeta>()
.ok_or(Error::MissingMetadata)?
.get_variants(&info.param_signatures()[0].ty)
.expect("enum should always have variants")
.to_native_assert_error("enum should always have variants")?
.clone();
match variant_ids.len() {
0 => {
Expand Down
6 changes: 3 additions & 3 deletions src/libfuncs/felt252_dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use super::LibfuncHelper;
use crate::{
error::Result,
error::{panic::ToNativeAssertError, Result},
metadata::{
felt252_dict::Felt252DictOverrides, runtime_bindings::RuntimeBindingsMeta, MetadataStorage,
},
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn build_new<'ctx, 'this>(

let runtime_bindings = metadata
.get_mut::<RuntimeBindingsMeta>()
.expect("Runtime library not available.");
.to_native_assert_error("runtime library should be available")?;
let dict_ptr = runtime_bindings.dict_new(
context,
helper,
Expand Down Expand Up @@ -143,7 +143,7 @@ pub fn build_squash<'ctx, 'this>(

let runtime_bindings = metadata
.get_mut::<RuntimeBindingsMeta>()
.expect("Runtime library not available.");
.to_native_assert_error("runtime library should be available")?;

let gas_refund = runtime_bindings
.dict_gas_refund(context, helper, entry, dict_ptr, location)?
Expand Down
8 changes: 4 additions & 4 deletions src/libfuncs/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use super::LibfuncHelper;
use crate::{
error::{Error, Result},
error::{panic::ToNativeAssertError, Error, Result},
metadata::{gas::GasCost, runtime_bindings::RuntimeBindingsMeta, MetadataStorage},
native_panic,
utils::{BlockExt, GepIndex},
Expand Down Expand Up @@ -91,7 +91,7 @@ pub fn build_withdraw_gas<'ctx, 'this>(

let gas_cost = metadata
.get::<GasCost>()
.expect("withdraw_gas should always have a gas cost")
.to_native_assert_error("withdraw_gas should always have a gas cost")?
.clone();

let u64_type: melior::ir::Type = IntegerType::new(context, 64).into();
Expand Down Expand Up @@ -172,7 +172,7 @@ pub fn build_redeposit_gas<'ctx, 'this>(

let gas_cost = metadata
.get::<GasCost>()
.expect("redeposit_gas should always have a gas cost")
.to_native_assert_error("redeposit_gas should always have a gas cost")?
.clone();

let u64_type: melior::ir::Type = IntegerType::new(context, 64).into();
Expand Down Expand Up @@ -247,7 +247,7 @@ pub fn build_builtin_withdraw_gas<'ctx, 'this>(

let gas_cost = metadata
.get::<GasCost>()
.expect("builtin_withdraw_gas should always have a gas cost")
.to_native_assert_error("builtin_withdraw_gas should always have a gas cost")?
.clone();

let u64_type: melior::ir::Type = IntegerType::new(context, 64).into();
Expand Down
3 changes: 1 addition & 2 deletions src/libfuncs/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,7 @@ fn build_wide_mul<'ctx, 'this>(

let ext_fn = if registry
.get_type(&info.signature.param_signatures[0].ty)?
.integer_range(registry)
.unwrap()
.integer_range(registry)?
.lower
.is_zero()
{
Expand Down
6 changes: 3 additions & 3 deletions src/libfuncs/pedersen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use super::LibfuncHelper;
use crate::{
error::Result,
error::{panic::ToNativeAssertError, Result},
metadata::{runtime_bindings::RuntimeBindingsMeta, MetadataStorage},
utils::{get_integer_layout, BlockExt, ProgramRegistryExt},
};
Expand Down Expand Up @@ -49,7 +49,7 @@ pub fn build_pedersen<'ctx>(
) -> Result<()> {
metadata
.get_mut::<RuntimeBindingsMeta>()
.expect("Runtime library not available.");
.to_native_assert_error("runtime library should be available")?;

let pedersen_builtin =
super::increment_builtin_counter(context, entry, location, entry.arg(0)?)?;
Expand Down Expand Up @@ -83,7 +83,7 @@ pub fn build_pedersen<'ctx>(

let runtime_bindings = metadata
.get_mut::<RuntimeBindingsMeta>()
.expect("Runtime library not available.");
.to_native_assert_error("runtime library should be available")?;

runtime_bindings
.libfunc_pedersen(context, helper, entry, dst_ptr, lhs_ptr, rhs_ptr, location)?;
Expand Down
6 changes: 3 additions & 3 deletions src/libfuncs/poseidon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use super::LibfuncHelper;
use crate::{
error::Result,
error::{panic::ToNativeAssertError, Result},
metadata::{runtime_bindings::RuntimeBindingsMeta, MetadataStorage},
utils::{get_integer_layout, BlockExt, ProgramRegistryExt},
};
Expand Down Expand Up @@ -50,7 +50,7 @@ pub fn build_hades_permutation<'ctx>(
) -> Result<()> {
metadata
.get_mut::<RuntimeBindingsMeta>()
.expect("Runtime library not available.");
.to_native_assert_error("runtime library should be available")?;

let poseidon_builtin =
super::increment_builtin_counter(context, entry, location, entry.arg(0)?)?;
Expand Down Expand Up @@ -91,7 +91,7 @@ pub fn build_hades_permutation<'ctx>(

let runtime_bindings = metadata
.get_mut::<RuntimeBindingsMeta>()
.expect("Runtime library not available.");
.to_native_assert_error("runtime library should be available")?;

runtime_bindings
.libfunc_hades_permutation(context, helper, entry, op0_ptr, op1_ptr, op2_ptr, location)?;
Expand Down
4 changes: 3 additions & 1 deletion src/libfuncs/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ pub fn build<'ctx, 'this>(
}
#[cfg(not(feature = "with-cheatcode"))]
StarkNetConcreteLibfunc::Testing(TestingConcreteLibfunc::Cheatcode(_)) => {
unimplemented!("feature 'with-cheatcode' is required to compile with cheatcode syscall")
crate::native_panic!(
"feature 'with-cheatcode' is required to compile with cheatcode syscall"
)
}
}
}
Expand Down
Loading