diff --git a/metamath-rs/src/bit_set.rs b/metamath-rs/src/bit_set.rs index 4afb879..86111fc 100644 --- a/metamath-rs/src/bit_set.rs +++ b/metamath-rs/src/bit_set.rs @@ -172,7 +172,7 @@ pub struct BitsetIter<'a> { buffer: slice::Iter<'a, usize>, } -impl<'a> Iterator for BitsetIter<'a> { +impl Iterator for BitsetIter<'_> { type Item = usize; fn next(&mut self) -> Option { diff --git a/metamath-rs/src/comment_parser.rs b/metamath-rs/src/comment_parser.rs index 0ab7962..210d9e7 100644 --- a/metamath-rs/src/comment_parser.rs +++ b/metamath-rs/src/comment_parser.rs @@ -344,7 +344,7 @@ impl<'a> CommentParser<'a> { } } -impl<'a> Iterator for CommentParser<'a> { +impl Iterator for CommentParser<'_> { type Item = CommentItem; #[allow(clippy::cognitive_complexity)] @@ -555,7 +555,7 @@ impl<'a> ParentheticalIter<'a> { } } -impl<'a> Iterator for ParentheticalIter<'a> { +impl Iterator for ParentheticalIter<'_> { type Item = (Span, Parenthetical); fn next(&mut self) -> Option { diff --git a/metamath-rs/src/database.rs b/metamath-rs/src/database.rs index 4b36a55..f9117d2 100644 --- a/metamath-rs/src/database.rs +++ b/metamath-rs/src/database.rs @@ -530,7 +530,7 @@ impl Database { /// Panics if [`Database::name_pass`] was not previously called. #[inline] #[must_use] - pub fn name_result(&self) -> &Arc { + pub const fn name_result(&self) -> &Arc { self.nameset.as_ref().expect( "The database has not run `name_pass()`. Please ensure it is run before calling depending methods." ) @@ -574,7 +574,7 @@ impl Database { /// properties) can be obtained from this object. #[inline] #[must_use] - pub fn scope_result(&self) -> &Arc { + pub const fn scope_result(&self) -> &Arc { self.try_scope_result().expect( "The database has not run `scope_pass()`. Please ensure it is run before calling depending methods." ) @@ -619,7 +619,7 @@ impl Database { /// than error diagnostics. It does not save any parsed proof data. #[inline] #[must_use] - pub fn verify_result(&self) -> &Arc { + pub const fn verify_result(&self) -> &Arc { self.try_verify_result().expect( "The database has not run `verify_pass()`. Please ensure it is run before calling depending methods." ) @@ -675,7 +675,7 @@ impl Database { /// Panics if [`Database::typesetting_pass`] was not previously called. #[inline] #[must_use] - pub fn typesetting_result(&self) -> &Arc { + pub const fn typesetting_result(&self) -> &Arc { self.try_typesetting_result().expect( "The database has not run `typesetting_pass()`. Please ensure it is run before calling depending methods." ) @@ -704,7 +704,7 @@ impl Database { /// Panics if [`Database::outline_pass`] was not previously called. #[inline] #[must_use] - pub fn outline_result(&self) -> &Arc { + pub const fn outline_result(&self) -> &Arc { self.try_outline_result().expect( "The database has not run `outline_pass()`. Please ensure it is run before calling depending methods." ) @@ -734,7 +734,7 @@ impl Database { /// Panics if [`Database::grammar_pass`] was not previously called. #[inline] #[must_use] - pub fn grammar_result(&self) -> &Arc { + pub const fn grammar_result(&self) -> &Arc { self.try_grammar_result().expect( "The database has not run `grammar_pass()`. Please ensure it is run before calling depending methods." ) @@ -770,7 +770,7 @@ impl Database { /// Panics if [`Database::stmt_parse_pass`] was not previously called. #[inline] #[must_use] - pub fn stmt_parse_result(&self) -> &Arc { + pub const fn stmt_parse_result(&self) -> &Arc { self.try_stmt_parse_result().expect( "The database has not run `stmt_parse_pass()`. Please ensure it is run before calling depending methods." ) diff --git a/metamath-rs/src/formula.rs b/metamath-rs/src/formula.rs index ddb7830..9b598f3 100644 --- a/metamath-rs/src/formula.rs +++ b/metamath-rs/src/formula.rs @@ -138,7 +138,7 @@ pub struct SubstitutionsRef<'a> { substitutions: &'a Substitutions, } -impl<'a> std::ops::Deref for SubstitutionsRef<'a> { +impl std::ops::Deref for SubstitutionsRef<'_> { type Target = Substitutions; fn deref(&self) -> &Self::Target { @@ -146,7 +146,7 @@ impl<'a> std::ops::Deref for SubstitutionsRef<'a> { } } -impl<'a> Debug for SubstitutionsRef<'a> { +impl Debug for SubstitutionsRef<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut dm = f.debug_map(); for (label, formula) in &self.substitutions.0 { @@ -428,7 +428,7 @@ pub struct LabelIter<'a> { root: Option, } -impl<'a> LabelIter<'a> { +impl LabelIter<'_> { #[inline] fn visit_children(&mut self, node_id: NodeId) -> (Label, bool) { self.stack.push(self.formula.tree.children_iter(node_id)); @@ -439,7 +439,7 @@ impl<'a> LabelIter<'a> { } } -impl<'a> Iterator for LabelIter<'a> { +impl Iterator for LabelIter<'_> { type Item = (Label, bool); fn next(&mut self) -> Option { @@ -489,7 +489,7 @@ pub struct FormulaRef<'a> { formula: &'a Formula, } -impl<'a> std::ops::Deref for FormulaRef<'a> { +impl std::ops::Deref for FormulaRef<'_> { type Target = Formula; fn deref(&self) -> &Self::Target { @@ -677,7 +677,7 @@ struct SubFormulaRef<'a> { f_ref: FormulaRef<'a>, } -impl<'a> Debug for SubFormulaRef<'a> { +impl Debug for SubFormulaRef<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let label_name = as_str( self.f_ref @@ -708,7 +708,7 @@ pub struct Flatten<'a> { nset: &'a Nameset, } -impl<'a> Flatten<'a> { +impl Flatten<'_> { fn step_into(&mut self, node_id: NodeId) { let label = self.formula.tree[node_id]; let sref = self.sset.statement( @@ -728,7 +728,7 @@ impl<'a> Flatten<'a> { } } -impl<'a> Iterator for Flatten<'a> { +impl Iterator for Flatten<'_> { type Item = Symbol; fn next(&mut self) -> Option { @@ -762,7 +762,7 @@ impl<'a> Iterator for Flatten<'a> { // TODO(tirix): provide an implementation for size_hint? } -impl<'a> Display for FormulaRef<'a> { +impl Display for FormulaRef<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let nset = &**self.db.name_result(); write!(f, "{}", as_str(nset.atom_name(self.typecode)))?; @@ -773,7 +773,7 @@ impl<'a> Display for FormulaRef<'a> { } } -impl<'a> Debug for FormulaRef<'a> { +impl Debug for FormulaRef<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { SubFormulaRef { node_id: self.formula.root, diff --git a/metamath-rs/src/parser.rs b/metamath-rs/src/parser.rs index 0d1e944..e8470e0 100644 --- a/metamath-rs/src/parser.rs +++ b/metamath-rs/src/parser.rs @@ -114,7 +114,7 @@ enum CommentType { Heading(HeadingLevel), } -impl<'a> Scanner<'a> { +impl Scanner<'_> { /// Record a diagnostic against the nascent statement fn diag(&mut self, diag: Diagnostic) { self.diagnostics.push((self.statement_index, diag)); diff --git a/metamath-rs/src/proof.rs b/metamath-rs/src/proof.rs index 2543b07..8e75dd4 100644 --- a/metamath-rs/src/proof.rs +++ b/metamath-rs/src/proof.rs @@ -314,7 +314,7 @@ pub struct NormalIter<'a> { stack: Vec<(usize, usize)>, } -impl<'a> Iterator for NormalIter<'a> { +impl Iterator for NormalIter<'_> { type Item = RPNStep; fn next(&mut self) -> Option { @@ -495,7 +495,7 @@ struct ProofTreePrinterImpl<'a, 'b> { backref_max: usize, } -impl<'a, 'b> ProofTreePrinterImpl<'a, 'b> { +impl ProofTreePrinterImpl<'_, '_> { fn write_word(&mut self, word: &str) -> fmt::Result { let len = word.len() as u16; if self.chr + len < self.p.line_width { @@ -793,7 +793,7 @@ fn knapsack_fit(items: &[usize], values: &[u16], mut size: usize, included: &mut } } -impl<'a> fmt::Display for ProofTreePrinter<'a> { +impl fmt::Display for ProofTreePrinter<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut indent = "\n".to_string(); for _ in 0..self.indent { diff --git a/metamath-rs/src/segment.rs b/metamath-rs/src/segment.rs index 280df2c..539518e 100644 --- a/metamath-rs/src/segment.rs +++ b/metamath-rs/src/segment.rs @@ -102,7 +102,7 @@ impl SegmentOrder { #[derive(Clone)] pub(crate) struct SegmentIter<'a>(std::slice::Iter<'a, SegmentId>); -impl<'a> Iterator for SegmentIter<'a> { +impl Iterator for SegmentIter<'_> { type Item = SegmentId; fn next(&mut self) -> Option { @@ -114,13 +114,13 @@ impl<'a> Iterator for SegmentIter<'a> { } } -impl<'a> ExactSizeIterator for SegmentIter<'a> { +impl ExactSizeIterator for SegmentIter<'_> { fn len(&self) -> usize { self.0.len() } } -impl<'a> DoubleEndedIterator for SegmentIter<'a> { +impl DoubleEndedIterator for SegmentIter<'_> { fn next_back(&mut self) -> Option { self.0.next_back().copied() } @@ -183,7 +183,7 @@ impl Comparer for Database { } } -impl<'a, T, C: Comparer> Comparer for &'a C { +impl> Comparer for &'_ C { fn cmp(&self, left: &T, right: &T) -> Ordering { (*self).cmp(left, right) } @@ -254,7 +254,7 @@ pub struct SegmentRef<'a> { pub id: SegmentId, } -impl<'a> Deref for SegmentRef<'a> { +impl Deref for SegmentRef<'_> { type Target = Arc; #[inline] diff --git a/metamath-rs/src/statement.rs b/metamath-rs/src/statement.rs index ada8e3b..697574e 100644 --- a/metamath-rs/src/statement.rs +++ b/metamath-rs/src/statement.rs @@ -765,7 +765,7 @@ impl<'a> Iterator for StatementIter<'a> { } } -impl<'a> DoubleEndedIterator for StatementIter<'a> { +impl DoubleEndedIterator for StatementIter<'_> { fn next_back(&mut self) -> Option { self.slice_iter.next_back().map(|st_ref| StatementRef { segment: self.segment, @@ -775,7 +775,7 @@ impl<'a> DoubleEndedIterator for StatementIter<'a> { } } -impl<'a> ExactSizeIterator for StatementIter<'a> { +impl ExactSizeIterator for StatementIter<'_> { fn len(&self) -> usize { self.slice_iter.len() } @@ -801,7 +801,7 @@ pub struct TokenRef<'a> { pub address: TokenAddress, } -impl<'a> Deref for TokenRef<'a> { +impl Deref for TokenRef<'_> { type Target = [u8]; #[inline] @@ -810,7 +810,7 @@ impl<'a> Deref for TokenRef<'a> { } } -impl<'a> TokenRef<'a> { +impl TokenRef<'_> { /// Get the local index of the token within the statement under iteration. #[must_use] pub const fn index(self) -> TokenIndex { diff --git a/metamath-rs/src/tree.rs b/metamath-rs/src/tree.rs index bf19412..bb4f4b6 100644 --- a/metamath-rs/src/tree.rs +++ b/metamath-rs/src/tree.rs @@ -104,7 +104,7 @@ impl Tree { /// Debug only, dumps the internal structure of the tree. pub(crate) fn dump<'a, D>(&'a self, display: D) where - D: Fn(&'a TreeItem) -> &str, + D: Fn(&'a TreeItem) -> &'a str, { for node in &self.nodes { println!( @@ -187,7 +187,7 @@ impl<'a, TreeItem> Iterator for NodeIter<'a, TreeItem> { } } -impl<'a, TreeItem> ExactSizeIterator for NodeIter<'a, TreeItem> { +impl ExactSizeIterator for NodeIter<'_, TreeItem> { fn len(&self) -> usize { self.0.len() } diff --git a/metamath-rs/src/util.rs b/metamath-rs/src/util.rs index c94c6f5..c88c844 100644 --- a/metamath-rs/src/util.rs +++ b/metamath-rs/src/util.rs @@ -20,7 +20,7 @@ pub(crate) fn fast_clear(vec: &mut Vec) { // emprically, *most* copies in the verifier where fast_extend and extend_from_within // are used are 1-2 bytes -unsafe fn short_copy(src: *const T, dst: *mut T, count: usize) { +const unsafe fn short_copy(src: *const T, dst: *mut T, count: usize) { match count { 1 => ptr::write(dst, ptr::read(src)), 2 => ptr::write(dst.cast::<[T; 2]>(), ptr::read(src.cast())),