Merge pull request #3019 from Skgland/rebis-dev_fix-clippy

fix clippy
This commit is contained in:
Mark Thom
2025-07-31 22:09:41 -07:00
committed by GitHub
26 changed files with 111 additions and 135 deletions

View File

@@ -2,7 +2,9 @@ name: CI
on:
push:
branches: [master]
branches:
- master
- rebis-dev
tags:
- "v**"
pull_request:
@@ -47,7 +49,6 @@ jobs:
- { os: ubuntu-22.04, rust-version: nightly, target: 'wasm32-unknown-unknown', publish: true, args: '--no-default-features' , test-args: '--no-run --no-default-features', use_swap: true }
# Cargo.toml rust-version
- { os: ubuntu-22.04, rust-version: "1.85", target: 'x86_64-unknown-linux-gnu'}
# rust versions
- { os: ubuntu-22.04, rust-version: beta, target: 'x86_64-unknown-linux-gnu'}
- { os: ubuntu-22.04, rust-version: nightly, target: 'x86_64-unknown-linux-gnu', miri: true, components: "miri"}
defaults:

View File

@@ -1055,7 +1055,7 @@ fn generate_instruction_preface() -> TokenStream {
constants.iter().map(|(c, ptr)| {
functor!(
atom!(":"),
[cell((c.clone())), indexing_code_ptr((*ptr))]
[cell((*c)), indexing_code_ptr((*ptr))]
)
}),
)
@@ -3262,14 +3262,14 @@ where
let disc = match DiscriminantT::from_str(id.to_string().as_str()) {
Ok(disc) => disc,
Err(_) => {
panic!("can't generate discriminant {}", id);
panic!("can't generate discriminant {id}");
}
};
match disc.get_str(key) {
Some(prop) => prop,
None => {
panic!("can't find property {} of discriminant {:?}", key, disc);
panic!("can't find property {key} of discriminant {disc:?}");
}
}
}
@@ -3387,7 +3387,7 @@ impl InstructionData {
(name, arity, CountableInference::HasDefault)
} else {
panic!("type ID is: {}", id);
panic!("type ID is: {id}");
};
let v_ident = variant

View File

@@ -126,14 +126,14 @@ pub fn index_static_strings(instruction_rs_path: &std::path::Path) -> TokenStrea
match file.read_to_string(&mut src) {
Ok(_) => {}
Err(e) => {
panic!("error reading file: {:?}", e);
panic!("error reading file: {e:?}");
}
}
let syntax = match syn::parse_file(&src) {
Ok(s) => s,
Err(e) => {
panic!("parse error: {} in file {:?}", e, path);
panic!("parse error: {e} in file {path:?}");
}
};
Ok(syntax)

View File

@@ -254,7 +254,7 @@ impl std::ops::Deref for AtomString<'_> {
fn deref(&self) -> &Self::Target {
match self {
Self::Static(reference) => reference,
Self::Inlined(inlined) => inlined_to_str(&inlined),
Self::Inlined(inlined) => inlined_to_str(inlined),
Self::Dynamic(guard) => guard.deref(),
}
}

View File

