clear rustc warnings (#3051)

This commit is contained in:
Mark Thom
2025-08-23 14:34:49 -07:00
parent e168b31963
commit 39d02a0caf
14 changed files with 25 additions and 78 deletions

View File

@@ -133,7 +133,10 @@ impl BranchStack {
} }
#[inline] #[inline]
pub(crate) fn drain_branches(&mut self, depth: usize) -> std::vec::Drain<BranchOccurrences> { pub(crate) fn drain_branches(
&mut self,
depth: usize,
) -> std::vec::Drain<'_, BranchOccurrences> {
let start_idx = self.len() - depth; let start_idx = self.len() - depth;
self.drain(start_idx..) self.drain(start_idx..)
} }

View File

@@ -19,7 +19,7 @@ use std::vec::Vec;
pub fn eager_stackful_preorder_iter( pub fn eager_stackful_preorder_iter(
heap: &mut Heap, heap: &mut Heap,
value: HeapCellValue, value: HeapCellValue,
) -> EagerStackfulPreOrderHeapIter { ) -> EagerStackfulPreOrderHeapIter<'_> {
EagerStackfulPreOrderHeapIter::new(heap, value) EagerStackfulPreOrderHeapIter::new(heap, value)
} }
@@ -646,7 +646,7 @@ mod tests {
pub(crate) fn stackless_preorder_iter( pub(crate) fn stackless_preorder_iter(
heap: &mut Heap, heap: &mut Heap,
start: usize, start: usize,
) -> StacklessPreOrderHeapIter<IteratorUMP> { ) -> StacklessPreOrderHeapIter<'_, IteratorUMP> {
StacklessPreOrderHeapIter::<IteratorUMP>::new(heap, start) StacklessPreOrderHeapIter::<IteratorUMP>::new(heap, start)
} }
@@ -654,7 +654,7 @@ mod tests {
pub(crate) fn stackless_post_order_iter( pub(crate) fn stackless_post_order_iter(
heap: &'_ mut Heap, heap: &'_ mut Heap,
start: usize, start: usize,
) -> RightistPostOrderHeapIter { ) -> RightistPostOrderHeapIter<'_> {
PostOrderIterator::new(stackless_preorder_iter(heap, start)) PostOrderIterator::new(stackless_preorder_iter(heap, start))
} }

View File

@@ -233,7 +233,6 @@ enum TokenOrRedirect {
OpenList(Rc<Cell<(bool, usize)>>), OpenList(Rc<Cell<(bool, usize)>>),
CloseList(Rc<Cell<(bool, usize)>>), CloseList(Rc<Cell<(bool, usize)>>),
HeadTailSeparator, HeadTailSeparator,
StackPop,
CommaSeparatedCharList(CommaSeparatedCharList), CommaSeparatedCharList(CommaSeparatedCharList),
} }
@@ -1862,10 +1861,6 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
TokenOrRedirect::Space => push_char!(self, ' '), TokenOrRedirect::Space => push_char!(self, ' '),
TokenOrRedirect::LeftCurly => push_char!(self, '{'), TokenOrRedirect::LeftCurly => push_char!(self, '{'),
TokenOrRedirect::RightCurly => push_char!(self, '}'), TokenOrRedirect::RightCurly => push_char!(self, '}'),
TokenOrRedirect::StackPop => {
self.iter.pop_stack();
self.state_stack.push(TokenOrRedirect::Atom(atom!("...")));
}
TokenOrRedirect::CommaSeparatedCharList(char_list) => { TokenOrRedirect::CommaSeparatedCharList(char_list) => {
self.print_comma_separated_char_list(char_list); self.print_comma_separated_char_list(char_list);
} }

View File

