From 39d02a0caffa0f7b67377821e7d5f64258d82140 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Sat, 23 Aug 2025 14:34:49 -0700 Subject: [PATCH] clear rustc warnings (#3051) --- src/debray_allocator.rs | 5 +++- src/heap_iter.rs | 6 ++-- src/heap_print.rs | 5 ---- src/iterators.rs | 8 +++--- src/machine/copier.rs | 2 +- src/machine/disjuncts.rs | 2 +- src/machine/heap.rs | 10 +++---- src/machine/lib_machine/mod.rs | 2 +- src/machine/loader.rs | 2 +- src/machine/machine_indices.rs | 2 +- src/machine/machine_state.rs | 4 +-- src/machine/mock_wam.rs | 2 +- src/machine/mod.rs | 2 +- src/machine/partial_string.rs | 51 ---------------------------------- 14 files changed, 25 insertions(+), 78 deletions(-) diff --git a/src/debray_allocator.rs b/src/debray_allocator.rs index 53c7f206..7fe37259 100644 --- a/src/debray_allocator.rs +++ b/src/debray_allocator.rs @@ -133,7 +133,10 @@ impl BranchStack { } #[inline] - pub(crate) fn drain_branches(&mut self, depth: usize) -> std::vec::Drain { + pub(crate) fn drain_branches( + &mut self, + depth: usize, + ) -> std::vec::Drain<'_, BranchOccurrences> { let start_idx = self.len() - depth; self.drain(start_idx..) } diff --git a/src/heap_iter.rs b/src/heap_iter.rs index a57101b9..365d9ca3 100644 --- a/src/heap_iter.rs +++ b/src/heap_iter.rs @@ -19,7 +19,7 @@ use std::vec::Vec; pub fn eager_stackful_preorder_iter( heap: &mut Heap, value: HeapCellValue, -) -> EagerStackfulPreOrderHeapIter { +) -> EagerStackfulPreOrderHeapIter<'_> { EagerStackfulPreOrderHeapIter::new(heap, value) } @@ -646,7 +646,7 @@ mod tests { pub(crate) fn stackless_preorder_iter( heap: &mut Heap, start: usize, - ) -> StacklessPreOrderHeapIter { + ) -> StacklessPreOrderHeapIter<'_, IteratorUMP> { StacklessPreOrderHeapIter::::new(heap, start) } @@ -654,7 +654,7 @@ mod tests { pub(crate) fn stackless_post_order_iter( heap: &'_ mut Heap, start: usize, - ) -> RightistPostOrderHeapIter { + ) -> RightistPostOrderHeapIter<'_> { PostOrderIterator::new(stackless_preorder_iter(heap, start)) } diff --git a/src/heap_print.rs b/src/heap_print.rs index 6c3c2ceb..44989fb6 100644 --- a/src/heap_print.rs +++ b/src/heap_print.rs @@ -233,7 +233,6 @@ enum TokenOrRedirect { OpenList(Rc>), CloseList(Rc>), HeadTailSeparator, - StackPop, CommaSeparatedCharList(CommaSeparatedCharList), } @@ -1862,10 +1861,6 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> { TokenOrRedirect::Space => push_char!(self, ' '), TokenOrRedirect::LeftCurly => 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) => { self.print_comma_separated_char_list(char_list); } diff --git a/src/iterators.rs b/src/iterators.rs index 8e2e43dd..e3a2ccbd 100644 --- a/src/iterators.rs +++ b/src/iterators.rs @@ -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) } pub(crate) fn breadth_first_iter( - term: &'_ Term, + term: &Term, iterable_root: RootIterationPolicy, -) -> FactIterator { +) -> FactIterator<'_> { FactIterator::new(term, iterable_root) } @@ -336,7 +336,7 @@ pub(crate) struct ClauseIterator<'a> { remaining_chunks_on_stack: usize, } -fn state_from_chunked_terms(chunk_vec: &'_ VecDeque) -> ClauseIteratorState { +fn state_from_chunked_terms(chunk_vec: &VecDeque) -> ClauseIteratorState<'_> { if chunk_vec.len() == 1 { if let Some(ChunkedTerms::Branch(ref branches)) = chunk_vec.front() { return ClauseIteratorState::RemainingBranches(branches, 0); diff --git a/src/machine/copier.rs b/src/machine/copier.rs index 78658c4a..110371bc 100644 --- a/src/machine/copier.rs +++ b/src/machine/copier.rs @@ -82,7 +82,7 @@ pub trait CopierTarget: IndexMut { // returns the tail location of the pstr on success fn as_slice_from<'a>(&'a self, from: usize) -> Box + 'a>; fn copy_pstr_to_threshold(&mut self, pstr_loc: usize) -> Result; - fn reserve(&mut self, num_cells: usize) -> Result; + fn reserve(&mut self, num_cells: usize) -> Result, usize>; fn copy_slice_to_end(&mut self, bounds: Range) -> Result<(), usize>; } diff --git a/src/machine/disjuncts.rs b/src/machine/disjuncts.rs index 49cf8c14..4ecac7bc 100644 --- a/src/machine/disjuncts.rs +++ b/src/machine/disjuncts.rs @@ -18,7 +18,7 @@ use std::collections::VecDeque; use std::hash::{Hash, Hasher}; use std::ops::{Deref, DerefMut}; -#[derive(Debug, Clone)]//, PartialOrd, PartialEq, Eq, Hash)] +#[derive(Debug, Clone)] //, PartialOrd, PartialEq, Eq, Hash)] pub struct BranchNumber { branch_num: Rational, delta: Rational, diff --git a/src/machine/heap.rs b/src/machine/heap.rs index e69050ab..c6ca9871 100644 --- a/src/machine/heap.rs +++ b/src/machine/heap.rs @@ -94,7 +94,7 @@ pub struct HeapStringScan<'a> { } // 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 .iter() .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. // 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 .iter() .position(|b| *b == 0u8) @@ -529,7 +529,7 @@ impl<'a> SizedHeap for HeapWriter<'a> { 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 slice = std::slice::from_raw_parts( self.section.heap_ptr.byte_add(slice_loc), @@ -612,7 +612,7 @@ impl Heap { } } - pub fn reserve(&mut self, num_cells: usize) -> Result { + pub fn reserve(&mut self, num_cells: usize) -> Result, usize> { let section; let len = heap_index!(num_cells); @@ -1064,7 +1064,7 @@ impl SizedHeap for Heap { 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 slice = std::slice::from_raw_parts( self.inner.ptr.add(slice_loc), diff --git a/src/machine/lib_machine/mod.rs b/src/machine/lib_machine/mod.rs index a1ba3399..fc036940 100644 --- a/src/machine/lib_machine/mod.rs +++ b/src/machine/lib_machine/mod.rs @@ -561,7 +561,7 @@ impl Machine { } /// Runs a query. - pub fn run_query(&mut self, query: impl Into) -> QueryState { + pub fn run_query(&mut self, query: impl Into) -> QueryState<'_> { let mut parser = Parser::new( Stream::from_owned_string(query.into(), &mut self.machine_st.arena), &mut self.machine_st, diff --git a/src/machine/loader.rs b/src/machine/loader.rs index 6efe1984..b4d54676 100644 --- a/src/machine/loader.rs +++ b/src/machine/loader.rs @@ -1361,7 +1361,7 @@ impl<'a> MachinePreludeView<'a> { pub(super) fn composite_op_dir( &self, compilation_target: &CompilationTarget, - ) -> CompositeOpDir { + ) -> CompositeOpDir<'_, '_> { match compilation_target { CompilationTarget::User => CompositeOpDir::new(&self.indices.op_dir, None), CompilationTarget::Module(ref module_name) => { diff --git a/src/machine/machine_indices.rs b/src/machine/machine_indices.rs index 8a0b6d41..7f7bfe35 100644 --- a/src/machine/machine_indices.rs +++ b/src/machine/machine_indices.rs @@ -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); #[cfg(target_pointer_width = "32")] diff --git a/src/machine/machine_state.rs b/src/machine/machine_state.rs index 7663c952..c77110c7 100644 --- a/src/machine/machine_state.rs +++ b/src/machine/machine_state.rs @@ -352,7 +352,7 @@ impl<'a> CopierTarget for CopyTerm<'a> { } #[inline(always)] - fn reserve(&mut self, num_cells: usize) -> Result { + fn reserve(&mut self, num_cells: usize) -> Result, usize> { self.state.heap.reserve(num_cells) } @@ -478,7 +478,7 @@ impl<'a> CopierTarget for CopyBallTerm<'a> { } #[inline] - fn reserve(&mut self, num_cells: usize) -> Result { + fn reserve(&mut self, num_cells: usize) -> Result, usize> { self.stub.reserve(num_cells) } diff --git a/src/machine/mock_wam.rs b/src/machine/mock_wam.rs index 0fcebd41..df9dbe75 100644 --- a/src/machine/mock_wam.rs +++ b/src/machine/mock_wam.rs @@ -178,7 +178,7 @@ impl<'a> CopierTarget for TermCopyingMockWAM<'a> { } #[inline(always)] - fn reserve(&mut self, num_cells: usize) -> Result { + fn reserve(&mut self, num_cells: usize) -> Result, usize> { self.wam.machine_st.heap.reserve(num_cells) } diff --git a/src/machine/mod.rs b/src/machine/mod.rs index 51ae44e4..db6dae7e 100644 --- a/src/machine/mod.rs +++ b/src/machine/mod.rs @@ -220,7 +220,7 @@ pub(crate) fn get_structure_index(value: HeapCellValue) -> Option { impl Machine { #[inline] - fn prelude_view_and_machine_st(&mut self) -> (MachinePreludeView, &mut MachineState) { + fn prelude_view_and_machine_st(&mut self) -> (MachinePreludeView<'_>, &mut MachineState) { ( MachinePreludeView { indices: &mut self.indices, diff --git a/src/machine/partial_string.rs b/src/machine/partial_string.rs index ee0c2be9..977c421c 100644 --- a/src/machine/partial_string.rs +++ b/src/machine/partial_string.rs @@ -5,8 +5,6 @@ use crate::machine::machine_errors::CycleSearchResult; use crate::machine::system_calls::BrentAlgState; use crate::types::*; -use std::ops::Deref; - #[derive(Clone, Copy)] pub struct HeapPStrIter<'a> { 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, -} - -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 { - 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)] mod test { use super::*; -- 2.54.0