chore: misc clippy lints

This commit is contained in:
Will Lillis 2024-10-06 17:55:00 -04:00 committed by GitHub
parent 50bea73ce3
commit 5c6445edea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 74 additions and 72 deletions

View file

@ -55,7 +55,7 @@ impl<'a> CoincidentTokenIndex<'a> {
}
}
impl<'a> fmt::Debug for CoincidentTokenIndex<'a> {
impl fmt::Debug for CoincidentTokenIndex<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "CoincidentTokenIndex {{")?;

View file

@ -180,7 +180,7 @@ impl<'a> ParseItemSet<'a> {
}
}
impl<'a> fmt::Display for ParseItemDisplay<'a> {
impl fmt::Display for ParseItemDisplay<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
if self.0.is_augmented() {
write!(f, "START →")?;
@ -243,7 +243,7 @@ impl<'a> fmt::Display for ParseItemDisplay<'a> {
}
}
impl<'a> fmt::Display for TokenSetDisplay<'a> {
impl fmt::Display for TokenSetDisplay<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "[")?;
for (i, symbol) in self.0.iter().enumerate() {
@ -268,7 +268,7 @@ impl<'a> fmt::Display for TokenSetDisplay<'a> {
}
}
impl<'a> fmt::Display for ParseItemSetDisplay<'a> {
impl fmt::Display for ParseItemSetDisplay<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
for (item, lookaheads) in &self.0.entries {
writeln!(
@ -282,7 +282,7 @@ impl<'a> fmt::Display for ParseItemSetDisplay<'a> {
}
}
impl<'a> Hash for ParseItem<'a> {
impl Hash for ParseItem<'_> {
fn hash<H: Hasher>(&self, hasher: &mut H) {
hasher.write_u32(self.variable_index);
hasher.write_u32(self.step_index);
@ -311,7 +311,7 @@ impl<'a> Hash for ParseItem<'a> {
}
}
impl<'a> PartialEq for ParseItem<'a> {
impl PartialEq for ParseItem<'_> {
fn eq(&self, other: &Self) -> bool {
if self.variable_index != other.variable_index
|| self.step_index != other.step_index
@ -348,7 +348,7 @@ impl<'a> PartialEq for ParseItem<'a> {
}
}
impl<'a> Ord for ParseItem<'a> {
impl Ord for ParseItem<'_> {
fn cmp(&self, other: &Self) -> Ordering {
self.step_index
.cmp(&other.step_index)
@ -388,15 +388,15 @@ impl<'a> Ord for ParseItem<'a> {
}
}
impl<'a> PartialOrd for ParseItem<'a> {
impl PartialOrd for ParseItem<'_> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<'a> Eq for ParseItem<'a> {}
impl Eq for ParseItem<'_> {}
impl<'a> Hash for ParseItemSet<'a> {
impl Hash for ParseItemSet<'_> {
fn hash<H: Hasher>(&self, hasher: &mut H) {
hasher.write_usize(self.entries.len());
for (item, lookaheads) in &self.entries {
@ -406,7 +406,7 @@ impl<'a> Hash for ParseItemSet<'a> {
}
}
impl<'a> Hash for ParseItemSetCore<'a> {
impl Hash for ParseItemSetCore<'_> {
fn hash<H: Hasher>(&self, hasher: &mut H) {
hasher.write_usize(self.entries.len());
for item in &self.entries {

View file

@ -289,7 +289,7 @@ impl<'a> ParseItemSetBuilder<'a> {
}
}
impl<'a> fmt::Debug for ParseItemSetBuilder<'a> {
impl fmt::Debug for ParseItemSetBuilder<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "ParseItemSetBuilder {{")?;

View file

@ -44,7 +44,7 @@ struct Minimizer<'a> {
simple_aliases: &'a AliasMap,
}
impl<'a> Minimizer<'a> {
impl Minimizer<'_> {
fn remove_unit_reductions(&mut self) {
let mut aliased_symbols = HashSet::new();
for variable in &self.syntax_grammar.variables {

View file

@ -145,7 +145,7 @@ impl<'a> TokenConflictMap<'a> {
}
}
impl<'a> fmt::Debug for TokenConflictMap<'a> {
impl fmt::Debug for TokenConflictMap<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "TokenConflictMap {{")?;

View file

@ -66,16 +66,12 @@ pub fn generate_parser_in_directory(
}
}
let grammar_path = grammar_path
.map(PathBuf::from)
.unwrap_or_else(|| repo_path.join("grammar.js"));
let grammar_path = grammar_path.map_or_else(|| repo_path.join("grammar.js"), PathBuf::from);
// Read the grammar file.
let grammar_json = load_grammar_file(&grammar_path, js_runtime)?;
let src_path = out_path
.map(PathBuf::from)
.unwrap_or_else(|| repo_path.join("src"));
let src_path = out_path.map_or_else(|| repo_path.join("src"), PathBuf::from);
let header_path = src_path.join("tree_sitter");
// Ensure that the output directories exist.

View file

@ -94,7 +94,7 @@ struct Interner<'a> {
grammar: &'a InputGrammar,
}
impl<'a> Interner<'a> {
impl Interner<'_> {
fn intern_rule(&self, rule: &Rule, name: Option<&str>) -> Result<Rule> {
match rule {
Rule::Choice(elements) => {