Skip to content

Commit

Permalink
appease God Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
odesenfans committed Feb 5, 2024
1 parent 398ee66 commit 9f208d2
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions vm/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,16 @@ pub mod test_utils {
$crate::types::relocatable::MaybeRelocatable::from(($val1, $val2))
};
($val1 : expr) => {
$crate::types::relocatable::MaybeRelocatable::from(crate::Felt252::from($val1 as i128))
$crate::types::relocatable::MaybeRelocatable::from($crate::Felt252::from($val1 as i128))
};
}
pub use mayberelocatable;

#[macro_export]
macro_rules! references {
($num: expr) => {{
let mut references = crate::stdlib::collections::HashMap::<usize, HintReference>::new();
let mut references =
$crate::stdlib::collections::HashMap::<usize, HintReference>::new();
for i in 0..$num {
references.insert(i as usize, HintReference::new_simple((i as i32 - $num)));
}
Expand Down Expand Up @@ -295,27 +296,27 @@ pub mod test_utils {
//Program with builtins
( $( $builtin_name: expr ),* ) => {{
let shared_program_data = SharedProgramData {
data: crate::stdlib::vec::Vec::new(),
data: $crate::stdlib::vec::Vec::new(),
hints_collection: HintsCollection::new(&BTreeMap::new(), 0).unwrap(),
main: None,
start: None,
end: None,
error_message_attributes: crate::stdlib::vec::Vec::new(),
error_message_attributes: $crate::stdlib::vec::Vec::new(),
instruction_locations: None,
identifiers: crate::stdlib::collections::HashMap::new(),
identifiers: $crate::stdlib::collections::HashMap::new(),
reference_manager: Program::get_reference_list(&ReferenceManager {
references: crate::stdlib::vec::Vec::new(),
references: $crate::stdlib::vec::Vec::new(),
}),
};
Program {
shared_program_data: Arc::new(shared_program_data),
constants: crate::stdlib::collections::HashMap::new(),
constants: $crate::stdlib::collections::HashMap::new(),
builtins: vec![$( $builtin_name ),*],
}
}};
($($field:ident = $value:expr),* $(,)?) => {{

let program_flat = crate::utils::test_utils::ProgramFlat {
let program_flat = $crate::utils::test_utils::ProgramFlat {
$(
$field: $value,
)*
Expand Down Expand Up @@ -427,9 +428,9 @@ pub mod test_utils {
{
let ids_names = vec![$( $name ),*];
let references = references!(ids_names.len() as i32);
let mut ids_data = crate::stdlib::collections::HashMap::<crate::stdlib::string::String, HintReference>::new();
let mut ids_data = $crate::stdlib::collections::HashMap::<$crate::stdlib::string::String, HintReference>::new();
for (i, name) in ids_names.iter().enumerate() {
ids_data.insert(crate::stdlib::string::ToString::to_string(name), references.get(&i).unwrap().clone());
ids_data.insert($crate::stdlib::string::ToString::to_string(name), references.get(&i).unwrap().clone());
}
ids_data
}
Expand All @@ -441,9 +442,9 @@ pub mod test_utils {
macro_rules! non_continuous_ids_data {
( $( ($name: expr, $offset:expr) ),* $(,)? ) => {
{
let mut ids_data = crate::stdlib::collections::HashMap::<crate::stdlib::string::String, HintReference>::new();
let mut ids_data = $crate::stdlib::collections::HashMap::<$crate::stdlib::string::String, HintReference>::new();
$(
ids_data.insert(crate::stdlib::string::String::from($name), HintReference::new_simple($offset));
ids_data.insert($crate::stdlib::string::String::from($name), HintReference::new_simple($offset));
)*
ids_data
}
Expand Down Expand Up @@ -479,28 +480,28 @@ pub mod test_utils {
}};
($vm:expr, $ids_data:expr, $hint_code:expr, $exec_scopes:expr) => {{
let hint_data = HintProcessorData::new_default(
crate::stdlib::string::ToString::to_string($hint_code),
$crate::stdlib::string::ToString::to_string($hint_code),
$ids_data,
);
let mut hint_processor = BuiltinHintProcessor::new_empty();
hint_processor.execute_hint(
&mut $vm,
$exec_scopes,
&any_box!(hint_data),
&crate::stdlib::collections::HashMap::new(),
&$crate::stdlib::collections::HashMap::new(),
)
}};
($vm:expr, $ids_data:expr, $hint_code:expr) => {{
let hint_data = HintProcessorData::new_default(
crate::stdlib::string::ToString::to_string($hint_code),
$crate::stdlib::string::ToString::to_string($hint_code),
$ids_data,
);
let mut hint_processor = BuiltinHintProcessor::new_empty();
hint_processor.execute_hint(
&mut $vm,
exec_scopes_ref!(),
&any_box!(hint_data),
&crate::stdlib::collections::HashMap::new(),
&$crate::stdlib::collections::HashMap::new(),
)
}};
}
Expand Down Expand Up @@ -591,13 +592,13 @@ pub mod test_utils {
)*
let mut dict_manager = DictManager::new();
dict_manager.trackers.insert(2, tracker);
$exec_scopes.insert_value("dict_manager", crate::stdlib::rc::Rc::new(core::cell::RefCell::new(dict_manager)))
$exec_scopes.insert_value("dict_manager", $crate::stdlib::rc::Rc::new(core::cell::RefCell::new(dict_manager)))
};
($exec_scopes:expr, $tracker_num:expr) => {
let tracker = DictTracker::new_empty(relocatable!($tracker_num, 0));
let mut dict_manager = DictManager::new();
dict_manager.trackers.insert(2, tracker);
$exec_scopes.insert_value("dict_manager", crate::stdlib::rc::Rc::new(core::cell::RefCell::new(dict_manager)))
$exec_scopes.insert_value("dict_manager", $crate::stdlib::rc::Rc::new(core::cell::RefCell::new(dict_manager)))
};

}
Expand All @@ -612,13 +613,13 @@ pub mod test_utils {
)*
let mut dict_manager = DictManager::new();
dict_manager.trackers.insert(2, tracker);
$exec_scopes.insert_value("dict_manager", crate::stdlib::rc::Rc::new(core::cell::RefCell::new(dict_manager)))
$exec_scopes.insert_value("dict_manager", $crate::stdlib::rc::Rc::new(core::cell::RefCell::new(dict_manager)))
};
($exec_scopes:expr, $tracker_num:expr,$default:expr) => {
let tracker = DictTracker::new_default_dict(relocatable!($tracker_num, 0), &MaybeRelocatable::from($default), None);
let mut dict_manager = DictManager::new();
dict_manager.trackers.insert(2, tracker);
$exec_scopes.insert_value("dict_manager", crate::stdlib::rc::Rc::new(core::cell::RefCell::new(dict_manager)))
$exec_scopes.insert_value("dict_manager", $crate::stdlib::rc::Rc::new(core::cell::RefCell::new(dict_manager)))
};
}
pub use dict_manager_default;
Expand Down

0 comments on commit 9f208d2

Please sign in to comment.