diff --git a/crates/db/benches/tb_single_thread.rs b/crates/db/benches/tb_single_thread.rs index 4812152c..ffb0ec18 100644 --- a/crates/db/benches/tb_single_thread.rs +++ b/crates/db/benches/tb_single_thread.rs @@ -19,6 +19,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use moor_db::rdb::{RelBox, RelationInfo}; use moor_db::testing::jepsen::{History, Type, Value}; use moor_values::util::SliceRef; +use std::rc::Rc; use std::sync::Arc; use std::time::{Duration, Instant}; @@ -71,7 +72,7 @@ fn list_append_scan_workload(iters: u64, events: &Vec) -> Duration { match e.r#type { Type::invoke => { // Start a transaction. - let tx = Arc::new(db.clone().start_tx()); + let tx = Rc::new(db.clone().start_tx()); assert!( !processes.check(e.process as usize), "T{} already exists committed", @@ -129,7 +130,7 @@ fn list_append_seek_workload(iters: u64, events: &Vec) -> Duration { match e.r#type { Type::invoke => { // Start a transaction. - let tx = Arc::new(db.clone().start_tx()); + let tx = Rc::new(db.clone().start_tx()); assert!( !processes.check(e.process as usize), "T{} already exists committed", diff --git a/crates/db/tests/jepsen.rs b/crates/db/tests/jepsen.rs index bf227783..6595f297 100644 --- a/crates/db/tests/jepsen.rs +++ b/crates/db/tests/jepsen.rs @@ -36,6 +36,7 @@ pub mod support { #[cfg(test)] mod tests { use std::collections::{BTreeSet, HashMap}; + use std::rc::Rc; use std::sync::Arc; use tracing_test::traced_test; @@ -152,7 +153,7 @@ mod tests { match e.r#type { Type::invoke => { // Start a transaction. - let tx = Arc::new(db.clone().start_tx()); + let tx = Rc::new(db.clone().start_tx()); let existing = processes.insert(e.process, tx.clone()); assert!( existing.is_none(), diff --git a/crates/db/tests/rdb_restore.rs b/crates/db/tests/rdb_restore.rs index 58bdc038..290b2184 100644 --- a/crates/db/tests/rdb_restore.rs +++ b/crates/db/tests/rdb_restore.rs @@ -16,6 +16,7 @@ mod test { use std::collections::HashMap; use std::path::PathBuf; + use std::rc::Rc; use std::sync::Arc; use tracing_test::traced_test; @@ -36,13 +37,13 @@ mod test { fn fill_db( db: Arc, events: &Vec, - processes: &mut HashMap>, + processes: &mut HashMap>, ) { for e in events { match e.r#type { Type::invoke => { // Start a transaction. - let tx = Arc::new(db.clone().start_tx()); + let tx = Rc::new(db.clone().start_tx()); let existing = processes.insert(e.process, tx.clone()); assert!( existing.is_none(), diff --git a/crates/kernel/src/builtins/bf_verbs.rs b/crates/kernel/src/builtins/bf_verbs.rs index dd5bcd44..5cde46db 100644 --- a/crates/kernel/src/builtins/bf_verbs.rs +++ b/crates/kernel/src/builtins/bf_verbs.rs @@ -54,12 +54,7 @@ fn bf_verb_info(bf_args: &mut BfCallState<'_>) -> Result { return Err(E_TYPE); }; - if !bf_args - .world_state - .valid(*obj) - - .map_err(world_state_err)? - { + if !bf_args.world_state.valid(*obj).map_err(world_state_err)? { return Err(E_INVARG); } @@ -67,7 +62,6 @@ fn bf_verb_info(bf_args: &mut BfCallState<'_>) -> Result { Variant::Str(verb_desc) => bf_args .world_state .get_verb(bf_args.task_perms_who(), *obj, verb_desc.as_str()) - .map_err(world_state_err)?, Variant::Int(verb_index) => { let verb_index = *verb_index; @@ -78,7 +72,6 @@ fn bf_verb_info(bf_args: &mut BfCallState<'_>) -> Result { bf_args .world_state .get_verb_at_index(bf_args.task_perms_who(), *obj, verb_index) - .map_err(world_state_err)? } _ => { @@ -122,7 +115,6 @@ fn get_verbdef( bf_args .world_state .get_verb(bf_args.task_perms_who(), obj, verb_desc) - } Variant::Int(verb_index) => { let verb_index = *verb_index; @@ -133,7 +125,6 @@ fn get_verbdef( bf_args .world_state .get_verb_at_index(bf_args.task_perms_who(), obj, verb_index) - } _ => return Err(E_TYPE), }; @@ -201,12 +192,7 @@ fn bf_set_verb_info(bf_args: &mut BfCallState<'_>) -> Result { } let update_attrs = parse_verb_info(info)?; - if !bf_args - .world_state - .valid(*obj) - - .map_err(world_state_err)? - { + if !bf_args.world_state.valid(*obj).map_err(world_state_err)? { return Err(E_INVARG); } @@ -220,7 +206,6 @@ fn bf_set_verb_info(bf_args: &mut BfCallState<'_>) -> Result { verb_name.as_str(), update_attrs, ) - .map_err(world_state_err)?; } Variant::Int(verb_index) => { @@ -232,7 +217,6 @@ fn bf_set_verb_info(bf_args: &mut BfCallState<'_>) -> Result { bf_args .world_state .update_verb_at_index(bf_args.task_perms_who(), *obj, verb_index, update_attrs) - .map_err(world_state_err)?; } _ => return Err(E_TYPE), @@ -249,12 +233,7 @@ fn bf_verb_args(bf_args: &mut BfCallState<'_>) -> Result { let Variant::Obj(obj) = bf_args.args[0].variant() else { return Err(E_TYPE); }; - if !bf_args - .world_state - .valid(*obj) - - .map_err(world_state_err)? - { + if !bf_args.world_state.valid(*obj).map_err(world_state_err)? { return Err(E_INVARG); } @@ -311,12 +290,7 @@ fn bf_set_verb_args(bf_args: &mut BfCallState<'_>) -> Result { if verbinfo.len() != 3 { return Err(E_INVARG); } - if !bf_args - .world_state - .valid(*obj) - - .map_err(world_state_err)? - { + if !bf_args.world_state.valid(*obj).map_err(world_state_err)? { return Err(E_INVARG); } @@ -341,7 +315,6 @@ fn bf_set_verb_args(bf_args: &mut BfCallState<'_>) -> Result { verb_name.as_str(), update_attrs, ) - .map_err(world_state_err)?; } Variant::Int(verb_index) => { @@ -353,7 +326,6 @@ fn bf_set_verb_args(bf_args: &mut BfCallState<'_>) -> Result { bf_args .world_state .update_verb_at_index(bf_args.task_perms_who(), *obj, verb_index, update_attrs) - .map_err(world_state_err)?; } _ => return Err(E_TYPE), @@ -370,19 +342,13 @@ fn bf_verb_code(bf_args: &mut BfCallState<'_>) -> Result { let Variant::Obj(obj) = bf_args.args[0].variant() else { return Err(E_TYPE); }; - if !bf_args - .world_state - .valid(*obj) - - .map_err(world_state_err)? - { + if !bf_args.world_state.valid(*obj).map_err(world_state_err)? { return Err(E_INVARG); } // Verify caller is a programmer. if !bf_args .task_perms() - .map_err(world_state_err)? .flags .contains(ObjFlag::Programmer) @@ -408,7 +374,6 @@ fn bf_verb_code(bf_args: &mut BfCallState<'_>) -> Result { let verb_info = bf_args .world_state .retrieve_verb(bf_args.task_perms_who(), *obj, verbdef.uuid()) - .map_err(world_state_err)?; // If the binary is empty, just return empty rather than try to decode it. @@ -451,19 +416,13 @@ fn bf_set_verb_code(bf_args: &mut BfCallState<'_>) -> Result { let Variant::Obj(obj) = bf_args.args[0].variant() else { return Err(E_TYPE); }; - if !bf_args - .world_state - .valid(*obj) - - .map_err(world_state_err)? - { + if !bf_args.world_state.valid(*obj).map_err(world_state_err)? { return Err(E_INVARG); } // Verify caller is a programmer. if !bf_args .task_perms() - .map_err(world_state_err)? .flags .contains(ObjFlag::Programmer) @@ -519,7 +478,6 @@ fn bf_set_verb_code(bf_args: &mut BfCallState<'_>) -> Result { bf_args .world_state .update_verb_with_id(bf_args.task_perms_who(), *obj, verbdef.uuid(), update_attrs) - .map_err(world_state_err)?; Ok(Ret(v_none())) } @@ -539,19 +497,13 @@ fn bf_add_verb(bf_args: &mut BfCallState<'_>) -> Result { let Variant::List(args) = bf_args.args[2].variant() else { return Err(E_TYPE); }; - if !bf_args - .world_state - .valid(*obj) - - .map_err(world_state_err)? - { + if !bf_args.world_state.valid(*obj).map_err(world_state_err)? { return Err(E_INVARG); } // Verify caller is a programmer. if !bf_args .task_perms() - .map_err(world_state_err)? .flags .contains(ObjFlag::Programmer) @@ -573,7 +525,6 @@ fn bf_add_verb(bf_args: &mut BfCallState<'_>) -> Result { Vec::new(), BinaryType::LambdaMoo18X, ) - .map_err(world_state_err)?; Ok(Ret(v_none())) @@ -588,19 +539,13 @@ fn bf_delete_verb(bf_args: &mut BfCallState<'_>) -> Result { let Variant::Obj(obj) = bf_args.args[0].variant() else { return Err(E_TYPE); }; - if !bf_args - .world_state - .valid(*obj) - - .map_err(world_state_err)? - { + if !bf_args.world_state.valid(*obj).map_err(world_state_err)? { return Err(E_INVARG); } // Verify caller is a programmer. if !bf_args .task_perms() - .map_err(world_state_err)? .flags .contains(ObjFlag::Programmer) @@ -616,7 +561,6 @@ fn bf_delete_verb(bf_args: &mut BfCallState<'_>) -> Result { bf_args .world_state .remove_verb(bf_args.task_perms_who(), *obj, verbdef.uuid()) - .map_err(world_state_err)?; Ok(Ret(v_none())) @@ -635,12 +579,7 @@ fn bf_disassemble(bf_args: &mut BfCallState<'_>) -> Result { let Variant::Obj(obj) = bf_args.args[0].variant() else { return Err(E_TYPE); }; - if !bf_args - .world_state - .valid(*obj) - - .map_err(world_state_err)? - { + if !bf_args.world_state.valid(*obj).map_err(world_state_err)? { return Err(E_INVARG); } @@ -658,7 +597,6 @@ fn bf_disassemble(bf_args: &mut BfCallState<'_>) -> Result { let verb_info = bf_args .world_state .retrieve_verb(bf_args.task_perms_who(), *obj, verbdef.uuid()) - .map_err(world_state_err)?; if verb_info.binary().is_empty() { diff --git a/crates/kernel/src/vm/activation.rs b/crates/kernel/src/vm/activation.rs index 02174e65..344c11a1 100644 --- a/crates/kernel/src/vm/activation.rs +++ b/crates/kernel/src/vm/activation.rs @@ -290,7 +290,7 @@ impl Activation { frame.set_gvar(GlobalName::iobjstr, v_str("")); } - let a = Self { + Self { frame, this: verb_call_request.call.this, player: verb_call_request.call.player, @@ -302,9 +302,7 @@ impl Activation { bf_trampoline_arg: None, args: verb_call_request.call.args.clone(), permissions: verb_owner, - }; - - a + } } pub fn for_eval(permissions: Objid, player: Objid, program: Program) -> Self { @@ -346,7 +344,7 @@ impl Activation { frame.set_gvar(GlobalName::iobj, v_objid(NOTHING)); frame.set_gvar(GlobalName::iobjstr, v_str("")); - let a = Self { + Self { frame, this: player, player, @@ -358,9 +356,7 @@ impl Activation { bf_trampoline_arg: None, args: vec![], permissions, - }; - - a + } } pub fn for_bf_call( bf_index: usize, diff --git a/crates/kernel/src/vm/vm_call.rs b/crates/kernel/src/vm/vm_call.rs index 3203fb5f..797fb722 100644 --- a/crates/kernel/src/vm/vm_call.rs +++ b/crates/kernel/src/vm/vm_call.rs @@ -205,11 +205,13 @@ impl VM { pub(crate) fn exec_fork_vector(&self, vm_state: &mut VMExecState, fork_request: Fork) { // Set the activation up with the new task ID, and the new code. let mut a = fork_request.activation; - a.frame.program.main_vector = - Arc::new(a.frame.program.fork_vectors[fork_request.fork_vector_offset.0 as usize].clone()); + a.frame.program.main_vector = Arc::new( + a.frame.program.fork_vectors[fork_request.fork_vector_offset.0 as usize].clone(), + ); a.frame.pc = 0; if let Some(task_id_name) = fork_request.task_id { - a.frame.set_var_offset(&task_id_name, v_int(vm_state.task_id as i64)) + a.frame + .set_var_offset(&task_id_name, v_int(vm_state.task_id as i64)) .expect("Unable to set task_id in activation frame"); } diff --git a/crates/kernel/src/vm/vm_execute.rs b/crates/kernel/src/vm/vm_execute.rs index 61037460..8f6362de 100644 --- a/crates/kernel/src/vm/vm_execute.rs +++ b/crates/kernel/src/vm/vm_execute.rs @@ -706,7 +706,7 @@ impl VM { for _i in 0..num_excepts { f.pop(); /* code list */ - f.handler_stack.pop(); + f.handler_stack.pop(); } if is_catch { f.push(v); diff --git a/crates/kernel/src/vm/vm_unwind.rs b/crates/kernel/src/vm/vm_unwind.rs index 3433798e..b413c764 100644 --- a/crates/kernel/src/vm/vm_unwind.rs +++ b/crates/kernel/src/vm/vm_unwind.rs @@ -183,7 +183,10 @@ impl VM { pieces.push(format!(" (this == #{})", a.this.0)); } if a.frame.find_line_no(a.frame.pc).is_some() { - pieces.push(format!(" (line {})", a.frame.find_line_no(a.frame.pc).unwrap())); + pieces.push(format!( + " (line {})", + a.frame.find_line_no(a.frame.pc).unwrap() + )); } if i == 0 { pieces.push(format!(": {}", raise_msg));