@@ -251,7 +251,7 @@ impl DebrayAllocator {
}
}
if self.branch_stack.len() > 0 {
if !self.branch_stack.is_empty() {
for var_num in subsumed_hits {
self.branch_stack.add_branch_occurrence(var_num);
}

View File

@@ -324,7 +324,7 @@ impl ForeignFunctionTable {
let mut pointer_args =
Self::build_pointer_args(&mut args, &function_impl.args, &mut self.structs)?;
return unsafe {
unsafe {
macro_rules! call_and_return {
($type:ty) => {{
let mut n: Box<u8> = Box::new(0);
@@ -410,7 +410,7 @@ impl ForeignFunctionTable {
}
_ => unreachable!(),
}
};
}
}
fn read_struct(

View File

@@ -372,11 +372,11 @@ pub enum ModuleSource {
impl ModuleSource {
pub(crate) fn as_functor_stub(&self) -> MachineStub {
match self {
&ModuleSource::Library(name) => {
match *self {
ModuleSource::Library(name) => {
functor!(atom!("library"), [atom_as_cell(name)])
}
&ModuleSource::File(name) => {
ModuleSource::File(name) => {
functor!(name)
}
}
@@ -627,9 +627,9 @@ impl Default for Number {
impl fmt::Display for Number {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Number::Float(fl) => write!(f, "{}", fl),
Number::Integer(n) => write!(f, "{}", n),
Number::Rational(r) => write!(f, "{}", r),
Number::Float(fl) => write!(f, "{fl}"),
Number::Integer(n) => write!(f, "{n}"),
Number::Rational(r) => write!(f, "{r}"),
Number::Fixnum(n) => write!(f, "{}", n.get_num()),
}
}

View File

@@ -698,9 +698,9 @@ mod tests {
let functor = variadic_functor(
atom!("switch_on_constants"),
1,
constants.iter().map(|(c, ptr)| {
functor!(atom!(":"), [cell((c.clone())), indexing_code_ptr((*ptr))])
}),
constants
.iter()
.map(|(c, ptr)| functor!(atom!(":"), [cell((*c)), indexing_code_ptr((*ptr))])),
);
heap.truncate(0);
@@ -739,12 +739,12 @@ mod tests {
]
);
println!("{:?}", stub);
println!("{stub:?}");
// now the error form
let lineless_error_form = functor!(atom!("error"), [functor(stub), functor(culprit)]);
println!("{:?}", lineless_error_form);
println!("{lineless_error_form:?}");
let mut heap = Heap::new();
let mut functor_writer = Heap::functor_writer(lineless_error_form);

View File

@@ -831,13 +831,13 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
read_heap_cell!(cell,
(HeapCellValueTag::Lis | HeapCellValueTag::Str, h) => {
Some(format!("{}", h))
Some(format!("{h}"))
}
(HeapCellValueTag::Var | HeapCellValueTag::AttrVar, h) => {
Some(format!("_{}", h))
Some(format!("_{h}"))
}
(HeapCellValueTag::StackVar, h) => {
Some(format!("_s_{}", h))
Some(format!("_s_{h}"))
}
_ => {
None
@@ -1002,7 +1002,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
#[inline]
fn print_ip_addr(&mut self, ip: IpAddr) {
push_char!(self, '\'');
append_str!(self, &format!("{}", ip));
append_str!(self, &format!("{ip}"));
push_char!(self, '\'');
}
@@ -1039,7 +1039,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
self.print_rational(max_depth, r, *op);
}
n => {
let output_str = format!("{}", n);
let output_str = format!("{n}");
push_space_if_amb!(self, &output_str, {
append_str!(self, &output_str);
@@ -1086,7 +1086,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
match self.op_dir.get(&(atom!("rdiv"), Fixity::In)) {
Some(op_desc) => {
if r.is_int() {
let output_str = format!("{}", r);
let output_str = format!("{r}");
push_space_if_amb!(self, &output_str, {
append_str!(self, &output_str);

View File

@@ -403,7 +403,7 @@ impl<'a> Iterator for ClauseIterator<'a> {
self.state_stack
.push(ClauseIteratorState::RemainingBranches(branches, 0));
}
&ChunkedTerms::Chunk { ref terms } => {
ChunkedTerms::Chunk { ref terms } => {
return Some(ClauseItem::Chunk { terms });
}
}

View File

@@ -133,7 +133,7 @@ fn merge_indices(
);
retraction_info.push_record(RetractionRecord::AddedIndex(
skeleton[clause_index].opt_arg_index_key.clone(),
skeleton[clause_index].opt_arg_index_key,
clause_loc,
));
} else {
@@ -246,7 +246,7 @@ fn remove_index_from_subsequence(
// appear anywhere inside an Internal record.
retraction_info.push_record(RetractionRecord::RemovedIndex(
index_loc,
opt_arg_index_key.clone(),
*opt_arg_index_key,
offset,
));
}
@@ -808,7 +808,7 @@ fn prepend_compiled_clause(
skeleton.clauses[0].clause_start = clause_loc + 2;
retraction_info.push_record(RetractionRecord::AddedIndex(
skeleton.clauses[0].opt_arg_index_key.clone(),
skeleton.clauses[0].opt_arg_index_key,
skeleton.clauses[0].clause_start,
));
@@ -1070,7 +1070,7 @@ fn append_compiled_clause(
skeleton.clauses[target_pos].opt_arg_index_key += index_loc - 1;
retraction_info.push_record(RetractionRecord::AddedIndex(
skeleton.clauses[target_pos].opt_arg_index_key.clone(),
skeleton.clauses[target_pos].opt_arg_index_key,
skeleton.clauses[target_pos].clause_start,
));

View File

@@ -137,10 +137,7 @@ impl<'a, const STOP_AT_CYCLES: bool> CycleDetectingIter<'a, STOP_AT_CYCLES> {
let cell = self.heap[h];
let arity = cell_as_atom_cell!(self.heap[h]).get_arity();
let last_cell_loc = match self.traverse_subterm(h + 1, arity) {
Some(last_cell_loc) => last_cell_loc,
None => return None,
};
let last_cell_loc = self.traverse_subterm(h + 1, arity)?;
if last_cell_loc == h {
if self.backward() {
@@ -171,10 +168,7 @@ impl<'a, const STOP_AT_CYCLES: bool> CycleDetectingIter<'a, STOP_AT_CYCLES> {
let mut cell = self.heap[self.current];
cell.set_value(self.next);
let last_cell_loc = match self.traverse_subterm(self.next as usize, 2) {
Some(last_cell_loc) => last_cell_loc,
None => return None,
};
let last_cell_loc = self.traverse_subterm(self.next as usize, 2)?;
if self.cycle_detection_active() {
for idx in (self.next as usize..last_cell_loc).rev() {

View File

@@ -3277,7 +3277,7 @@ impl Machine {
&Instruction::PutPartialString(_, ref string, reg) => {
self.machine_st[reg] = backtrack_on_resource_error!(
self.machine_st,
self.machine_st.heap.allocate_pstr(&string)
self.machine_st.heap.allocate_pstr(string)
);
self.machine_st.p += 1;

View File

@@ -612,7 +612,6 @@ impl Heap {
}
}
#[must_use]
pub fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter, usize> {
let section;
let len = heap_index!(num_cells);
@@ -745,10 +744,8 @@ impl Heap {
// the heap to a pre-allocated resource error
pub(crate) fn push_cell(&mut self, cell: HeapCellValue) -> Result<(), usize> {
unsafe {
if self.inner.byte_len == self.inner.byte_cap {
if !self.grow() {
return Err(self.resource_error_offset());
}
if self.inner.byte_len == self.inner.byte_cap && !self.grow() {
return Err(self.resource_error_offset());
}
// SAFETY:
@@ -1009,7 +1006,7 @@ impl<'a> PStrSegmentIter<'a> {
let string_buf = unsafe {
let char_ptr = heap.inner.ptr.add(pstr_loc);
let slice = std::slice::from_raw_parts(char_ptr, heap.inner.byte_len - pstr_loc);
std::str::from_utf8_unchecked(&slice)
std::str::from_utf8_unchecked(slice)
};
PStrSegmentIter { string_buf }

View File

@@ -546,27 +546,21 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
for export in removed_module.module_decl.exports.iter() {
match export {
ModuleExport::PredicateKey(ref key) => {
match (
if let (Some(module_code_idx), Some(target_code_idx)) = (
removed_module.code_dir.get(key).cloned(),
code_dir.get_mut(key).cloned(),
) {
(Some(module_code_idx), Some(target_code_idx)) => {
let code_index_tbl =
&mut LS::machine_st(payload).arena.code_index_tbl;
let module_code_ptr =
code_index_tbl.get_entry(module_code_idx.into());
let target_code_ptr =
code_index_tbl.get_entry(target_code_idx.into());
let code_index_tbl = &mut LS::machine_st(payload).arena.code_index_tbl;
let module_code_ptr = code_index_tbl.get_entry(module_code_idx.into());
let target_code_ptr = code_index_tbl.get_entry(target_code_idx.into());
if module_code_ptr == target_code_ptr {
let old_index_ptr = target_code_idx
.replace(code_index_tbl, IndexPtr::undefined());
payload
.retraction_info
.push_record(predicate_retractor(*key, old_index_ptr));
}
if module_code_ptr == target_code_ptr {
let old_index_ptr =
target_code_idx.replace(code_index_tbl, IndexPtr::undefined());
payload
.retraction_info
.push_record(predicate_retractor(*key, old_index_ptr));
}
_ => {}
}
}
ModuleExport::OpDecl(op_decl) => {
@@ -688,12 +682,12 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
let code_index_tbl = &mut LS::machine_st(&mut self.payload).arena.code_index_tbl;
if module_name == atom!("user") {
return *self
*self
.wam_prelude
.indices
.code_dir
.entry(key)
.or_insert_with(|| CodeIndex::new(IndexPtr::undefined(), code_index_tbl));
.or_insert_with(|| CodeIndex::new(IndexPtr::undefined(), code_index_tbl))
} else {
self.get_or_insert_local_code_index(module_name, key)
}

View File

@@ -1407,10 +1407,10 @@ impl MachineState {
term_stack.push(Term::Literal(Cell::default(), Literal::try_from(addr).unwrap()));
}
(HeapCellValueTag::StackVar, h) => {
term_stack.push(Term::Var(Cell::default(), VarPtr::from(format!("s_{}", h))));
term_stack.push(Term::Var(Cell::default(), VarPtr::from(format!("s_{h}"))));
}
(HeapCellValueTag::Var | HeapCellValueTag::AttrVar, h) => {
term_stack.push(Term::Var(Cell::default(), VarPtr::from(format!("_{}", h))));
term_stack.push(Term::Var(Cell::default(), VarPtr::from(format!("_{h}"))));
}
(HeapCellValueTag::Atom, (name, arity)) => {
let h = iter.focus().value() as usize;

View File

@@ -159,17 +159,17 @@ impl From<CodeIndexOffset> for CodeIndex {
}
}
impl Into<CodeIndexOffset> for CodeIndex {
impl From<CodeIndex> for CodeIndexOffset {
#[inline(always)]
fn into(self) -> CodeIndexOffset {
self.0
fn from(value: CodeIndex) -> CodeIndexOffset {
value.0
}
}
impl Into<CodeIndexOffset> for &'_ CodeIndex {
impl From<&'_ CodeIndex> for CodeIndexOffset {
#[inline(always)]
fn into(self) -> CodeIndexOffset {
self.0
fn from(value: &'_ CodeIndex) -> CodeIndexOffset {
value.0
}
}
@@ -206,7 +206,7 @@ impl VarKey {
#[inline]
pub(crate) fn to_string(&self) -> String {
match self {
VarKey::AnonVar(h) => format!("_{}", h),
VarKey::AnonVar(h) => format!("_{h}"),
VarKey::VarPtr(var) => var.borrow().to_string(),
}
}
@@ -526,7 +526,7 @@ impl IndexStore {
&'a self,
range: R,
) -> impl Iterator<Item = Stream> + 'a {
self.streams.range(range).into_iter().copied()
self.streams.range(range).copied()
}
/// Forcibly sets `alias` to `stream`.

View File

@@ -659,8 +659,8 @@ impl MachineState {
&self.atom_tbl,
)
);
Ok(unify_fn!(*self, var_names_offset, var_names_addr))
unify_fn!(*self, var_names_offset, var_names_addr);
Ok(())
}
pub fn read_term_body(&mut self, mut term_write_result: TermWriteResult) -> CallResult {

View File

@@ -847,13 +847,11 @@ impl MachineState {
if let Some(c) = char_iter.next() {
if n == 1 {
self.unify_char(c, a3);
} else if char_iter.next().is_some() {
unify_fn!(*self, pstr_loc_as_cell!(pstr_loc + c.len_utf8()), a3);
} else {
if char_iter.next().is_some() {
unify_fn!(*self, pstr_loc_as_cell!(pstr_loc + c.len_utf8()), a3);
} else {
let tail_idx = Heap::pstr_tail_idx(pstr_loc + c.len_utf8());
unify_fn!(*self, self.heap[tail_idx], a3);
}
let tail_idx = Heap::pstr_tail_idx(pstr_loc + c.len_utf8());
unify_fn!(*self, self.heap[tail_idx], a3);
}
} else {
unreachable!()

View File

@@ -56,7 +56,7 @@ impl MockWAM {
let mut printer = HCPrinter::new(
&mut self.machine_st.heap,
&mut self.machine_st.stack,
&mut self.machine_st.arena,
&self.machine_st.arena,
&self.op_dir,
PrinterOutputter::new(),
term_write_result.heap_loc,
@@ -195,15 +195,11 @@ pub fn all_cells_marked_and_unforwarded(heap: &Heap, offset: usize) {
assert!(
cell.get_mark_bit(),
"cell {:?} at index {} is not marked",
cell,
curr_idx
"cell {cell:?} at index {curr_idx} is not marked"
);
assert!(
!cell.get_forwarding_bit(),
"cell {:?} at index {} is forwarded",
cell,
curr_idx
"cell {cell:?} at index {curr_idx} is forwarded"
);
}
}
@@ -227,9 +223,7 @@ pub fn all_cells_unmarked(iter: &impl SizedHeap) {
assert!(
!cell.get_mark_bit(),
"cell {:?} at index {} is still marked",
cell,
curr_idx
"cell {cell:?} at index {curr_idx} is still marked"
);
}
}
@@ -255,6 +249,7 @@ pub(crate) fn parse_and_write_parsed_term_to_heap(
impl Machine {
/// For use in tests.
#[allow(clippy::unbuffered_bytes)]
pub fn test_load_file(&mut self, file: &str) -> Vec<u8> {
let stream = Stream::from_owned_string(
std::fs::read_to_string(AsRef::<std::path::Path>::as_ref(file)).unwrap(),
@@ -266,6 +261,7 @@ impl Machine {
}
/// For use in tests.
#[allow(clippy::unbuffered_bytes)]
pub fn test_load_string(&mut self, code: &str) -> Vec<u8> {
let stream = Stream::from_owned_string(code.to_owned(), &mut self.machine_st.arena);

View File

@@ -1653,7 +1653,8 @@ impl MachineState {
};
stream.set_past_end_of_stream(true);
Ok(unify!(self, result, end_of_stream))
unify!(self, result, end_of_stream);
Ok(())
}
EOFAction::Reset => {
if !stream.reset() {

View File

@@ -194,7 +194,7 @@ fn pstr_segment_char_count_up_to(
let mut byte_offset = 0;
if max_chars > 0 {
while let Some(c) = char_iter.next() {
for c in &mut char_iter {
if c == '\u{0}' {
break;
}
@@ -784,7 +784,7 @@ impl MachineState {
let steps = if max_steps > -1 {
std::cmp::min(max_steps, num_steps as i64)
} else {
max_steps as i64
max_steps
};
self.finalize_skip_max_list(steps, pstr_loc); // cell);
@@ -989,6 +989,7 @@ impl MachineState {
}
}
#[allow(clippy::never_loop)] // TODO why is there a loop here that never loops?
loop {
match lexer.lookahead_char() {
Err(e) if e.is_unexpected_eof() => {
@@ -2327,7 +2328,7 @@ impl Machine {
let cell = step_or_resource_error!(
self.machine_st,
self.machine_st.heap.allocate_cstr(&*name.as_str())
self.machine_st.heap.allocate_cstr(&name.as_str())
);
unify!(self.machine_st, self.machine_st.registers[2], cell);
@@ -2386,7 +2387,7 @@ impl Machine {
self.machine_st,
sized_iter_to_heap_list(
&mut self.machine_st.heap,
(&*name).chars().count(),
name.chars().count(),
iter,
)
);
@@ -2916,7 +2917,7 @@ impl Machine {
let string = match Number::try_from((n, &self.machine_st.arena.f64_tbl)) {
Ok(Number::Float(OrderedFloat(n))) => {
format!("{0:<20?}", n)
format!("{n:<20?}")
}
Ok(Number::Fixnum(n)) => n.get_num().to_string(),
Ok(Number::Integer(n)) => n.to_string(),
@@ -3245,7 +3246,7 @@ impl Machine {
let n: u32 = (&*n).try_into().unwrap();
let n = char::try_from(n);
if let Ok(c) = n {
write!(&mut stream, "{}", c).unwrap();
write!(&mut stream, "{c}").unwrap();
return Ok(());
}
}
@@ -3253,7 +3254,7 @@ impl Machine {
let n = n.get_num();
if let Some(c) = u32::try_from(n).ok().and_then(char::from_u32) {
write!(&mut stream, "{}", c).unwrap();
write!(&mut stream, "{c}").unwrap();
return Ok(());
}
}
@@ -3295,13 +3296,13 @@ impl Machine {
read_heap_cell!(addr,
(HeapCellValueTag::Atom, (name, _arity)) => {
if let Some(c) = name.as_char() {
write!(&mut stream, "{}", c).unwrap();
write!(&mut stream, "{c}").unwrap();
return Ok(());
}
}
/*
(HeapCellValueTag::Char, c) => {
write!(&mut stream, "{}", c).unwrap();
write!(&mut stream, "{c}").unwrap();
return Ok(());
}
*/
@@ -3792,11 +3793,7 @@ impl Machine {
#[inline(always)]
pub(crate) fn first_stream(&mut self) {
let first_stream = self
.indices
.iter_streams(..)
.filter(|s| !s.is_null_stream())
.next();
let first_stream = self.indices.iter_streams(..).find(|s| !s.is_null_stream());
if let Some(first_stream) = first_stream {
let stream = first_stream.into();
@@ -3816,8 +3813,7 @@ impl Machine {
.indices
.iter_streams(prev_stream..)
.filter(|s| !s.is_null_stream())
.skip(1)
.next();
.nth(1);
if let Some(next_stream) = next_stream {
let var = self.deref_register(2).as_var().unwrap();
@@ -3935,14 +3931,14 @@ impl Machine {
self.indices.remove_stream(stream);
stream.close().or_else(|_| {
stream.close().map_err(|_| {
let stub = functor_stub(atom!("close"), 1);
let addr = stream.into();
let err = self
.machine_st
.existence_error(ExistenceError::Stream(addr));
Err(self.machine_st.error_form(err, stub))
self.machine_st.error_form(err, stub)
})
}
@@ -4152,9 +4148,7 @@ impl Machine {
let mut functor_writer = Heap::functor_writer(functor);
if let Err(e) = functor_writer(heap) {
return Err(e);
}
functor_writer(heap)?;
num_functors += 1;
}
@@ -7637,7 +7631,7 @@ impl Machine {
let buffer = git_version!(cargo_prefix = "cargo:", fallback = "unknown");
let cstr_cell =
step_or_resource_error!(self.machine_st, self.machine_st.heap.allocate_cstr(&buffer));
step_or_resource_error!(self.machine_st, self.machine_st.heap.allocate_cstr(buffer));
unify!(self.machine_st, cstr_cell, self.machine_st.registers[1]);
}
@@ -8622,7 +8616,7 @@ impl Machine {
];
for spec in SPECIFIERS {
fstr.push_str(&format!("'{}'=\"%{}\", ", spec, spec).to_string());
fstr.push_str(&format!("'{spec}'=\"%{spec}\", "));
}
fstr.push_str("finis].");
@@ -8719,7 +8713,7 @@ impl Machine {
Ok(result)
}
scraper::Node::Comment(comment) => {
let comment = self.machine_st.heap.allocate_cstr(&comment)?;
let comment = self.machine_st.heap.allocate_cstr(comment)?;
let result = str_loc_as_cell!(self.machine_st.heap.cell_len());
let mut writer = self.machine_st.heap.reserve(2)?;

View File

@@ -290,7 +290,7 @@ pub(crate) trait Unifier: DerefMut<Target = MachineState> {
let machine_st = self.deref_mut();
let f1 = machine_st.arena.f64_tbl.get_entry(f1);
let f2 = machine_st.arena.f64_tbl.get_entry(f2.into());
let f2 = machine_st.arena.f64_tbl.get_entry(f2);
self.fail = f1 != f2;
}

View File

@@ -10,7 +10,6 @@ use std::cell::{Cell, Ref, RefCell, RefMut};
use std::fmt;
use std::hash::Hash;
use std::hash::Hasher;
use std::i64;
use std::io::{Error as IOError, ErrorKind};
use std::ops::Not;
use std::ops::RangeInclusive;
@@ -268,8 +267,8 @@ impl RegType {
impl fmt::Display for RegType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
RegType::Perm(val) => write!(f, "Y{}", val),
RegType::Temp(val) => write!(f, "X{}", val),
RegType::Perm(val) => write!(f, "Y{val}"),
RegType::Temp(val) => write!(f, "X{val}"),
}
}
}
@@ -291,10 +290,10 @@ impl VarReg {
impl fmt::Display for VarReg {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
VarReg::Norm(RegType::Perm(reg)) => write!(f, "Y{}", reg),
VarReg::Norm(RegType::Temp(reg)) => write!(f, "X{}", reg),
VarReg::ArgAndNorm(RegType::Perm(reg), arg) => write!(f, "Y{} A{}", reg, arg),
VarReg::ArgAndNorm(RegType::Temp(reg), arg) => write!(f, "X{} A{}", reg, arg),
VarReg::Norm(RegType::Perm(reg)) => write!(f, "Y{reg}"),
VarReg::Norm(RegType::Temp(reg)) => write!(f, "X{reg}"),
VarReg::ArgAndNorm(RegType::Perm(reg), arg) => write!(f, "Y{reg} A{arg}"),
VarReg::ArgAndNorm(RegType::Temp(reg), arg) => write!(f, "X{reg} A{arg}"),
}
}
}
@@ -830,7 +829,7 @@ impl Var {
#[inline(always)]
pub fn to_string(&self) -> String {
match self {
Var::InSitu(n) | Var::Generated(n) => format!("_{}", n),
Var::InSitu(n) | Var::Generated(n) => format!("_{n}"),
Var::Named(value) => value.as_ref().clone(),
}
}
@@ -858,9 +857,9 @@ impl Term {
}
pub fn name(&self) -> Option<Atom> {
match self {
&Term::Literal(_, Literal::Atom(atom)) => Some(atom),
&Term::Clause(_, atom, ..) => Some(atom),
match *self {
Term::Literal(_, Literal::Atom(atom)) => Some(atom),
Term::Clause(_, atom, ..) => Some(atom),
_ => None,
}
}

View File

@@ -63,6 +63,7 @@ enum Number {
impl Number {
#[inline]
#[allow(clippy::wrong_self_convention)]
fn to_literal(self) -> Literal {
match self {
Number::BigInt(ibig) => Literal::Integer(ibig),
@@ -80,6 +81,7 @@ enum NumberToken {
impl NumberToken {
#[inline]
#[allow(clippy::wrong_self_convention)]
fn to_token(self) -> Option<Token> {
match self {
NumberToken::Number(number) => Some(Token::Literal(number.to_literal())),
@@ -959,8 +961,8 @@ impl<'a, R: CharRead> Lexer<'a, R> {
))))
}
},
Ok(NumberToken::Number(n)) => return Ok(Token::Literal(n.to_literal())),
Err(e) => return Err(e),
Ok(NumberToken::Number(n)) => Ok(Token::Literal(n.to_literal())),
Err(e) => Err(e),
}
}

View File

@@ -111,7 +111,7 @@ pub(crate) fn as_partial_string(
tail_ref = tail;
}
Term::CompleteString(_, cstr) => {
string += &*cstr.as_str();
string += cstr.as_str();
tail = Term::Literal(Cell::default(), Literal::Atom(atom!("[]")));
break;
}