Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy 1.83.0 #176

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metamath-rs/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Item> {
Expand Down
4 changes: 2 additions & 2 deletions metamath-rs/src/comment_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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<Self::Item> {
Expand Down
14 changes: 7 additions & 7 deletions metamath-rs/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ impl Database {
/// Panics if [`Database::name_pass`] was not previously called.
#[inline]
#[must_use]
pub fn name_result(&self) -> &Arc<Nameset> {
pub const fn name_result(&self) -> &Arc<Nameset> {
self.nameset.as_ref().expect(
"The database has not run `name_pass()`. Please ensure it is run before calling depending methods."
)
Expand Down Expand Up @@ -574,7 +574,7 @@ impl Database {
/// properties) can be obtained from this object.
#[inline]
#[must_use]
pub fn scope_result(&self) -> &Arc<ScopeResult> {
pub const fn scope_result(&self) -> &Arc<ScopeResult> {
self.try_scope_result().expect(
"The database has not run `scope_pass()`. Please ensure it is run before calling depending methods."
)
Expand Down Expand Up @@ -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<VerifyResult> {
pub const fn verify_result(&self) -> &Arc<VerifyResult> {
self.try_verify_result().expect(
"The database has not run `verify_pass()`. Please ensure it is run before calling depending methods."
)
Expand Down Expand Up @@ -675,7 +675,7 @@ impl Database {
/// Panics if [`Database::typesetting_pass`] was not previously called.
#[inline]
#[must_use]
pub fn typesetting_result(&self) -> &Arc<TypesettingData> {
pub const fn typesetting_result(&self) -> &Arc<TypesettingData> {
self.try_typesetting_result().expect(
"The database has not run `typesetting_pass()`. Please ensure it is run before calling depending methods."
)
Expand Down Expand Up @@ -704,7 +704,7 @@ impl Database {
/// Panics if [`Database::outline_pass`] was not previously called.
#[inline]
#[must_use]
pub fn outline_result(&self) -> &Arc<Outline> {
pub const fn outline_result(&self) -> &Arc<Outline> {
self.try_outline_result().expect(
"The database has not run `outline_pass()`. Please ensure it is run before calling depending methods."
)
Expand Down Expand Up @@ -734,7 +734,7 @@ impl Database {
/// Panics if [`Database::grammar_pass`] was not previously called.
#[inline]
#[must_use]
pub fn grammar_result(&self) -> &Arc<Grammar> {
pub const fn grammar_result(&self) -> &Arc<Grammar> {
self.try_grammar_result().expect(
"The database has not run `grammar_pass()`. Please ensure it is run before calling depending methods."
)
Expand Down Expand Up @@ -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<StmtParse> {
pub const fn stmt_parse_result(&self) -> &Arc<StmtParse> {
self.try_stmt_parse_result().expect(
"The database has not run `stmt_parse_pass()`. Please ensure it is run before calling depending methods."
)
Expand Down
20 changes: 10 additions & 10 deletions metamath-rs/src/formula.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ 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 {
self.substitutions
}
}

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 {
Expand Down Expand Up @@ -428,7 +428,7 @@ pub struct LabelIter<'a> {
root: Option<NodeId>,
}

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));
Expand All @@ -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<Self::Item> {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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<Self::Item> {
Expand Down Expand Up @@ -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)))?;
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion metamath-rs/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions metamath-rs/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RPNStep> {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions metamath-rs/src/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Item> {
Expand All @@ -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::Item> {
self.0.next_back().copied()
}
Expand Down Expand Up @@ -183,7 +183,7 @@ impl Comparer<TokenAddress> for Database {
}
}

impl<'a, T, C: Comparer<T>> Comparer<T> for &'a C {
impl<T, C: Comparer<T>> Comparer<T> for &'_ C {
fn cmp(&self, left: &T, right: &T) -> Ordering {
(*self).cmp(left, right)
}
Expand Down Expand Up @@ -254,7 +254,7 @@ pub struct SegmentRef<'a> {
pub id: SegmentId,
}

impl<'a> Deref for SegmentRef<'a> {
impl Deref for SegmentRef<'_> {
type Target = Arc<Segment>;

#[inline]
Expand Down
8 changes: 4 additions & 4 deletions metamath-rs/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::Item> {
self.slice_iter.next_back().map(|st_ref| StatementRef {
segment: self.segment,
Expand All @@ -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()
}
Expand All @@ -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]
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions metamath-rs/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl<TreeItem> Tree<TreeItem> {
/// 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!(
Expand Down Expand Up @@ -187,7 +187,7 @@ impl<'a, TreeItem> Iterator for NodeIter<'a, TreeItem> {
}
}

impl<'a, TreeItem> ExactSizeIterator for NodeIter<'a, TreeItem> {
impl<TreeItem> ExactSizeIterator for NodeIter<'_, TreeItem> {
fn len(&self) -> usize {
self.0.len()
}
Expand Down
2 changes: 1 addition & 1 deletion metamath-rs/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) fn fast_clear<T: Copy>(vec: &mut Vec<T>) {

// emprically, *most* copies in the verifier where fast_extend and extend_from_within
// are used are 1-2 bytes
unsafe fn short_copy<T>(src: *const T, dst: *mut T, count: usize) {
const unsafe fn short_copy<T>(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())),
Expand Down
Loading