@@ -305,14 +305,14 @@ impl<'a> Iterator for FactIterator<'a> {
} }
} }
pub(crate) fn post_order_iter(term: &'_ Term) -> QueryIterator { pub(crate) fn post_order_iter(term: &Term) -> QueryIterator<'_> {
QueryIterator::from_term(term) QueryIterator::from_term(term)
} }
pub(crate) fn breadth_first_iter( pub(crate) fn breadth_first_iter(
term: &'_ Term, term: &Term,
iterable_root: RootIterationPolicy, iterable_root: RootIterationPolicy,
) -> FactIterator { ) -> FactIterator<'_> {
FactIterator::new(term, iterable_root) FactIterator::new(term, iterable_root)
} }
@@ -336,7 +336,7 @@ pub(crate) struct ClauseIterator<'a> {
remaining_chunks_on_stack: usize, remaining_chunks_on_stack: usize,
} }
fn state_from_chunked_terms(chunk_vec: &'_ VecDeque<ChunkedTerms>) -> ClauseIteratorState { fn state_from_chunked_terms(chunk_vec: &VecDeque<ChunkedTerms>) -> ClauseIteratorState<'_> {
if chunk_vec.len() == 1 { if chunk_vec.len() == 1 {
if let Some(ChunkedTerms::Branch(ref branches)) = chunk_vec.front() { if let Some(ChunkedTerms::Branch(ref branches)) = chunk_vec.front() {
return ClauseIteratorState::RemainingBranches(branches, 0); return ClauseIteratorState::RemainingBranches(branches, 0);

View File

@@ -82,7 +82,7 @@ pub trait CopierTarget: IndexMut<usize, Output = HeapCellValue> {
// returns the tail location of the pstr on success // returns the tail location of the pstr on success
fn as_slice_from<'a>(&'a self, from: usize) -> Box<dyn Iterator<Item = u8> + 'a>; fn as_slice_from<'a>(&'a self, from: usize) -> Box<dyn Iterator<Item = u8> + 'a>;
fn copy_pstr_to_threshold(&mut self, pstr_loc: usize) -> Result<usize, usize>; fn copy_pstr_to_threshold(&mut self, pstr_loc: usize) -> Result<usize, usize>;
fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter, usize>; fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter<'_>, usize>;
fn copy_slice_to_end(&mut self, bounds: Range<usize>) -> Result<(), usize>; fn copy_slice_to_end(&mut self, bounds: Range<usize>) -> Result<(), usize>;
} }

View File

@@ -18,7 +18,7 @@ use std::collections::VecDeque;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
#[derive(Debug, Clone)]//, PartialOrd, PartialEq, Eq, Hash)] #[derive(Debug, Clone)] //, PartialOrd, PartialEq, Eq, Hash)]
pub struct BranchNumber { pub struct BranchNumber {
branch_num: Rational, branch_num: Rational,
delta: Rational, delta: Rational,

View File

@@ -94,7 +94,7 @@ pub struct HeapStringScan<'a> {
} }
// The heap_slice should be inside the heap // The heap_slice should be inside the heap
unsafe fn scan_slice_to_str(heap_slice: &[u8]) -> HeapStringScan { unsafe fn scan_slice_to_str(heap_slice: &[u8]) -> HeapStringScan<'_> {
let string_len = heap_slice let string_len = heap_slice
.iter() .iter()
.position(|b| *b == 0u8) .position(|b| *b == 0u8)
@@ -117,7 +117,7 @@ unsafe fn scan_slice_to_str(heap_slice: &[u8]) -> HeapStringScan {
// Same as scan_slice_to_str but assumes that the slice is from the start of a string. // Same as scan_slice_to_str but assumes that the slice is from the start of a string.
// Can be used on strings out of the heap. // Can be used on strings out of the heap.
unsafe fn scan_slice_to_str_from_start(heap_slice: &[u8]) -> HeapStringScan { unsafe fn scan_slice_to_str_from_start(heap_slice: &[u8]) -> HeapStringScan<'_> {
let string_len = heap_slice let string_len = heap_slice
.iter() .iter()
.position(|b| *b == 0u8) .position(|b| *b == 0u8)
@@ -529,7 +529,7 @@ impl<'a> SizedHeap for HeapWriter<'a> {
self.section.cell_len() self.section.cell_len()
} }
fn scan_slice_to_str(&self, slice_loc: usize) -> HeapStringScan { fn scan_slice_to_str(&self, slice_loc: usize) -> HeapStringScan<'_> {
let HeapStringScan { string, tail_idx } = unsafe { let HeapStringScan { string, tail_idx } = unsafe {
let slice = std::slice::from_raw_parts( let slice = std::slice::from_raw_parts(
self.section.heap_ptr.byte_add(slice_loc), self.section.heap_ptr.byte_add(slice_loc),
@@ -612,7 +612,7 @@ impl Heap {
} }
} }
pub fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter, usize> { pub fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter<'_>, usize> {
let section; let section;
let len = heap_index!(num_cells); let len = heap_index!(num_cells);
@@ -1064,7 +1064,7 @@ impl SizedHeap for Heap {
self.cell_len() self.cell_len()
} }
fn scan_slice_to_str(&self, slice_loc: usize) -> HeapStringScan { fn scan_slice_to_str(&self, slice_loc: usize) -> HeapStringScan<'_> {
let HeapStringScan { string, tail_idx } = unsafe { let HeapStringScan { string, tail_idx } = unsafe {
let slice = std::slice::from_raw_parts( let slice = std::slice::from_raw_parts(
self.inner.ptr.add(slice_loc), self.inner.ptr.add(slice_loc),

View File

@@ -561,7 +561,7 @@ impl Machine {
} }
/// Runs a query. /// Runs a query.
pub fn run_query(&mut self, query: impl Into<String>) -> QueryState { pub fn run_query(&mut self, query: impl Into<String>) -> QueryState<'_> {
let mut parser = Parser::new( let mut parser = Parser::new(
Stream::from_owned_string(query.into(), &mut self.machine_st.arena), Stream::from_owned_string(query.into(), &mut self.machine_st.arena),
&mut self.machine_st, &mut self.machine_st,

View File

@@ -1361,7 +1361,7 @@ impl<'a> MachinePreludeView<'a> {
pub(super) fn composite_op_dir( pub(super) fn composite_op_dir(
&self, &self,
compilation_target: &CompilationTarget, compilation_target: &CompilationTarget,
) -> CompositeOpDir { ) -> CompositeOpDir<'_, '_> {
match compilation_target { match compilation_target {
CompilationTarget::User => CompositeOpDir::new(&self.indices.op_dir, None), CompilationTarget::User => CompositeOpDir::new(&self.indices.op_dir, None),
CompilationTarget::Module(ref module_name) => { CompilationTarget::Module(ref module_name) => {

View File

@@ -136,7 +136,7 @@ impl IndexPtr {
} }
} }
#[derive(Debug, Clone, Copy)]// , Ord, Hash, PartialOrd, Eq, PartialEq)] #[derive(Debug, Clone, Copy)] // , Ord, Hash, PartialOrd, Eq, PartialEq)]
pub struct CodeIndex(CodeIndexOffset); pub struct CodeIndex(CodeIndexOffset);
#[cfg(target_pointer_width = "32")] #[cfg(target_pointer_width = "32")]

View File

@@ -352,7 +352,7 @@ impl<'a> CopierTarget for CopyTerm<'a> {
} }
#[inline(always)] #[inline(always)]
fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter, usize> { fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter<'_>, usize> {
self.state.heap.reserve(num_cells) self.state.heap.reserve(num_cells)
} }
@@ -478,7 +478,7 @@ impl<'a> CopierTarget for CopyBallTerm<'a> {
} }
#[inline] #[inline]
fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter, usize> { fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter<'_>, usize> {
self.stub.reserve(num_cells) self.stub.reserve(num_cells)
} }

View File

@@ -178,7 +178,7 @@ impl<'a> CopierTarget for TermCopyingMockWAM<'a> {
} }
#[inline(always)] #[inline(always)]
fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter, usize> { fn reserve(&mut self, num_cells: usize) -> Result<HeapWriter<'_>, usize> {
self.wam.machine_st.heap.reserve(num_cells) self.wam.machine_st.heap.reserve(num_cells)
} }

View File

@@ -220,7 +220,7 @@ pub(crate) fn get_structure_index(value: HeapCellValue) -> Option<CodeIndex> {
impl Machine { impl Machine {
#[inline] #[inline]
fn prelude_view_and_machine_st(&mut self) -> (MachinePreludeView, &mut MachineState) { fn prelude_view_and_machine_st(&mut self) -> (MachinePreludeView<'_>, &mut MachineState) {
( (
MachinePreludeView { MachinePreludeView {
indices: &mut self.indices, indices: &mut self.indices,

View File

@@ -5,8 +5,6 @@ use crate::machine::machine_errors::CycleSearchResult;
use crate::machine::system_calls::BrentAlgState; use crate::machine::system_calls::BrentAlgState;
use crate::types::*; use crate::types::*;
use std::ops::Deref;
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub struct HeapPStrIter<'a> { pub struct HeapPStrIter<'a> {
pub heap: &'a Heap, pub heap: &'a Heap,
@@ -209,55 +207,6 @@ impl<'a> Iterator for HeapPStrIter<'a> {
} }
} }
pub struct PStrCharsIter<'a> {
pub iter: HeapPStrIter<'a>,
pub item: Option<PStrIteratee>,
}
impl<'a> Deref for PStrCharsIter<'a> {
type Target = HeapPStrIter<'a>;
fn deref(&self) -> &Self::Target {
&self.iter
}
}
impl<'a> Iterator for PStrCharsIter<'a> {
type Item = char;
fn next(&mut self) -> Option<Self::Item> {
while let Some(item) = self.item {
match item {
PStrIteratee::Char { value, .. } => {
self.item = self.iter.next();
return Some(value);
}
PStrIteratee::PStrSlice {
slice_loc,
slice_len,
} => {
let s = self.iter.heap.slice_to_str(slice_loc, slice_len);
match s.chars().next() {
Some(c) => {
self.item = Some(PStrIteratee::PStrSlice {
slice_loc: slice_loc + c.len_utf8(),
slice_len: slice_len - c.len_utf8(),
});
return Some(c);
}
None => {
self.item = self.iter.next();
}
}
}
}
}
None
}
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;