From: Skgland Date: Sat, 10 Jan 2026 16:52:34 +0000 (+0100) Subject: fix clippy lints X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=eca4262be6a9d5d2e1c836a5157c3f6343050208;p=scryer-prolog.git fix clippy lints --- diff --git a/build/instructions_template.rs b/build/instructions_template.rs index 277ce010..06f71edb 100644 --- a/build/instructions_template.rs +++ b/build/instructions_template.rs @@ -1570,12 +1570,11 @@ pub fn generate_instructions_rs() -> TokenStream { let instr_macro_arms: Vec<_> = instr_data .instr_variants .iter() - .rev() // produce default, execute & default & execute cases first. - .cloned() + .rev() .map(|(name, arity, _, variant)| { let variant_ident = variant.ident.clone(); let variant_string = variant.ident.to_string(); - let arity = match arity { + let arity = match *arity { Arity::Static(arity) => arity, _ => 1, }; diff --git a/src/codegen.rs b/src/codegen.rs index 902f5b9f..c5a0c857 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -859,7 +859,7 @@ impl CodeGenerator { let v = HeapCellValue::from(c); self.marker - .mark_non_var::(Level::Shallow, term_loc, &cell, code); + .mark_non_var::(Level::Shallow, term_loc, cell, code); code.push_back(instr!("put_constant", Level::Shallow, v, temp_v!(1))); compile_expr!(self, &terms[1], term_loc, code) diff --git a/src/ffi.rs b/src/ffi.rs index 0d3521b8..5545b397 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -975,6 +975,8 @@ pub enum FfiError { ArgCountMismatch { name: Atom, // ffi function or struct kind: ArgCountMismatchKind, + + #[allow(dead_code, reason = "will be used by PR 3173")] expected: usize, got: usize, }, diff --git a/src/machine/dispatch.rs b/src/machine/dispatch.rs index 8306c6e8..cbf7d941 100644 --- a/src/machine/dispatch.rs +++ b/src/machine/dispatch.rs @@ -847,11 +847,11 @@ impl MachineState { } #[inline(always)] - fn get_partial_string_instr(&mut self, string: &String, r: RegType) { + fn get_partial_string_instr(&mut self, string: &str, r: RegType) { self.heap[0] = self[r]; let mut h = 0; - let mut string_cursor = string.as_str(); + let mut string_cursor = string; if self.heap[0].is_stack_var() { let cell = self.store(self.deref(self.heap[0])); @@ -1548,63 +1548,63 @@ impl Machine { fn verify_attr_dispatch_loop(&mut self) -> Option { 'outer: loop { for _ in 0..INSTRUCTIONS_PER_INTERRUPT_POLL { - match &self.code[self.machine_st.p] { - &Instruction::BreakFromDispatchLoop => { + match self.code[self.machine_st.p] { + Instruction::BreakFromDispatchLoop => { break 'outer; } - &Instruction::GetLevel(r) => self.machine_st.get_level_instr(r), - &Instruction::GetPrevLevel(r) => self.machine_st.get_prev_level_instr(r), - &Instruction::GetCutPoint(r) => self.machine_st.get_cut_point_instr(r), - &Instruction::Deallocate => self.machine_st.deallocate(), - &Instruction::JmpByCall(offset) => { + Instruction::GetLevel(r) => self.machine_st.get_level_instr(r), + Instruction::GetPrevLevel(r) => self.machine_st.get_prev_level_instr(r), + Instruction::GetCutPoint(r) => self.machine_st.get_cut_point_instr(r), + Instruction::Deallocate => self.machine_st.deallocate(), + Instruction::JmpByCall(offset) => { self.machine_st.p += offset; } - &Instruction::RevJmpBy(offset) => { + Instruction::RevJmpBy(offset) => { self.machine_st.p -= offset; } - &Instruction::GetConstant(_, c, reg) => { + Instruction::GetConstant(_, c, reg) => { self.machine_st.get_constant_instr(c, reg) } - &Instruction::GetList(_, reg) => self.machine_st.get_list_instr(reg), - &Instruction::GetPartialString(_, ref string, reg) => { + Instruction::GetList(_, reg) => self.machine_st.get_list_instr(reg), + Instruction::GetPartialString(_, ref string, reg) => { self.machine_st.get_partial_string_instr(string, reg) } - &Instruction::GetStructure(_lvl, name, arity, reg) => { + Instruction::GetStructure(_lvl, name, arity, reg) => { self.machine_st.get_structure_instr(name, arity, reg) } - &Instruction::GetVariable(norm, arg) => { + Instruction::GetVariable(norm, arg) => { self.machine_st.get_variable_instr(norm, arg) } - &Instruction::GetValue(norm, arg) => self.machine_st.get_value_instr(norm, arg), - &Instruction::UnifyConstant(v) => self.machine_st.unify_constant_instr(v), - &Instruction::UnifyLocalValue(reg) => { + Instruction::GetValue(norm, arg) => self.machine_st.get_value_instr(norm, arg), + Instruction::UnifyConstant(v) => self.machine_st.unify_constant_instr(v), + Instruction::UnifyLocalValue(reg) => { self.machine_st.unify_local_value_instr(reg) } - &Instruction::UnifyVariable(reg) => self.machine_st.unify_variable_instr(reg), - &Instruction::UnifyValue(reg) => self.machine_st.unify_value_instr(reg), - &Instruction::UnifyVoid(n) => self.machine_st.unify_void_instr(n), - &Instruction::PutConstant(_, cell, reg) => { + Instruction::UnifyVariable(reg) => self.machine_st.unify_variable_instr(reg), + Instruction::UnifyValue(reg) => self.machine_st.unify_value_instr(reg), + Instruction::UnifyVoid(n) => self.machine_st.unify_void_instr(n), + Instruction::PutConstant(_, cell, reg) => { self.machine_st.put_constant_instr(cell, reg) } - &Instruction::PutList(_, reg) => self.machine_st.put_list_instr(reg), - &Instruction::PutPartialString(_, ref string, reg) => { + Instruction::PutList(_, reg) => self.machine_st.put_list_instr(reg), + Instruction::PutPartialString(_, ref string, reg) => { self.machine_st.put_partial_string_instr(string, reg) } - &Instruction::PutStructure(name, arity, reg) => { + Instruction::PutStructure(name, arity, reg) => { self.machine_st.put_structure_instr(name, arity, reg) } - &Instruction::PutUnsafeValue(perm_slot, arg) => { + Instruction::PutUnsafeValue(perm_slot, arg) => { self.machine_st.put_unsafe_value_instr(perm_slot, arg) } - &Instruction::PutValue(norm, arg) => self.machine_st.put_value_instr(norm, arg), - &Instruction::PutVariable(norm, arg) => { + Instruction::PutValue(norm, arg) => self.machine_st.put_value_instr(norm, arg), + Instruction::PutVariable(norm, arg) => { self.machine_st.put_variable_instr(norm, arg) } - &Instruction::SetConstant(c) => self.machine_st.set_constant_instr(c), - &Instruction::SetLocalValue(reg) => self.machine_st.set_local_value_instr(reg), - &Instruction::SetVariable(reg) => self.machine_st.set_variable_instr(reg), - &Instruction::SetValue(reg) => self.machine_st.set_value_instr(reg), - &Instruction::SetVoid(n) => self.machine_st.set_void_instr(n), + Instruction::SetConstant(c) => self.machine_st.set_constant_instr(c), + Instruction::SetLocalValue(reg) => self.machine_st.set_local_value_instr(reg), + Instruction::SetVariable(reg) => self.machine_st.set_variable_instr(reg), + Instruction::SetValue(reg) => self.machine_st.set_value_instr(reg), + Instruction::SetVoid(n) => self.machine_st.set_void_instr(n), _ => return None, } } diff --git a/src/offset_table.rs b/src/offset_table.rs index ec3f6031..c6fee00d 100644 --- a/src/offset_table.rs +++ b/src/offset_table.rs @@ -238,6 +238,7 @@ impl SerialOffsetTable { &mut *self.block.base.add(offset).cast::().cast_mut() } + #[allow(clippy::wrong_self_convention)] fn to_concurrent(&mut self) -> ConcurrentOffsetTable where T: fmt::Debug, diff --git a/src/parser/ast.rs b/src/parser/ast.rs index 3728da75..9fc54c70 100644 --- a/src/parser/ast.rs +++ b/src/parser/ast.rs @@ -250,6 +250,7 @@ pub enum GInteger { impl GInteger { #[inline] + #[allow(clippy::wrong_self_convention)] pub fn to_literal(self) -> Literal { match self { GInteger::Integer(integer) => Literal::Integer(integer),