From 08686837e5d10e8828b5daf34bda3da6c7af6d71 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Thu, 7 Dec 2023 11:10:13 +0100 Subject: [PATCH] Finish setting up rustc/Clippy lints and fix those (#695) Part of #155 Commit messages have a bit more context on the relevant changes. I've decided to drop very few lints from the EDR list like deny-by-default ones, `inconsistent_struct_constructor` (not that useful) or `implicit_clone` (a lot of false-positives/unidiomatic suggestions; let's wait for Rust 1.74 and https://github.com/rust-lang/rust-clippy/issues/11281 to include it again) or irrelevant ones for us like `suboptimal_flops`. --- .cargo/config.toml | 25 +- crates/codegen/ebnf/src/serialization.rs | 27 +- crates/codegen/grammar/src/grammar.rs | 2 +- .../src/compiler/analysis/definitions.rs | 2 +- .../src/compiler/analysis/reachability.rs | 2 +- .../src/compiler/analysis/references.rs | 17 +- .../definition/src/internals/errors.rs | 22 +- .../internals/parse_input_tokens/adapter.rs | 15 +- .../parse_input_tokens/external_types.rs | 39 +- .../internals/parse_input_tokens/helpers.rs | 38 +- .../src/internals/parse_input_tokens/mod.rs | 10 +- .../definition/src/internals/spanned/mod.rs | 6 +- .../write_output_tokens/external_types.rs | 14 +- .../language/definition/src/model/manifest.rs | 2 +- .../definition/src/model/terminals/keyword.rs | 17 +- .../definition/src/model/utils/identifier.rs | 2 +- .../src/derive/parse_input_tokens.rs | 14 +- .../internal_macros/src/derive/spanned.rs | 4 +- .../src/derive/write_output_tokens.rs | 8 +- .../internal_macros/src/input_model.rs | 8 +- crates/codegen/language/tests/src/fail/mod.rs | 2 +- .../parser/generator/src/code_generator.rs | 19 +- .../parser/generator/src/parser_definition.rs | 1 + .../src/precedence_parser_definition.rs | 31 +- .../generator/src/scanner_definition.rs | 2 +- crates/codegen/parser/runtime/src/cst.rs | 16 +- crates/codegen/parser/runtime/src/cursor.rs | 18 +- crates/codegen/parser/runtime/src/lexer.rs | 20 +- .../parser/runtime/src/napi/napi_cursor.rs | 10 +- .../runtime/src/napi/napi_parse_error.rs | 9 +- .../runtime/src/napi/napi_text_index.rs | 2 + .../codegen/parser/runtime/src/parse_error.rs | 3 +- .../runtime/src/support/choice_helper.rs | 18 +- .../parser/runtime/src/support/context.rs | 2 +- .../runtime/src/support/parser_function.rs | 6 +- .../runtime/src/support/parser_result.rs | 1 + .../runtime/src/support/precedence_helper.rs | 5 +- .../parser/runtime/src/support/recovery.rs | 69 +-- .../runtime/src/support/repetition_helper.rs | 12 +- .../runtime/src/support/scanner_macros.rs | 1 + .../runtime/src/support/separated_helper.rs | 12 +- .../runtime/src/support/sequence_helper.rs | 5 +- .../runtime/src/templates/language.rs.jinja2 | 17 +- .../rules/definitions/keywords/collector.rs | 15 +- .../rules/definitions/operators/mod.rs | 2 +- .../rules/definitions/versions/mod.rs | 5 +- .../validation/rules/references/validator.rs | 10 +- .../src/validation/visitors/version_set.rs | 6 +- crates/codegen/spec/src/snippets.rs | 2 +- crates/codegen/testing/src/cst_output.rs | 11 +- crates/infra/cli/src/commands/ci/mod.rs | 1 + crates/infra/cli/src/toolchains/napi/cli.rs | 2 + .../infra/cli/src/toolchains/napi/compiler.rs | 1 + .../infra/cli/src/toolchains/napi/config.rs | 2 +- crates/infra/utils/src/cargo/workspace.rs | 13 +- .../utils/src/codegen/common/formatting.rs | 2 +- crates/infra/utils/src/codegen/read_write.rs | 24 +- crates/infra/utils/src/commands/mod.rs | 10 +- crates/infra/utils/src/errors/mod.rs | 8 +- .../solidity/inputs/language/src/grammar.rs | 96 +-- .../outputs/cargo/crate/src/generated/cst.rs | 16 +- .../cargo/crate/src/generated/cursor.rs | 18 +- .../cargo/crate/src/generated/language.rs | 556 +++++++++--------- .../cargo/crate/src/generated/lexer.rs | 20 +- .../crate/src/generated/napi/napi_cursor.rs | 10 +- .../src/generated/napi/napi_parse_error.rs | 9 +- .../src/generated/napi/napi_text_index.rs | 2 + .../cargo/crate/src/generated/parse_error.rs | 3 +- .../src/generated/support/choice_helper.rs | 18 +- .../crate/src/generated/support/context.rs | 2 +- .../src/generated/support/parser_function.rs | 6 +- .../src/generated/support/parser_result.rs | 1 + .../generated/support/precedence_helper.rs | 5 +- .../crate/src/generated/support/recovery.rs | 69 +-- .../generated/support/repetition_helper.rs | 12 +- .../src/generated/support/scanner_macros.rs | 1 + .../src/generated/support/separated_helper.rs | 12 +- .../src/generated/support/sequence_helper.rs | 5 +- .../solidity/outputs/cargo/crate/src/main.rs | 19 +- .../outputs/npm/crate/src/generated/cst.rs | 16 +- .../outputs/npm/crate/src/generated/cursor.rs | 18 +- .../npm/crate/src/generated/language.rs | 556 +++++++++--------- .../outputs/npm/crate/src/generated/lexer.rs | 20 +- .../crate/src/generated/napi/napi_cursor.rs | 10 +- .../src/generated/napi/napi_parse_error.rs | 9 +- .../src/generated/napi/napi_text_index.rs | 2 + .../npm/crate/src/generated/parse_error.rs | 3 +- .../src/generated/support/choice_helper.rs | 18 +- .../crate/src/generated/support/context.rs | 2 +- .../src/generated/support/parser_function.rs | 6 +- .../src/generated/support/parser_result.rs | 1 + .../generated/support/precedence_helper.rs | 5 +- .../crate/src/generated/support/recovery.rs | 69 +-- .../generated/support/repetition_helper.rs | 12 +- .../src/generated/support/scanner_macros.rs | 1 + .../src/generated/support/separated_helper.rs | 12 +- .../src/generated/support/sequence_helper.rs | 5 +- crates/solidity/testing/sanctuary/src/main.rs | 36 +- .../testing/sanctuary/src/reporting.rs | 5 +- .../testing/utils/src/cst_snapshots/mod.rs | 4 +- .../testing/utils/src/version_pragmas/mod.rs | 18 +- 101 files changed, 1248 insertions(+), 1129 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 076961a1bd..1bdce1cd79 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -10,9 +10,24 @@ lto = true # https://blog.rust-lang.org/2023/11/16/Rust-1.74.0.html#lint-configuration-through-cargo rustflags = [ # rustc additional warnings: - "--warn", - "unused_crate_dependencies", - # clippy additional warnings: - "--warn", - "clippy::wildcard_imports", + "-Wunused_crate_dependencies", + # Rust 2018 idioms that are not yet warn-by-default: + "-Welided_lifetimes_in_paths", + "-Wunused_extern_crates", + "-Wexplicit_outlives_requirements", + # ๐Ÿ“Ž Lints that are enabled (warn/deny) by default + "-Wclippy::all", + # Restriction (optional, neutral lints) + "-Wclippy::exit", # Prefer not `process::exit`ing directly + "-Wclippy::rest_pat_in_fully_bound_structs", # Prefer not to use `..` in fully bound structs + "-Wclippy::verbose_file_reads", # Prefer simpler and more concise `fs::read_to_string` + # Pedantic + "-Wclippy::pedantic", # Warn about pedantic lints, except... + "-Aclippy::implicit_clone", # A lot of false positives, tuned down in Clippy bundled with Rust 1.73 + "-Aclippy::match_same_arms", # It's often clearer to have the same arm twice + "-Aclippy::missing_errors_doc", # Most of our code is internal; let's not clutter the docs until... + "-Aclippy::missing_panics_doc", # ... we care about the public documentation in our shipped crates + "-Aclippy::module_name_repetitions", # It seems we prefer it this way; we'd need to discuss that + "-Aclippy::must_use_candidate", # Overzealous, we'd have to `[must_use]` a lot of things + "-Aclippy::redundant_closure_for_method_calls", # Not always clearer, let's not pepper `allow`s whenever needed ] diff --git a/crates/codegen/ebnf/src/serialization.rs b/crates/codegen/ebnf/src/serialization.rs index 1ccc6ff8e8..c3b9f477ab 100644 --- a/crates/codegen/ebnf/src/serialization.rs +++ b/crates/codegen/ebnf/src/serialization.rs @@ -87,17 +87,15 @@ impl EbnfSerializer { } /// Naive version of formatting for long EBNF statements. - /// Tries to break long lines, which are usually choices of references (PrecedenceParser) or keywords (Scanner). + /// Tries to break long lines, which are usually choices of references + /// ([`PrecedenceParser`](ProductionDefinition::PrecedenceParser)) or keywords ([`Scanner`](ProductionDefinition::Scanner)). /// Otherwise, prints everything on a single line. fn serialize_root_node(&mut self, name: &str, root_node: &EbnfNode) -> String { - let choices = match &root_node { - EbnfNode::Choice { nodes } => nodes, - _ => { - // Not a choice: Just flush everything on a single line: - let mut buffer = String::new(); - self.serialize_node(root_node, &mut buffer); - return buffer; - } + let EbnfNode::Choice { nodes: choices } = &root_node else { + // Not a choice: Just flush everything on a single line: + let mut buffer = String::new(); + self.serialize_node(root_node, &mut buffer); + return buffer; }; let choices = choices @@ -202,13 +200,10 @@ impl EbnfSerializer { fn display_name(&self, name: &str) -> String { let mut name = name.to_owned(); - let production = match self.language.productions.get(&name) { - Some(production) => production, - None => { - // Not a top-level production, so it is an named parser. - // Therefore, it is neither inlined nor a scanner. Return name as-is: - return name; - } + let Some(production) = self.language.productions.get(&name) else { + // Not a top-level production, so it is an named parser. + // Therefore, it is neither inlined nor a scanner. Return name as-is: + return name; }; if matches!(production.definition, ProductionDefinition::Scanner { .. }) { diff --git a/crates/codegen/grammar/src/grammar.rs b/crates/codegen/grammar/src/grammar.rs index ae3aa6c539..72790ddea5 100644 --- a/crates/codegen/grammar/src/grammar.rs +++ b/crates/codegen/grammar/src/grammar.rs @@ -84,7 +84,7 @@ impl Visitable for GrammarElement { Self::TriviaParserDefinition(trivia_parser) => trivia_parser.accept_visitor(visitor), Self::ParserDefinition(parser) => parser.accept_visitor(visitor), Self::PrecedenceParserDefinition(precedence_parser) => { - precedence_parser.accept_visitor(visitor) + precedence_parser.accept_visitor(visitor); } } } diff --git a/crates/codegen/language/definition/src/compiler/analysis/definitions.rs b/crates/codegen/language/definition/src/compiler/analysis/definitions.rs index a247f8012a..fb4bbdbe50 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/definitions.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/definitions.rs @@ -151,7 +151,7 @@ fn calculate_defined_in(analysis: &mut Analysis, item: &SpannedItem) -> VersionS } SpannedItem::Token { item } => { for definition in &item.definitions { - try_add_specifier(&definition.enabled) + try_add_specifier(&definition.enabled); } } SpannedItem::Fragment { item } => { diff --git a/crates/codegen/language/definition/src/compiler/analysis/reachability.rs b/crates/codegen/language/definition/src/compiler/analysis/reachability.rs index eed5958836..dce3343791 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/reachability.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/reachability.rs @@ -33,7 +33,7 @@ fn check_unreachabable_items(analysis: &mut Analysis) { collect_trivia(&language.leading_trivia, &mut queue); collect_trivia(&language.trailing_trivia, &mut queue); - let mut visited = queue.iter().cloned().collect::>(); + let mut visited = queue.iter().copied().collect::>(); while let Some(name) = queue.pop() { for referenced_item in &analysis.metadata[name].referenced_items { diff --git a/crates/codegen/language/definition/src/compiler/analysis/references.rs b/crates/codegen/language/definition/src/compiler/analysis/references.rs index 506ed90b3d..287f85a034 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/references.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/references.rs @@ -4,7 +4,9 @@ use crate::{ model::{ Identifier, SpannedEnumItem, SpannedEnumVariant, SpannedField, SpannedFragmentItem, SpannedItem, - SpannedItemDiscriminants::{self, *}, + SpannedItemDiscriminants::{ + self, Enum, Fragment, Keyword, Precedence, Repeated, Separated, Struct, Token, Trivia, + }, SpannedKeywordDefinition, SpannedKeywordItem, SpannedPrecedenceExpression, SpannedPrecedenceItem, SpannedPrecedenceOperator, SpannedPrimaryExpression, SpannedRepeatedItem, SpannedScanner, SpannedSeparatedItem, SpannedStructItem, @@ -363,14 +365,11 @@ fn check_reference( enablement: &VersionSet, expected_kinds: &[SpannedItemDiscriminants], ) { - let target = match analysis.metadata.get_mut(&**reference) { - Some(target) => target, - None => { - analysis - .errors - .add(reference, &Errors::UnknownReference(reference)); - return; - } + let Some(target) = analysis.metadata.get_mut(&**reference) else { + analysis + .errors + .add(reference, &Errors::UnknownReference(reference)); + return; }; let not_defined_in = enablement.difference(&target.defined_in); diff --git a/crates/codegen/language/definition/src/internals/errors.rs b/crates/codegen/language/definition/src/internals/errors.rs index 55d5acf19a..f9315c291a 100644 --- a/crates/codegen/language/definition/src/internals/errors.rs +++ b/crates/codegen/language/definition/src/internals/errors.rs @@ -3,7 +3,7 @@ use std::fmt::Display; pub type Result = std::result::Result; -/// Our own proxy for [syn::Error] since the latter does not expose the underlying sub-errors. +/// Our own proxy for [`syn::Error`] since the latter does not expose the underlying sub-errors. #[derive(Debug)] pub struct Error { message: String, @@ -18,7 +18,7 @@ impl Error { }) } - pub fn from_syn(error: syn::Error) -> Self { + pub fn from_syn(error: &syn::Error) -> Self { Self { message: error.to_string(), span: error.span(), @@ -34,6 +34,18 @@ impl Error { } } +impl From for Error { + fn from(error: syn::Error) -> Self { + Self::from_syn(&error) + } +} + +impl From for syn::Error { + fn from(error: Error) -> Self { + Error::to_syn(&error) + } +} + #[derive(Debug)] pub struct ErrorsCollection { errors: Vec, @@ -60,11 +72,7 @@ impl ErrorsCollection { } pub fn to_compile_errors(&self) -> TokenStream { - return self - .errors - .iter() - .map(|error| error.to_compile_error()) - .collect(); + self.errors.iter().map(Error::to_compile_error).collect() } } diff --git a/crates/codegen/language/definition/src/internals/parse_input_tokens/adapter.rs b/crates/codegen/language/definition/src/internals/parse_input_tokens/adapter.rs index 7ae2845cbf..34db2bd001 100644 --- a/crates/codegen/language/definition/src/internals/parse_input_tokens/adapter.rs +++ b/crates/codegen/language/definition/src/internals/parse_input_tokens/adapter.rs @@ -1,5 +1,5 @@ use crate::{ - internals::{Error, ErrorsCollection, ParseInputTokens, Result}, + internals::{ErrorsCollection, ParseInputTokens, Result}, model::SpannedLanguage, }; use proc_macro2::TokenStream; @@ -9,7 +9,7 @@ pub(crate) struct ParseAdapter; impl ParseAdapter { pub fn parse(input: TokenStream) -> Result { - syn::parse2(input).map_err(Error::from_syn) + Ok(syn::parse2(input)?) } } @@ -18,14 +18,13 @@ pub(crate) struct ParseOutput { pub errors: ErrorsCollection, } -/// A wrapper around [syn::parse::Parse] to convert to/from our own error types. +/// A wrapper around [`syn::parse::Parse`] to convert to/from our own error types. impl Parse for ParseOutput { - fn parse(input: ParseStream) -> syn::Result { + fn parse(input: ParseStream<'_>) -> syn::Result { let mut errors = ErrorsCollection::new(); - match SpannedLanguage::parse_named_value(input, &mut errors) { - Ok(language) => Ok(Self { language, errors }), - Err(error) => Err(error.to_syn()), - } + let language = SpannedLanguage::parse_named_value(input, &mut errors)?; + + Ok(Self { language, errors }) } } diff --git a/crates/codegen/language/definition/src/internals/parse_input_tokens/external_types.rs b/crates/codegen/language/definition/src/internals/parse_input_tokens/external_types.rs index 3c33c0f2a1..64425d1230 100644 --- a/crates/codegen/language/definition/src/internals/parse_input_tokens/external_types.rs +++ b/crates/codegen/language/definition/src/internals/parse_input_tokens/external_types.rs @@ -1,5 +1,5 @@ use crate::internals::{ - parse_input_tokens::ParseHelpers, Error, ErrorsCollection, ParseInputTokens, Result, Spanned, + parse_input_tokens::ParseHelpers, ErrorsCollection, ParseInputTokens, Result, Spanned, }; use indexmap::{IndexMap, IndexSet}; use proc_macro2::Ident; @@ -8,7 +8,7 @@ use std::{fmt::Debug, rc::Rc}; use syn::{parse::ParseStream, LitBool, LitChar, LitStr}; impl ParseInputTokens for bool { - fn parse_value(input: ParseStream, _: &mut ErrorsCollection) -> Result { + fn parse_value(input: ParseStream<'_>, _: &mut ErrorsCollection) -> Result { let literal = ParseHelpers::syn::(input)?; Ok(literal.value()) @@ -16,7 +16,7 @@ impl ParseInputTokens for bool { } impl ParseInputTokens for Box { - fn parse_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { + fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { let value = T::parse_value(input, errors)?; Ok(value.into()) @@ -24,7 +24,7 @@ impl ParseInputTokens for Box { } impl ParseInputTokens for char { - fn parse_value(input: ParseStream, _: &mut ErrorsCollection) -> Result { + fn parse_value(input: ParseStream<'_>, _: &mut ErrorsCollection) -> Result { let literal = ParseHelpers::syn::(input)?; Ok(literal.value()) @@ -34,14 +34,14 @@ impl ParseInputTokens for char { impl ParseInputTokens for IndexMap { - fn parse_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { - ParseHelpers::map(input, errors) + fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { + Ok(ParseHelpers::map(input, errors)) } } impl ParseInputTokens for IndexSet> { - fn parse_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { - let sequence: Vec> = ParseHelpers::sequence(input, errors)?; + fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { + let sequence: Vec> = ParseHelpers::sequence(input, errors); let mut set = Self::new(); @@ -58,7 +58,7 @@ impl ParseInputTokens for IndexSet< } impl ParseInputTokens for Option { - fn parse_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { + fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { if input.is_empty() { Ok(None) } else { @@ -66,7 +66,11 @@ impl ParseInputTokens for Option { } } - fn parse_field(name: &str, input: ParseStream, errors: &mut ErrorsCollection) -> Result { + fn parse_field( + name: &str, + input: ParseStream<'_>, + errors: &mut ErrorsCollection, + ) -> Result { match ParseHelpers::syn::(&input.fork()) { Ok(key) if key == name => Ok(Some(ParseHelpers::field(name, input, errors)?)), _ => Ok(None), @@ -75,7 +79,7 @@ impl ParseInputTokens for Option { } impl ParseInputTokens for Rc { - fn parse_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { + fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { let value = T::parse_value(input, errors)?; Ok(value.into()) @@ -83,7 +87,7 @@ impl ParseInputTokens for Rc { } impl ParseInputTokens for String { - fn parse_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { + fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { let literal = ParseHelpers::syn::(input)?; let value = literal.value(); @@ -96,21 +100,22 @@ impl ParseInputTokens for String { } impl ParseInputTokens for usize { - fn parse_value(input: ParseStream, _: &mut ErrorsCollection) -> Result { + fn parse_value(input: ParseStream<'_>, _: &mut ErrorsCollection) -> Result { let literal = ParseHelpers::syn::(input)?; + let value = literal.base10_parse::()?; - literal.base10_parse::().map_err(Error::from_syn) + Ok(value) } } impl ParseInputTokens for Vec { - fn parse_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { - ParseHelpers::sequence(input, errors) + fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { + Ok(ParseHelpers::sequence(input, errors)) } } impl ParseInputTokens for Version { - fn parse_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { + fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { let literal = ParseHelpers::syn::(input)?; match Self::parse(&literal.value()) { diff --git a/crates/codegen/language/definition/src/internals/parse_input_tokens/helpers.rs b/crates/codegen/language/definition/src/internals/parse_input_tokens/helpers.rs index 36cedb2fac..667f0707ca 100644 --- a/crates/codegen/language/definition/src/internals/parse_input_tokens/helpers.rs +++ b/crates/codegen/language/definition/src/internals/parse_input_tokens/helpers.rs @@ -1,28 +1,28 @@ use crate::internals::{Error, ErrorsCollection, ParseInputTokens, Result, Spanned}; use indexmap::IndexMap; use proc_macro2::{extra::DelimSpan, Delimiter, Ident, TokenStream}; -use std::{fmt::Debug, ops::Deref}; +use std::fmt::Debug; use syn::{braced, bracketed, parenthesized, parse::ParseStream, Token}; pub struct ParseHelpers; impl ParseHelpers { - pub fn syn(input: ParseStream) -> Result { - input.parse::().map_err(Error::from_syn) + pub fn syn(input: ParseStream<'_>) -> Result { + Ok(input.parse::()?) } pub fn delimited( delimiter: Delimiter, - input: ParseStream, - inner_parser: impl FnOnce(DelimSpan, ParseStream) -> Result, + input: ParseStream<'_>, + inner_parser: impl FnOnce(DelimSpan, ParseStream<'_>) -> Result, ) -> Result { - delimited(delimiter, input, inner_parser).map_err(Error::from_syn) + Ok(delimited(delimiter, input, inner_parser)?) } pub fn sequence( - input: ParseStream, + input: ParseStream<'_>, errors: &mut ErrorsCollection, - ) -> Result> { + ) -> Vec { match Self::delimited(Delimiter::Bracket, input, |_, inner_input| { let mut result = Vec::new(); @@ -40,19 +40,19 @@ impl ParseHelpers { Ok(result) }) { - Ok(value) => Ok(value), + Ok(value) => value, Err(error) => { errors.push(error); - Ok(vec![]) + vec![] } } } pub fn map( - input: ParseStream, + input: ParseStream<'_>, errors: &mut ErrorsCollection, - ) -> Result> { + ) -> indexmap::IndexMap { match Self::delimited(Delimiter::Parenthesis, input, |_, inner_input| { let mut result = IndexMap::new(); @@ -71,7 +71,7 @@ impl ParseHelpers { } } - if result.contains_key(key.deref()) { + if result.contains_key(&*key) { errors.add(&key, &Errors::DuplicateMapKey); } else { result.insert(key.into_value(), value); @@ -80,18 +80,18 @@ impl ParseHelpers { Ok(result) }) { - Ok(value) => Ok(value), + Ok(value) => value, Err(error) => { errors.push(error); - Ok(IndexMap::new()) + IndexMap::new() } } } pub fn field( name: &str, - input: ParseStream, + input: ParseStream<'_>, errors: &mut ErrorsCollection, ) -> Result { let span = input.span(); @@ -116,11 +116,11 @@ impl ParseHelpers { } } -/// A wrapper to convert error types in callsites, since the macros below requires returning [syn::Result]. +/// A wrapper to convert error types in callsites, since the macros below requires returning [`syn::Result`]. fn delimited( delimiter: Delimiter, - input: ParseStream, - inner_parser: impl FnOnce(DelimSpan, ParseStream) -> Result, + input: ParseStream<'_>, + inner_parser: impl FnOnce(DelimSpan, ParseStream<'_>) -> Result, ) -> syn::Result { let inner_input; let span = match delimiter { diff --git a/crates/codegen/language/definition/src/internals/parse_input_tokens/mod.rs b/crates/codegen/language/definition/src/internals/parse_input_tokens/mod.rs index 8f1620d601..b78619f01f 100644 --- a/crates/codegen/language/definition/src/internals/parse_input_tokens/mod.rs +++ b/crates/codegen/language/definition/src/internals/parse_input_tokens/mod.rs @@ -10,17 +10,21 @@ use syn::parse::ParseStream; pub trait ParseInputTokens: Sized { /// Main parser entrypoint, and should be implemented by all types. - fn parse_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result; + fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result; /// Allows named types (structs) to parse the type name before its body. /// By default, it will parse the value directly if not overriden. - fn parse_named_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { + fn parse_named_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { Self::parse_value(input, errors) } /// Allows implementations (like `Option`) to modify the parsing logic, /// by checking if the field exists before attempting to parse it. - fn parse_field(name: &str, input: ParseStream, errors: &mut ErrorsCollection) -> Result { + fn parse_field( + name: &str, + input: ParseStream<'_>, + errors: &mut ErrorsCollection, + ) -> Result { ParseHelpers::field(name, input, errors) } } diff --git a/crates/codegen/language/definition/src/internals/spanned/mod.rs b/crates/codegen/language/definition/src/internals/spanned/mod.rs index d73d0d70fa..2ea4d4e8e3 100644 --- a/crates/codegen/language/definition/src/internals/spanned/mod.rs +++ b/crates/codegen/language/definition/src/internals/spanned/mod.rs @@ -44,7 +44,7 @@ impl Eq for Spanned {} impl std::hash::Hash for Spanned { fn hash(&self, state: &mut H) { - self.value.hash(state) + self.value.hash(state); } } @@ -67,14 +67,14 @@ impl PartialOrd for Spanned { } impl ParseInputTokens for Spanned { - fn parse_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { + fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { let span = input.span(); let value = T::parse_value(input, errors)?; Ok(Self::new(span, value)) } - fn parse_named_value(input: ParseStream, errors: &mut ErrorsCollection) -> Result { + fn parse_named_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { let span = input.span(); let value = ParseInputTokens::parse_named_value(input, errors)?; diff --git a/crates/codegen/language/definition/src/internals/write_output_tokens/external_types.rs b/crates/codegen/language/definition/src/internals/write_output_tokens/external_types.rs index b5f26c8af4..8f01ab5d99 100644 --- a/crates/codegen/language/definition/src/internals/write_output_tokens/external_types.rs +++ b/crates/codegen/language/definition/src/internals/write_output_tokens/external_types.rs @@ -3,7 +3,7 @@ use indexmap::{IndexMap, IndexSet}; use proc_macro2::{Literal, TokenStream}; use quote::{format_ident, quote}; use semver::Version; -use std::{ops::Deref, rc::Rc}; +use std::rc::Rc; impl WriteOutputTokens for bool { fn write_output_tokens(&self) -> TokenStream { @@ -17,7 +17,7 @@ impl WriteOutputTokens for bool { impl WriteOutputTokens for Box { fn write_output_tokens(&self) -> TokenStream { - let value = self.deref().write_output_tokens(); + let value = self.as_ref().write_output_tokens(); quote! { #value.into() @@ -37,8 +37,8 @@ impl WriteOutputTokens for char { impl WriteOutputTokens for IndexMap { fn write_output_tokens(&self) -> TokenStream { - let keys = self.keys().map(|key| key.write_output_tokens()); - let values = self.values().map(|value| value.write_output_tokens()); + let keys = self.keys().map(K::write_output_tokens); + let values = self.values().map(V::write_output_tokens); quote! { [ #( (#keys, #values) ),* ].into() @@ -48,7 +48,7 @@ impl WriteOutputTokens for IndexMap< impl WriteOutputTokens for IndexSet { fn write_output_tokens(&self) -> TokenStream { - let items = self.iter().map(|item| item.write_output_tokens()); + let items = self.iter().map(T::write_output_tokens); quote! { [ #( #items ),* ].into() @@ -77,7 +77,7 @@ impl WriteOutputTokens for Option { impl WriteOutputTokens for Rc { fn write_output_tokens(&self) -> TokenStream { - let value = self.deref().write_output_tokens(); + let value = self.as_ref().write_output_tokens(); quote! { #value.into() @@ -107,7 +107,7 @@ impl WriteOutputTokens for usize { impl WriteOutputTokens for Vec { fn write_output_tokens(&self) -> TokenStream { - let items = self.iter().map(|item| item.write_output_tokens()); + let items = self.iter().map(T::write_output_tokens); quote! { [ #( #items ),* ].into() diff --git a/crates/codegen/language/definition/src/model/manifest.rs b/crates/codegen/language/definition/src/model/manifest.rs index 004d221186..8e9d49cc16 100644 --- a/crates/codegen/language/definition/src/model/manifest.rs +++ b/crates/codegen/language/definition/src/model/manifest.rs @@ -43,7 +43,7 @@ impl Language { self.sections .iter() .flat_map(|section| &*section.topics) - .flat_map(|topic| topic.items.iter().map(AsRef::as_ref)) + .flat_map(|topic| topic.items.iter().map(Rc::as_ref)) } /// Returns a flattened iterator over items along with section and topic they belong to. diff --git a/crates/codegen/language/definition/src/model/terminals/keyword.rs b/crates/codegen/language/definition/src/model/terminals/keyword.rs index 6d066912a7..65567a0b5e 100644 --- a/crates/codegen/language/definition/src/model/terminals/keyword.rs +++ b/crates/codegen/language/definition/src/model/terminals/keyword.rs @@ -34,27 +34,20 @@ impl KeywordValue { /// Collects all possible variations generated by this value. pub fn collect_variations(&self) -> Vec { match self { - KeywordValue::Atom { atom } => { - vec![atom.to_owned()] - } + KeywordValue::Atom { atom } => vec![atom.to_owned()], KeywordValue::Optional { value } => { let mut results = value.collect_variations(); results.insert(0, String::new()); results } KeywordValue::Choice { values } => { - return values - .iter() - .flat_map(|value| value.collect_variations()) - .collect_vec(); + values.iter().flat_map(Self::collect_variations).collect() } + KeywordValue::Sequence { values } => { - let matrix = values - .iter() - .map(|value| value.collect_variations()) - .collect_vec(); + let matrix = values.iter().map(Self::collect_variations).collect_vec(); - let results_len = matrix.iter().map(|values| values.len()).product(); + let results_len = matrix.iter().map(Vec::len).product(); let mut results = (0..results_len).map(|_| String::new()).collect_vec(); let mut span = results_len; diff --git a/crates/codegen/language/definition/src/model/utils/identifier.rs b/crates/codegen/language/definition/src/model/utils/identifier.rs index 3d9353ebec..ee64f2ae5c 100644 --- a/crates/codegen/language/definition/src/model/utils/identifier.rs +++ b/crates/codegen/language/definition/src/model/utils/identifier.rs @@ -62,7 +62,7 @@ impl Serialize for Identifier { } impl ParseInputTokens for Identifier { - fn parse_value(input: ParseStream, _: &mut ErrorsCollection) -> Result { + fn parse_value(input: ParseStream<'_>, _: &mut ErrorsCollection) -> Result { let value = ParseHelpers::syn::(input)?.to_string(); Ok(value.into()) diff --git a/crates/codegen/language/internal_macros/src/derive/parse_input_tokens.rs b/crates/codegen/language/internal_macros/src/derive/parse_input_tokens.rs index e6bfa24bcc..cbfa3e27e3 100644 --- a/crates/codegen/language/internal_macros/src/derive/parse_input_tokens.rs +++ b/crates/codegen/language/internal_macros/src/derive/parse_input_tokens.rs @@ -5,16 +5,16 @@ use quote::quote; pub fn parse_input_tokens(item: InputItem) -> TokenStream { match item { - InputItem::Struct { name, fields } => derive_struct(name, &fields), - InputItem::Enum { name, variants } => derive_enum(name, &variants), + InputItem::Struct { name, fields } => derive_struct(&name, &fields), + InputItem::Enum { name, variants } => derive_enum(&name, &variants), } } -fn derive_struct(name: Ident, fields: &[InputField]) -> TokenStream { +fn derive_struct(name: &Ident, fields: &[InputField]) -> TokenStream { let stripped_name = Literal::string(&strip_spanned_prefix(name.to_string())); let unexpected_type_error = Literal::string(&format!("Expected type: {stripped_name}")); - let fields_return = derive_fields_return(quote!(Self), fields); + let fields_return = derive_fields_return("e!(Self), fields); quote! { impl crate::internals::ParseInputTokens for #name { @@ -44,13 +44,13 @@ fn derive_struct(name: Ident, fields: &[InputField]) -> TokenStream { } } -fn derive_enum(name: Ident, variants: &[InputVariant]) -> TokenStream { +fn derive_enum(name: &Ident, variants: &[InputVariant]) -> TokenStream { let match_arms = variants.iter().map(|variant| { let variant_ident = &variant.name; let variant_name = variant_ident.to_string(); if let Some(fields) = &variant.fields { - let fields_return = derive_fields_return(quote!(Self::#variant_ident), fields); + let fields_return = derive_fields_return("e!(Self::#variant_ident), fields); quote! { #variant_name => { @@ -98,7 +98,7 @@ fn derive_enum(name: Ident, variants: &[InputVariant]) -> TokenStream { } } -fn derive_fields_return(type_name: TokenStream, fields: &[InputField]) -> TokenStream { +fn derive_fields_return(type_name: &TokenStream, fields: &[InputField]) -> TokenStream { // When there is only one field, we omit the `key = ` part. // This way, we can just write `Foo(Bar)` instead of `Foo(key = Bar)`. let assignments = if let [single_field] = fields { diff --git a/crates/codegen/language/internal_macros/src/derive/spanned.rs b/crates/codegen/language/internal_macros/src/derive/spanned.rs index b0c7532d50..2b7376501c 100644 --- a/crates/codegen/language/internal_macros/src/derive/spanned.rs +++ b/crates/codegen/language/internal_macros/src/derive/spanned.rs @@ -14,7 +14,7 @@ pub fn spanned(item: InputItem, spanned_derive_args: TokenStream) -> TokenStream match item { InputItem::Struct { name, fields } => { - let name = format_ident!("{}", add_spanned_prefix(name.to_string())); + let name = format_ident!("{}", add_spanned_prefix(name)); let fields = fields.into_iter().map(derive_field); quote! { @@ -25,7 +25,7 @@ pub fn spanned(item: InputItem, spanned_derive_args: TokenStream) -> TokenStream } } InputItem::Enum { name, variants } => { - let name = format_ident!("{}", add_spanned_prefix(name.to_string())); + let name = format_ident!("{}", add_spanned_prefix(name)); let variants = variants.into_iter().map(derive_variant); quote! { diff --git a/crates/codegen/language/internal_macros/src/derive/write_output_tokens.rs b/crates/codegen/language/internal_macros/src/derive/write_output_tokens.rs index 39e8f13928..9937245818 100644 --- a/crates/codegen/language/internal_macros/src/derive/write_output_tokens.rs +++ b/crates/codegen/language/internal_macros/src/derive/write_output_tokens.rs @@ -5,12 +5,12 @@ use quote::{format_ident, quote}; pub fn write_output_tokens(item: InputItem) -> TokenStream { match item { - InputItem::Struct { name, fields } => derive_struct(name, &fields), - InputItem::Enum { name, variants } => derive_enum(name, &variants), + InputItem::Struct { name, fields } => derive_struct(&name, &fields), + InputItem::Enum { name, variants } => derive_enum(&name, &variants), } } -fn derive_struct(name: Ident, fields: &[InputField]) -> TokenStream { +fn derive_struct(name: &Ident, fields: &[InputField]) -> TokenStream { let stripped_name = format_ident!("{}", strip_spanned_prefix(name.to_string())); let keys = fields.iter().map(|field| &field.name).collect_vec(); @@ -30,7 +30,7 @@ fn derive_struct(name: Ident, fields: &[InputField]) -> TokenStream { } } -fn derive_enum(name: Ident, variants: &[InputVariant]) -> TokenStream { +fn derive_enum(name: &Ident, variants: &[InputVariant]) -> TokenStream { let stripped_name = format_ident!("{}", strip_spanned_prefix(name.to_string())); let match_arms = variants.iter().map(|variant| { diff --git a/crates/codegen/language/internal_macros/src/input_model.rs b/crates/codegen/language/internal_macros/src/input_model.rs index 6e77b806e4..48720427f7 100644 --- a/crates/codegen/language/internal_macros/src/input_model.rs +++ b/crates/codegen/language/internal_macros/src/input_model.rs @@ -18,7 +18,7 @@ pub enum InputItem { } impl Parse for InputItem { - fn parse(input: ParseStream) -> Result { + fn parse(input: ParseStream<'_>) -> Result { let input = DeriveInput::parse(input)?; Self::from_syn(input) @@ -90,15 +90,15 @@ impl InputField { } } -pub fn add_spanned_prefix(input: String) -> String { +pub fn add_spanned_prefix(input: impl Display) -> String { format!("Spanned{input}") } pub fn strip_spanned_prefix(input: String) -> String { - return match input.strip_prefix("Spanned") { + match input.strip_prefix("Spanned") { Some(suffix) if !suffix.is_empty() => suffix.to_owned(), _ => input, - }; + } } fn error(spanned: impl ToTokens, message: impl Display) -> Result { diff --git a/crates/codegen/language/tests/src/fail/mod.rs b/crates/codegen/language/tests/src/fail/mod.rs index cd8accb7bc..e5156a88ac 100644 --- a/crates/codegen/language/tests/src/fail/mod.rs +++ b/crates/codegen/language/tests/src/fail/mod.rs @@ -1,6 +1,6 @@ /// These test cases are not actually part of this compilation, so they are not imported via 'mod' declarations here. /// Instead, they are individually picked up during runtime, and each is compiled separately, checking any errors they produce. -/// For more info: https://crates.io/crates/trybuild +/// For more info: use infra_utils::{cargo::CargoWorkspace, github::GitHub, paths::FileWalker}; use rayon::prelude::*; diff --git a/crates/codegen/parser/generator/src/code_generator.rs b/crates/codegen/parser/generator/src/code_generator.rs index 053b8808ea..0ea95c30d3 100644 --- a/crates/codegen/parser/generator/src/code_generator.rs +++ b/crates/codegen/parser/generator/src/code_generator.rs @@ -144,11 +144,11 @@ impl CodeGenerator { .entry(name) .or_insert_with(|| ScannerContext { name, - scanner_definitions: Default::default(), - alpha_literal_scanner: "".to_string(), - non_alpha_literal_scanner: "".to_string(), + scanner_definitions: BTreeSet::default(), + alpha_literal_scanner: String::new(), + non_alpha_literal_scanner: String::new(), compound_scanner_names: vec![], - delimiters: Default::default(), + delimiters: BTreeMap::default(), }); } } @@ -228,7 +228,7 @@ impl GrammarVisitor for CodeGenerator { quote! { #code.with_kind(RuleKind::#rule_kind) } } .to_string(), - )) + )); } fn parser_definition_enter(&mut self, parser: &ParserDefinitionRef) { @@ -264,7 +264,7 @@ impl GrammarVisitor for CodeGenerator { quote! { #code.with_kind(RuleKind::#rule_kind) } } .to_string(), - )) + )); } fn scanner_definition_node_enter(&mut self, node: &ScannerDefinitionNode) { @@ -307,9 +307,10 @@ impl GrammarVisitor for CodeGenerator { .unwrap() .delimiters; - if delimiters.get(close).is_some() { - panic!("Cannot use a closing delimiter as an opening one"); - } + assert!( + delimiters.get(close).is_none(), + "Cannot use a closing delimiter as an opening one" + ); delimiters.insert(open, close); } _ => {} diff --git a/crates/codegen/parser/generator/src/parser_definition.rs b/crates/codegen/parser/generator/src/parser_definition.rs index 40eea95993..8fd5fd02f0 100644 --- a/crates/codegen/parser/generator/src/parser_definition.rs +++ b/crates/codegen/parser/generator/src/parser_definition.rs @@ -32,6 +32,7 @@ pub trait ParserDefinitionNodeExtensions { } impl ParserDefinitionNodeExtensions for ParserDefinitionNode { + #[allow(clippy::too_many_lines)] // giant switch over parser definition node types fn to_parser_code(&self, context_name: &'static str, is_trivia: bool) -> TokenStream { let context = format_ident!("{context_name}"); let lex_ctx = quote! { LexicalContextType::#context }; diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index e93c07b89b..d97e68e3f9 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -71,6 +71,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode // The second pass is in the method `PrecedenceHelper::reduce_precedence_result` because it // is independent of the grammar. + #[allow(clippy::too_many_lines)] // Repetition-heavy with 4 kinds of precedence operators fn to_parser_code( &self, context_name: &'static str, @@ -86,7 +87,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode let mut operator_closures = Vec::new(); let mut binding_power = 1u8; - for (version_quality_ranges, model, name, operator_definition) in self.operators.iter() { + for (version_quality_ranges, model, name, operator_definition) in &self.operators { let operator_code = operator_definition .node() .to_parser_code(context_name, false); @@ -106,7 +107,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode match model { PrecedenceOperatorModel::BinaryLeftAssociative => { operator_closures.push(quote! { - let #closure_name = |input: &mut ParserContext| + let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_binary_operator( RuleKind::#rule_kind, #binding_power, @@ -118,7 +119,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode } PrecedenceOperatorModel::BinaryRightAssociative => { operator_closures.push(quote! { - let #closure_name = |input: &mut ParserContext| + let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_binary_operator( RuleKind::#rule_kind, #binding_power + 1, @@ -130,7 +131,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode } PrecedenceOperatorModel::Prefix => { operator_closures.push(quote! { - let #closure_name = |input: &mut ParserContext| + let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_prefix_operator( RuleKind::#rule_kind, #binding_power, @@ -141,7 +142,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode } PrecedenceOperatorModel::Postfix => { operator_closures.push(quote! { - let #closure_name = |input: &mut ParserContext| + let #closure_name = |input: &mut ParserContext<'_>| PrecedenceHelper::to_postfix_operator( RuleKind::#rule_kind, #binding_power, @@ -158,9 +159,10 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode // TODO: merge these three functions into parse_definition by changing // `to_parser_code` to use `(TokenStream, Vec)` as // the core type i.e. the `OperatorParser` type above + #[allow(clippy::items_after_statements)] fn make_sequence(parsers: Vec) -> TokenStream { let parsers = parsers - .iter() + .into_iter() .map(|parser| quote! { seq.elem(#parser)?; }) .collect::>(); quote! { @@ -171,9 +173,10 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode } } + #[allow(clippy::items_after_statements)] fn make_choice(parsers: Vec) -> TokenStream { let parsers = parsers - .iter() + .into_iter() .map(|(parser, version_quality_ranges)| { version_quality_ranges.wrap_code( quote! { @@ -196,19 +199,19 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode if !prefix_operator_parsers.is_empty() { let prefix_operator_parser = make_choice(prefix_operator_parsers); - operator_closures.push(quote! { let prefix_operator_parser = |input: &mut ParserContext| #prefix_operator_parser; }); + operator_closures.push(quote! { let prefix_operator_parser = |input: &mut ParserContext<'_>| #prefix_operator_parser; }); binary_operand_terms.push( quote! { ZeroOrMoreHelper::run(input, |input| prefix_operator_parser(input)) }, ); } let primary_expression_parser = self.primary_expression.to_parser_code(context_name, false); - operator_closures.push(quote! { let primary_expression_parser = |input: &mut ParserContext| #primary_expression_parser; }); + operator_closures.push(quote! { let primary_expression_parser = |input: &mut ParserContext<'_>| #primary_expression_parser; }); binary_operand_terms.push(quote! { primary_expression_parser(input) }); if !postfix_operator_parsers.is_empty() { let postfix_operator_parser = make_choice(postfix_operator_parsers); - operator_closures.push(quote! { let postfix_operator_parser = |input: &mut ParserContext| #postfix_operator_parser; }); + operator_closures.push(quote! { let postfix_operator_parser = |input: &mut ParserContext<'_>| #postfix_operator_parser; }); binary_operand_terms.push( quote! { ZeroOrMoreHelper::run(input, |input| postfix_operator_parser(input)) }, ); @@ -217,12 +220,12 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode let binary_operand_parser = make_sequence(binary_operand_terms); if binary_operator_parsers.is_empty() { - operator_closures.push(quote! { let linear_expression_parser = |input: &mut ParserContext| #binary_operand_parser; }); + operator_closures.push(quote! { let linear_expression_parser = |input: &mut ParserContext<'_>| #binary_operand_parser; }); } else { - operator_closures.push(quote! { let binary_operand_parser = |input: &mut ParserContext| #binary_operand_parser; }); + operator_closures.push(quote! { let binary_operand_parser = |input: &mut ParserContext<'_>| #binary_operand_parser; }); let binary_operator_parser = make_choice(binary_operator_parsers); - operator_closures.push(quote! { let binary_operator_parser = |input: &mut ParserContext| #binary_operator_parser; }); + operator_closures.push(quote! { let binary_operator_parser = |input: &mut ParserContext<'_>| #binary_operator_parser; }); let linear_expression_parser = make_sequence(vec![quote! { binary_operand_parser(input) }, { @@ -233,7 +236,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode quote! { ZeroOrMoreHelper::run(input, |input| #pairs) } }]); operator_closures - .push(quote! { let linear_expression_parser = |input: &mut ParserContext| #linear_expression_parser; }); + .push(quote! { let linear_expression_parser = |input: &mut ParserContext<'_>| #linear_expression_parser; }); } let expression_kind_literal = if let Some(kind) = expression_kind { diff --git a/crates/codegen/parser/generator/src/scanner_definition.rs b/crates/codegen/parser/generator/src/scanner_definition.rs index 324c73792d..831ee85e38 100644 --- a/crates/codegen/parser/generator/src/scanner_definition.rs +++ b/crates/codegen/parser/generator/src/scanner_definition.rs @@ -95,7 +95,7 @@ impl ScannerDefinitionNodeExtensions for ScannerDefinitionNode { if let ScannerDefinitionNode::Literal(string) = node { scanners.push(string); } else { - non_literal_scanners.push(node.to_scanner_code()) + non_literal_scanners.push(node.to_scanner_code()); } } scanners.sort(); diff --git a/crates/codegen/parser/runtime/src/cst.rs b/crates/codegen/parser/runtime/src/cst.rs index c8f9a650b0..75bae67260 100644 --- a/crates/codegen/parser/runtime/src/cst.rs +++ b/crates/codegen/parser/runtime/src/cst.rs @@ -73,29 +73,29 @@ impl Node { pub fn as_rule(&self) -> Option<&Rc> { match self { - Self::Rule(node) => Some(node), - _ => None, + Self::Rule(rule) => Some(rule), + Self::Token(..) => None, } } pub fn into_rule(self) -> Option> { match self { - Self::Rule(node) => Some(node), - _ => None, + Self::Rule(rule) => Some(rule), + Self::Token(..) => None, } } pub fn as_token(&self) -> Option<&Rc> { match self { - Self::Token(node) => Some(node), - _ => None, + Self::Token(token) => Some(token), + Self::Rule(..) => None, } } pub fn into_token(self) -> Option> { match self { - Self::Token(node) => Some(node), - _ => None, + Self::Token(token) => Some(token), + Self::Rule(..) => None, } } diff --git a/crates/codegen/parser/runtime/src/cursor.rs b/crates/codegen/parser/runtime/src/cursor.rs index 62d3f176ed..e8f92483fd 100644 --- a/crates/codegen/parser/runtime/src/cursor.rs +++ b/crates/codegen/parser/runtime/src/cursor.rs @@ -116,6 +116,7 @@ impl Cursor { /// Unlike `clone`, this re-roots at the current node. /// It does preserve the correct text offset however, /// even though the path is reset. + #[must_use] pub fn spawn(&self) -> Self { Self { path: vec![], @@ -205,17 +206,14 @@ impl Cursor { /// /// Returns `false` if the cursor is finished and at the root. pub fn go_to_parent(&mut self) -> bool { - match self.path.pop() { - Some(parent) => { - self.current = parent.into_path_node(); + if let Some(parent) = self.path.pop() { + self.current = parent.into_path_node(); - true - } - None => { - self.is_completed = true; + true + } else { + self.is_completed = true; - false - } + false } } @@ -290,7 +288,7 @@ impl Cursor { let text_offset = parent.text_offset + parent.rule_node.children[..child_number] .iter() - .map(|child| child.text_len()) + .map(Node::text_len) .sum(); self.path.push(parent); diff --git a/crates/codegen/parser/runtime/src/lexer.rs b/crates/codegen/parser/runtime/src/lexer.rs index 38cbd7fd55..923249f213 100644 --- a/crates/codegen/parser/runtime/src/lexer.rs +++ b/crates/codegen/parser/runtime/src/lexer.rs @@ -7,18 +7,24 @@ use crate::{ pub trait Lexer { // Generated by the templating engine #[doc(hidden)] - fn next_token(&self, input: &mut ParserContext) -> Option; + fn next_token( + &self, + input: &mut ParserContext<'_>, + ) -> Option; // NOTE: These are context-insensitive #[doc(hidden)] - fn leading_trivia(&self, input: &mut ParserContext) -> ParserResult; + fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; #[doc(hidden)] - fn trailing_trivia(&self, input: &mut ParserContext) -> ParserResult; + fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; #[doc(hidden)] /// Returns valid grouping delimiters in the given lexical context. fn delimiters() -> &'static [(TokenKind, TokenKind)]; /// Peeks the next token, including trivia. Does not advance the input. - fn peek_token(&self, input: &mut ParserContext) -> Option { + fn peek_token( + &self, + input: &mut ParserContext<'_>, + ) -> Option { let start = input.position(); let token = self.next_token::(input); input.set_position(start); @@ -28,7 +34,7 @@ pub trait Lexer { /// Peeks the next significant (i.e. non-trivia) token. Does not advance the input. fn peek_token_with_trivia( &self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, ) -> Option { let start = input.position(); @@ -42,7 +48,7 @@ pub trait Lexer { /// Attempts to consume the next expected token. Advances the input only if the token matches. fn parse_token( &self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, kind: TokenKind, ) -> ParserResult { let start = input.position(); @@ -62,7 +68,7 @@ pub trait Lexer { /// Advances the input only if the token matches. fn parse_token_with_trivia( &self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, kind: TokenKind, ) -> ParserResult { let mut children = vec![]; diff --git a/crates/codegen/parser/runtime/src/napi/napi_cursor.rs b/crates/codegen/parser/runtime/src/napi/napi_cursor.rs index f2b224a4d1..e621260b67 100644 --- a/crates/codegen/parser/runtime/src/napi/napi_cursor.rs +++ b/crates/codegen/parser/runtime/src/napi/napi_cursor.rs @@ -1,3 +1,8 @@ +// NAPI-exposed functions have to accept owned values +#![allow(clippy::needless_pass_by_value)] +// The functions are meant to be definitions for export, so they're not really used +#![allow(clippy::return_self_not_must_use)] + use { napi::{bindgen_prelude::Env, JsObject}, napi_derive::napi, @@ -24,12 +29,12 @@ impl Cursor { #[napi] pub fn reset(&mut self) { - self.0.reset() + self.0.reset(); } #[napi] pub fn complete(&mut self) { - self.0.complete() + self.0.complete(); } #[napi] @@ -63,6 +68,7 @@ impl Cursor { (&self.0.text_range()).into() } + #[allow(clippy::cast_possible_truncation)] // Cursor depth can't reasonably be larger than u32 #[napi(getter)] pub fn depth(&self) -> u32 { self.0.depth() as u32 diff --git a/crates/codegen/parser/runtime/src/napi/napi_parse_error.rs b/crates/codegen/parser/runtime/src/napi/napi_parse_error.rs index 379ea7f622..349250ae5f 100644 --- a/crates/codegen/parser/runtime/src/napi/napi_parse_error.rs +++ b/crates/codegen/parser/runtime/src/napi/napi_parse_error.rs @@ -1,3 +1,6 @@ +// NAPI-exposed functions have to accept owned values. +#![allow(clippy::needless_pass_by_value)] + use napi_derive::napi; use super::{napi_text_index, RustParseError}; @@ -21,11 +24,7 @@ impl ParseError { } pub fn tokens_that_would_have_allowed_more_progress(&self) -> Vec { - self.0 - .tokens_that_would_have_allowed_more_progress() - .iter() - .map(|x| x.to_string()) - .collect() + self.0.tokens_that_would_have_allowed_more_progress() } #[napi(namespace = "parse_error")] diff --git a/crates/codegen/parser/runtime/src/napi/napi_text_index.rs b/crates/codegen/parser/runtime/src/napi/napi_text_index.rs index a08d0a0503..ab45af8221 100644 --- a/crates/codegen/parser/runtime/src/napi/napi_text_index.rs +++ b/crates/codegen/parser/runtime/src/napi/napi_text_index.rs @@ -12,6 +12,8 @@ pub struct TextIndex { impl From<&RustTextIndex> for TextIndex { fn from(value: &RustTextIndex) -> Self { + // We only support 32-byte indices on TS side. + #[allow(clippy::cast_possible_truncation)] Self { utf8: value.utf8 as u32, utf16: value.utf16 as u32, diff --git a/crates/codegen/parser/runtime/src/parse_error.rs b/crates/codegen/parser/runtime/src/parse_error.rs index 49481fc541..9612eaf0e4 100644 --- a/crates/codegen/parser/runtime/src/parse_error.rs +++ b/crates/codegen/parser/runtime/src/parse_error.rs @@ -20,12 +20,11 @@ impl ParseError { let tokens_that_would_have_allowed_more_progress = self .tokens_that_would_have_allowed_more_progress .iter() - .map(|kind| kind.as_ref()) .collect::>(); tokens_that_would_have_allowed_more_progress .into_iter() - .map(|token| token.to_string()) + .map(TokenKind::to_string) .collect() } diff --git a/crates/codegen/parser/runtime/src/support/choice_helper.rs b/crates/codegen/parser/runtime/src/support/choice_helper.rs index d9b3a7fb59..2b4c9a1882 100644 --- a/crates/codegen/parser/runtime/src/support/choice_helper.rs +++ b/crates/codegen/parser/runtime/src/support/choice_helper.rs @@ -18,7 +18,7 @@ pub struct ChoiceHelper { } impl ChoiceHelper { - pub fn new(input: &mut ParserContext) -> Self { + pub fn new(input: &mut ParserContext<'_>) -> Self { Self { result: ParserResult::no_match(vec![]), start_position: input.mark(), @@ -37,7 +37,7 @@ impl ChoiceHelper { } /// Store the next result if it's a better match; otherwise, we retain the existing one. - fn attempt_pick(&mut self, input: &mut ParserContext, next_result: ParserResult) { + fn attempt_pick(&mut self, input: &mut ParserContext<'_>, next_result: ParserResult) { let better_pick = match (&mut self.result, &next_result) { // We settle for the first full match. (ParserResult::Match(running), _) if running.is_full_recursive() => { @@ -54,10 +54,8 @@ impl ChoiceHelper { running.expected_tokens.extend(next.expected_tokens.clone()); false } - // Otherwise, we have some match and we ignore a missing next one. - (ParserResult::IncompleteMatch(..), ParserResult::NoMatch(..)) - | (ParserResult::SkippedUntil(..), ParserResult::NoMatch(..)) - | (ParserResult::Match(..), ParserResult::NoMatch(..)) => false, + // Otherwise, we already have some match, so we ignore a next missing one. + (_, ParserResult::NoMatch(..)) => false, // Try to improve our match. (_, ParserResult::Match(next)) if next.is_full_recursive() => true, @@ -80,8 +78,8 @@ impl ChoiceHelper { /// /// Useful when you want to eagerly return a result from the parse function (e.g. when the choice was fully matched). pub fn run( - input: &mut ParserContext, - f: impl FnOnce(Self, &mut ParserContext) -> ControlFlow, + input: &mut ParserContext<'_>, + f: impl FnOnce(Self, &mut ParserContext<'_>) -> ControlFlow, ) -> ParserResult { match f(ChoiceHelper::new(input), input) { ControlFlow::Break(result) => result, @@ -96,7 +94,7 @@ impl ChoiceHelper { /// If a value is considered as a full match, it is returned, otherwise we backtrack and continue. pub fn consider( &mut self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, value: ParserResult, ) -> ControlFlow { self.attempt_pick(input, value); @@ -110,7 +108,7 @@ impl ChoiceHelper { } /// Finishes the choice parse, returning the accumulated match. - pub fn finish(self, input: &mut ParserContext) -> ControlFlow { + pub fn finish(self, input: &mut ParserContext<'_>) -> ControlFlow { assert!(!self.is_done()); // We didn't break early, so undo the rewind that has happened in the meantime. input.set_position(self.last_progress); diff --git a/crates/codegen/parser/runtime/src/support/context.rs b/crates/codegen/parser/runtime/src/support/context.rs index cedd466d96..f81d17805b 100644 --- a/crates/codegen/parser/runtime/src/support/context.rs +++ b/crates/codegen/parser/runtime/src/support/context.rs @@ -30,7 +30,7 @@ impl<'s> ParserContext<'s> { pub fn new(source: &'s str) -> Self { Self { source, - position: Default::default(), + position: TextIndex::ZERO, undo_position: None, errors: vec![], closing_delimiters: vec![], diff --git a/crates/codegen/parser/runtime/src/support/parser_function.rs b/crates/codegen/parser/runtime/src/support/parser_function.rs index 8580200912..5c2a72c9bd 100644 --- a/crates/codegen/parser/runtime/src/support/parser_function.rs +++ b/crates/codegen/parser/runtime/src/support/parser_function.rs @@ -11,14 +11,14 @@ use super::{ pub trait ParserFunction where - Self: Fn(&L, &mut ParserContext) -> ParserResult, + Self: Fn(&L, &mut ParserContext<'_>) -> ParserResult, { fn parse(&self, language: &L, input: &str) -> ParseOutput; } impl ParserFunction for F where - F: Fn(&L, &mut ParserContext) -> ParserResult, + F: Fn(&L, &mut ParserContext<'_>) -> ParserResult, { fn parse(&self, language: &L, input: &str) -> ParseOutput { let mut stream = ParserContext::new(input); @@ -33,7 +33,7 @@ where ParserResult::NoMatch(no_match) => ParseOutput { parse_tree: cst::Node::token(TokenKind::SKIPPED, input.to_string()), errors: vec![ParseError::new_covering_range( - Default::default()..input.into(), + TextIndex::ZERO..input.into(), no_match.expected_tokens, )], }, diff --git a/crates/codegen/parser/runtime/src/support/parser_result.rs b/crates/codegen/parser/runtime/src/support/parser_result.rs index 7bc5159651..0d29c13dd4 100644 --- a/crates/codegen/parser/runtime/src/support/parser_result.rs +++ b/crates/codegen/parser/runtime/src/support/parser_result.rs @@ -54,6 +54,7 @@ impl ParserResult { matches!(self, ParserResult::NoMatch(_)) } + #[must_use] pub fn with_kind(self, new_kind: RuleKind) -> ParserResult { match self { ParserResult::Match(r#match) => ParserResult::r#match( diff --git a/crates/codegen/parser/runtime/src/support/precedence_helper.rs b/crates/codegen/parser/runtime/src/support/precedence_helper.rs index 3f93fc2bda..bc93d2e7d8 100644 --- a/crates/codegen/parser/runtime/src/support/precedence_helper.rs +++ b/crates/codegen/parser/runtime/src/support/precedence_helper.rs @@ -2,7 +2,7 @@ use super::{ super::{cst, kinds::RuleKind}, parser_result::{ ParserResult, - PrattElement::{self, *}, + PrattElement::{self, Binary, Expression, Postfix, Prefix}, }, }; @@ -56,6 +56,8 @@ impl PrecedenceHelper { _ => result, } } + + #[allow(clippy::too_many_lines)] // Explicit on purpose, see below. pub fn reduce_precedence_result( child_kind: Option, result: ParserResult, @@ -67,6 +69,7 @@ impl PrecedenceHelper { // If the input is valid this should be correct by construction. + #[allow(clippy::redundant_else)] match result { ParserResult::PrattOperatorMatch(pratt_operator_match) => { let mut pratt_elements = pratt_operator_match.elements; diff --git a/crates/codegen/parser/runtime/src/support/recovery.rs b/crates/codegen/parser/runtime/src/support/recovery.rs index b39bf10716..66e3f50ccc 100644 --- a/crates/codegen/parser/runtime/src/support/recovery.rs +++ b/crates/codegen/parser/runtime/src/support/recovery.rs @@ -9,20 +9,21 @@ use super::parser_result::SkippedUntil; use super::ParserContext; /// An explicit parameter for the [`ParserResult::recover_until_with_nested_delims`] method. +#[derive(Clone, Copy)] pub enum RecoverFromNoMatch { Yes, No, } impl RecoverFromNoMatch { - pub fn as_bool(&self) -> bool { + pub fn as_bool(self) -> bool { matches!(self, RecoverFromNoMatch::Yes) } } fn opt_parse( - input: &mut ParserContext, - parse: impl Fn(&mut ParserContext) -> ParserResult, + input: &mut ParserContext<'_>, + parse: impl Fn(&mut ParserContext<'_>) -> ParserResult, ) -> Vec { let start = input.position(); if let ParserResult::Match(r#match) = parse(input) { @@ -40,21 +41,22 @@ impl ParserResult { /// /// Respects nested delimiters, i.e. the `expected` token is only accepted if it's not nested inside. /// Does not consume the `expected` token. + #[must_use] pub fn recover_until_with_nested_delims( self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, lexer: &L, expected: TokenKind, recover_from_no_match: RecoverFromNoMatch, ) -> ParserResult { - let before_recovery = input.position(); - enum ParseResultKind { Match, Incomplete, NoMatch, } + let before_recovery = input.position(); + let (mut nodes, mut expected_tokens, result_kind) = match self { ParserResult::IncompleteMatch(result) => ( result.nodes, @@ -75,38 +77,37 @@ impl ParserResult { let leading_trivia = opt_parse(input, |input| lexer.leading_trivia(input)); - match skip_until_with_nested_delims::<_, LexCtx>(input, lexer, expected) { - Some((found, skipped_range)) => { - nodes.extend(leading_trivia); - if matches!(result_kind, ParseResultKind::Match) { - expected_tokens.push(expected); - } + if let Some((found, skipped_range)) = + skip_until_with_nested_delims::<_, LexCtx>(input, lexer, expected) + { + nodes.extend(leading_trivia); + if matches!(result_kind, ParseResultKind::Match) { + expected_tokens.push(expected); + } - let skipped = input.content(skipped_range.utf8()); + let skipped = input.content(skipped_range.utf8()); - input.emit(ParseError { - text_range: skipped_range, - tokens_that_would_have_allowed_more_progress: expected_tokens.clone(), - }); + input.emit(ParseError { + text_range: skipped_range, + tokens_that_would_have_allowed_more_progress: expected_tokens.clone(), + }); - ParserResult::SkippedUntil(SkippedUntil { - nodes, - expected, - skipped, - found, - }) - } + ParserResult::SkippedUntil(SkippedUntil { + nodes, + skipped, + found, + expected, + }) + } else { // Not found till EOF, revert any recovery attempt - None => { - input.set_position(before_recovery); - - match result_kind { - ParseResultKind::Match => ParserResult::r#match(nodes, expected_tokens), - ParseResultKind::Incomplete => { - ParserResult::incomplete_match(nodes, expected_tokens) - } - ParseResultKind::NoMatch => ParserResult::no_match(expected_tokens), + input.set_position(before_recovery); + + match result_kind { + ParseResultKind::Match => ParserResult::r#match(nodes, expected_tokens), + ParseResultKind::Incomplete => { + ParserResult::incomplete_match(nodes, expected_tokens) } + ParseResultKind::NoMatch => ParserResult::no_match(expected_tokens), } } } @@ -118,7 +119,7 @@ impl ParserResult { /// /// Returns the found token and the range of skipped tokens on success. pub fn skip_until_with_nested_delims( - input: &mut ParserContext, + input: &mut ParserContext<'_>, lexer: &L, until: TokenKind, ) -> Option<(TokenKind, TextRange)> { diff --git a/crates/codegen/parser/runtime/src/support/repetition_helper.rs b/crates/codegen/parser/runtime/src/support/repetition_helper.rs index ab81d99424..b5072e72cd 100644 --- a/crates/codegen/parser/runtime/src/support/repetition_helper.rs +++ b/crates/codegen/parser/runtime/src/support/repetition_helper.rs @@ -9,8 +9,8 @@ pub type ZeroOrMoreHelper = RepetitionHelper<0>; pub type OneOrMoreHelper = RepetitionHelper<1>; impl RepetitionHelper { - pub fn run ParserResult>( - input: &mut ParserContext, + pub fn run) -> ParserResult>( + input: &mut ParserContext<'_>, parser: F, ) -> ParserResult { if MIN_COUNT > 1 { @@ -26,9 +26,7 @@ impl RepetitionHelper { // Couldn't get a full match but we allow 0 items - return an empty match // so the parse is considered valid but note the expected tokens - ParserResult::NoMatch(NoMatch { - expected_tokens, .. - }) if MIN_COUNT == 0 => { + ParserResult::NoMatch(NoMatch { expected_tokens }) if MIN_COUNT == 0 => { return ParserResult::r#match(vec![], expected_tokens); } // Don't try repeating if we don't have a full match and we require at least one @@ -84,7 +82,9 @@ impl RepetitionHelper { return ParserResult::SkippedUntil(skipped); } - (ParserResult::PrattOperatorMatch(..), ParserResult::SkippedUntil(_)) => todo!(), + (ParserResult::PrattOperatorMatch(..), ParserResult::SkippedUntil(_)) => { + unreachable!("We don't do recovery when reducing the Pratt matches") + } ( ParserResult::IncompleteMatch(..) diff --git a/crates/codegen/parser/runtime/src/support/scanner_macros.rs b/crates/codegen/parser/runtime/src/support/scanner_macros.rs index be45a7e28c..b35b5694d9 100644 --- a/crates/codegen/parser/runtime/src/support/scanner_macros.rs +++ b/crates/codegen/parser/runtime/src/support/scanner_macros.rs @@ -83,6 +83,7 @@ macro_rules! scan_zero_or_more { macro_rules! scan_one_or_more { ($stream:ident, $scanner:expr) => {{ let mut count = 0; + #[allow(clippy::redundant_else)] loop { let save = $stream.position(); if !($scanner) { diff --git a/crates/codegen/parser/runtime/src/support/separated_helper.rs b/crates/codegen/parser/runtime/src/support/separated_helper.rs index 329acef303..14d4d52ed9 100644 --- a/crates/codegen/parser/runtime/src/support/separated_helper.rs +++ b/crates/codegen/parser/runtime/src/support/separated_helper.rs @@ -15,9 +15,9 @@ pub struct SeparatedHelper; impl SeparatedHelper { pub fn run( - input: &mut ParserContext, + input: &mut ParserContext<'_>, lexer: &L, - body_parser: impl Fn(&mut ParserContext) -> ParserResult, + body_parser: impl Fn(&mut ParserContext<'_>) -> ParserResult, separator: TokenKind, ) -> ParserResult { let mut accum = vec![]; @@ -86,11 +86,11 @@ impl SeparatedHelper { } } ParserResult::NoMatch(no_match) => { - if accum.is_empty() { - return ParserResult::no_match(no_match.expected_tokens); + return if accum.is_empty() { + ParserResult::no_match(no_match.expected_tokens) } else { - return ParserResult::incomplete_match(accum, no_match.expected_tokens); - } + ParserResult::incomplete_match(accum, no_match.expected_tokens) + }; } ParserResult::SkippedUntil(skipped) => { diff --git a/crates/codegen/parser/runtime/src/support/sequence_helper.rs b/crates/codegen/parser/runtime/src/support/sequence_helper.rs index ac13d04891..f2d2867e0a 100644 --- a/crates/codegen/parser/runtime/src/support/sequence_helper.rs +++ b/crates/codegen/parser/runtime/src/support/sequence_helper.rs @@ -33,6 +33,7 @@ impl SequenceHelper { ) } + #[allow(clippy::too_many_lines)] // Big switch that purely defines the sequence logic /// Attempts to append the next result until we hit an incomplete/no match. fn attempt_append(&mut self, next_result: ParserResult) { match self.result { @@ -93,7 +94,7 @@ impl SequenceHelper { self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut cur.elements) .into_iter() - .flat_map(|pratt| pratt.into_nodes()) + .flat_map(PrattElement::into_nodes) .chain(next.nodes) .collect(), next.expected_tokens, @@ -103,7 +104,7 @@ impl SequenceHelper { self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut cur.elements) .into_iter() - .flat_map(|pratt| pratt.into_nodes()) + .flat_map(PrattElement::into_nodes) .collect(), next.expected_tokens, )); diff --git a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 index 98781008b1..9615655d9b 100644 --- a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 +++ b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 @@ -1,3 +1,6 @@ +// This file is generated; we can't reasonably satisfy some of these lints. +#![allow(clippy::if_not_else, clippy::too_many_lines, clippy::unused_self, clippy::struct_excessive_bools, clippy::similar_names)] + #[cfg(feature = "slang_napi_interfaces")] use {napi::bindgen_prelude::*, napi_derive::napi}; @@ -74,7 +77,7 @@ impl Language { {% for function in code.parser_functions %} #[allow(unused_assignments, unused_parens)] - fn {{ function.0 | snake_case }}(&self, input: &mut ParserContext) -> ParserResult { {{ function.1 }} } + fn {{ function.0 | snake_case }}(&self, input: &mut ParserContext<'_>) -> ParserResult { {{ function.1 }} } {% endfor %} /******************************************** @@ -83,7 +86,7 @@ impl Language { {% for function in code.scanner_functions %} #[allow(unused_assignments, unused_parens)] - fn {{ function.0 | snake_case }}(&self, input: &mut ParserContext) -> bool { {{ function.1 }} } + fn {{ function.0 | snake_case }}(&self, input: &mut ParserContext<'_>) -> bool { {{ function.1 }} } {% endfor %} pub fn scan(&self, lexical_context: LexicalContext, input: &str) -> Option { @@ -106,11 +109,11 @@ impl Language { } impl Lexer for Language { - fn leading_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { Language::leading_trivia(self, input) } - fn trailing_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { Language::trailing_trivia(self, input) } @@ -126,7 +129,7 @@ impl Lexer for Language { } } - fn next_token(&self, input: &mut ParserContext) -> Option { + fn next_token(&self, input: &mut ParserContext<'_>) -> Option { let save = input.position(); let mut furthest_position = input.position(); let mut longest_token = None; @@ -188,6 +191,8 @@ impl Lexer for Language { } #[cfg(feature = "slang_napi_interfaces")] +// NAPI-exposed functions have to accept owned values. +#[allow(clippy::needless_pass_by_value)] #[napi(namespace = "language")] impl Language { @@ -214,7 +219,7 @@ impl Language { #[napi(js_name = "parse", ts_return_type = "parse_output.ParseOutput")] pub fn parse_napi( - &self, + &self, #[napi(ts_arg_type = "kinds.ProductionKind")] production_kind: ProductionKind, input: String ) -> NAPIParseOutput { diff --git a/crates/codegen/schema/src/validation/rules/definitions/keywords/collector.rs b/crates/codegen/schema/src/validation/rules/definitions/keywords/collector.rs index 021134a05d..2a304e332e 100644 --- a/crates/codegen/schema/src/validation/rules/definitions/keywords/collector.rs +++ b/crates/codegen/schema/src/validation/rules/definitions/keywords/collector.rs @@ -52,16 +52,11 @@ impl Visitor for KeywordsCollector { location: &LocationRef, reporter: &mut Reporter, ) -> bool { - let identifier = - if let ScannerDefinition::TrailingContext { scanner, .. } = &scanner.definition { - scanner - } else { - return true; - }; + let ScannerDefinition::TrailingContext { scanner, .. } = &scanner.definition else { + return true; + }; - let variations = if let Some(variations) = Self::collect_variations(identifier) { - variations - } else { + let Some(variations) = Self::collect_variations(scanner) else { return false; }; @@ -107,7 +102,7 @@ impl KeywordsCollector { ScannerDefinition::Difference { minuend, .. } => Self::collect_variations(minuend), ScannerDefinition::Optional(child) => { let mut variations = Self::collect_variations(child)?; - variations.push("".to_owned()); + variations.push(String::new()); Some(variations) } ScannerDefinition::Range { from, to } => { diff --git a/crates/codegen/schema/src/validation/rules/definitions/operators/mod.rs b/crates/codegen/schema/src/validation/rules/definitions/operators/mod.rs index b7d7aca01d..66f784319e 100644 --- a/crates/codegen/schema/src/validation/rules/definitions/operators/mod.rs +++ b/crates/codegen/schema/src/validation/rules/definitions/operators/mod.rs @@ -59,7 +59,7 @@ impl Visitor for Operators { location: &LocationRef, reporter: &mut Reporter, ) -> bool { - for expression in parser.operator_expressions.iter() { + for expression in &parser.operator_expressions { let name = &expression.name; if self.language.productions.contains_key(name) { reporter.report(location, Errors::OperatorNamedAsProduction(name.to_owned())); diff --git a/crates/codegen/schema/src/validation/rules/definitions/versions/mod.rs b/crates/codegen/schema/src/validation/rules/definitions/versions/mod.rs index b74a8b2f22..4e59aa6401 100644 --- a/crates/codegen/schema/src/validation/rules/definitions/versions/mod.rs +++ b/crates/codegen/schema/src/validation/rules/definitions/versions/mod.rs @@ -45,9 +45,8 @@ impl Visitor for Versions { location: &LocationRef, reporter: &mut Reporter, ) -> bool { - let versions = match production.versions() { - Some(versions) => versions, - None => return false, + let Some(versions) = production.versions() else { + return false; }; if versions.is_empty() { diff --git a/crates/codegen/schema/src/validation/rules/references/validator.rs b/crates/codegen/schema/src/validation/rules/references/validator.rs index 89befbaa63..d03d397e9e 100644 --- a/crates/codegen/schema/src/validation/rules/references/validator.rs +++ b/crates/codegen/schema/src/validation/rules/references/validator.rs @@ -124,6 +124,7 @@ impl Visitor for Validator<'_> { } } +#[derive(Clone, Copy)] enum ReferenceKind { ParserToAnything, ParserToScanner, @@ -151,12 +152,9 @@ impl Validator<'_> { return; } - let reference = match self.language.productions.get(reference_name) { - Some(reference) => reference, - None => { - reporter.report(location, Errors::NotDefined(reference_name.to_owned())); - return; - } + let Some(reference) = self.language.productions.get(reference_name) else { + reporter.report(location, Errors::NotDefined(reference_name.to_owned())); + return; }; if !self.metadata.is_defined_over(reference_name, version_set) { diff --git a/crates/codegen/schema/src/validation/visitors/version_set.rs b/crates/codegen/schema/src/validation/visitors/version_set.rs index 8d921254dc..81353fa7a6 100644 --- a/crates/codegen/schema/src/validation/visitors/version_set.rs +++ b/crates/codegen/schema/src/validation/visitors/version_set.rs @@ -29,11 +29,11 @@ impl VersionSet { } #[cfg(test)] - fn from_ranges(ranges: Vec) -> Self { + fn from_ranges(ranges: impl IntoIterator) -> Self { let mut instance = Self::empty(); - for range in &ranges { - instance.add(range); + for range in ranges { + instance.add(&range); } instance diff --git a/crates/codegen/spec/src/snippets.rs b/crates/codegen/spec/src/snippets.rs index c934e6774a..28958c8c1f 100644 --- a/crates/codegen/spec/src/snippets.rs +++ b/crates/codegen/spec/src/snippets.rs @@ -36,7 +36,7 @@ impl Snippets { for version in versions { if let Some(snippet_path) = self.get_snippet_path(production, version) { let snippet = self.get_snippet(production, version).unwrap_or_default(); - codegen.write_file(snippet_path, snippet)? + codegen.write_file(snippet_path, snippet)?; }; } } diff --git a/crates/codegen/testing/src/cst_output.rs b/crates/codegen/testing/src/cst_output.rs index 5cd52e77ca..2a5492c0fc 100644 --- a/crates/codegen/testing/src/cst_output.rs +++ b/crates/codegen/testing/src/cst_output.rs @@ -58,13 +58,12 @@ fn collect_parser_tests(data_dir: &Path) -> Result { - let parser_tests = parser_tests - .entry(parser_name.to_string()) - .or_insert_with(BTreeSet::new); - - parser_tests.insert(test_name.to_string()); + parser_tests + .entry(parser_name.to_owned()) + .or_insert_with(BTreeSet::new) + .insert(test_name.to_owned()); } _ => { bail!("Invalid test input. Should be in the form of '/PARSER_NAME/TEST_NAME/input.sol', but found: {file:?}"); diff --git a/crates/infra/cli/src/commands/ci/mod.rs b/crates/infra/cli/src/commands/ci/mod.rs index 71f0730114..3635c8df47 100644 --- a/crates/infra/cli/src/commands/ci/mod.rs +++ b/crates/infra/cli/src/commands/ci/mod.rs @@ -9,6 +9,7 @@ use crate::commands::{ pub struct CiController; impl CiController { + #[allow(clippy::unused_self)] // For symmetry with other commands pub fn execute(&self) -> Result<()> { // Run all CI steps in order: _SLANG_INFRA_CI_STEPS_ORDERED_ (keep in sync) diff --git a/crates/infra/cli/src/toolchains/napi/cli.rs b/crates/infra/cli/src/toolchains/napi/cli.rs index 66d7ff13d8..313fc7c9ac 100644 --- a/crates/infra/cli/src/toolchains/napi/cli.rs +++ b/crates/infra/cli/src/toolchains/napi/cli.rs @@ -65,6 +65,8 @@ impl NapiCli { for child in output_dir.collect_children()? { let file_name = child.unwrap_name(); + // NAPI emits files with lowercase names. + #[allow(clippy::case_sensitive_file_extension_comparisons)] match file_name { "index.js" | "index.d.ts" => { source_files.push(output_dir.join(file_name)); diff --git a/crates/infra/cli/src/toolchains/napi/compiler.rs b/crates/infra/cli/src/toolchains/napi/compiler.rs index 5f55d03a39..2a37a77dd2 100644 --- a/crates/infra/cli/src/toolchains/napi/compiler.rs +++ b/crates/infra/cli/src/toolchains/napi/compiler.rs @@ -12,6 +12,7 @@ use crate::toolchains::napi::{ resolver::{NapiPackageKind, NapiResolver}, }; +#[derive(Clone, Copy)] pub enum NapiProfile { /// Build only the main package for local development. Debug, diff --git a/crates/infra/cli/src/toolchains/napi/config.rs b/crates/infra/cli/src/toolchains/napi/config.rs index dd52b8f6c5..b2a9f3bd69 100644 --- a/crates/infra/cli/src/toolchains/napi/config.rs +++ b/crates/infra/cli/src/toolchains/napi/config.rs @@ -57,7 +57,7 @@ impl NapiConfig { "Package should explicitly list targets, instead of using defaults." ); - Ok(triples.additional.to_owned()) + Ok(triples.additional) } } diff --git a/crates/infra/utils/src/cargo/workspace.rs b/crates/infra/utils/src/cargo/workspace.rs index a00c53f5f0..32875c4b41 100644 --- a/crates/infra/utils/src/cargo/workspace.rs +++ b/crates/infra/utils/src/cargo/workspace.rs @@ -113,7 +113,13 @@ impl CargoWorkspace { "--config", format!( "build.rustflags = {rustflags}", - rustflags = serde_json::to_string(&["--deny", "warnings"])?, + rustflags = serde_json::to_string(&[ + // Deny any warnings in CI: + "-Dwarnings", + // Lint against leftover `dbg/todo!` macros in CI: + "-Wclippy::dbg_macro", + "-Wclippy::todo" + ])?, ), ); // Rustdoc requires specifying RUSTDOCFLAGS, instead: @@ -122,7 +128,10 @@ impl CargoWorkspace { "--config", format!( "build.rustdocflags = {rustdocflags}", - rustdocflags = serde_json::to_string(&["--deny", "warnings"])?, + rustdocflags = serde_json::to_string(&[ + // Deny any warnings in CI: + "-Dwarnings" + ])?, ), ); } diff --git a/crates/infra/utils/src/codegen/common/formatting.rs b/crates/infra/utils/src/codegen/common/formatting.rs index 5046b7604d..a1c5a8eb30 100644 --- a/crates/infra/utils/src/codegen/common/formatting.rs +++ b/crates/infra/utils/src/codegen/common/formatting.rs @@ -56,7 +56,7 @@ fn generate_header(file_path: &Path) -> String { "This file is generated automatically by infrastructure scripts. Please don't edit by hand."; return match get_extension(file_path) { - "json" => "".to_string(), + "json" => String::new(), "html" | "md" => format!(""), "js" | "rs" | "ts" => format!("// {warning_line}"), "yml" | "zsh-completions" => format!("# {warning_line}"), diff --git a/crates/infra/utils/src/codegen/read_write.rs b/crates/infra/utils/src/codegen/read_write.rs index bc3b486fe0..2f6ecbcaf8 100644 --- a/crates/infra/utils/src/codegen/read_write.rs +++ b/crates/infra/utils/src/codegen/read_write.rs @@ -1,13 +1,10 @@ -use std::{ - collections::HashMap, - path::{Path, PathBuf}, -}; +use std::path::{Path, PathBuf}; use anyhow::{bail, Context, Result}; use cargo_emit::rerun_if_changed; use inflector::Inflector; use serde::Serialize; -use tera::Tera; +use tera::{Tera, Value}; use crate::{cargo::CargoWorkspace, codegen::write_only::CodegenWriteOnly, paths::PathExtensions}; @@ -31,15 +28,12 @@ impl CodegenReadWrite { let templates_glob = input_dir.join("**/*.jinja2"); let mut tera = Tera::new(templates_glob.unwrap_str())?; - fn snake_case( - value: &tera::Value, - _params: &HashMap, - ) -> Result { - let value = value.as_str().unwrap(); - let result = value.to_snake_case(); - Ok(tera::Value::String(result)) - } - tera.register_filter("snake_case", snake_case); + tera.register_filter("snake_case", |value: &Value, _params: &_| { + value + .as_str() + .ok_or_else(|| tera::Error::msg("Expected a string")) + .map(|s| Value::String(s.to_snake_case())) + }); tera.autoescape_on(vec![]); // disable autoescaping @@ -47,9 +41,9 @@ impl CodegenReadWrite { }; Ok(Self { - input_dir, writer, tera, + input_dir, }) } diff --git a/crates/infra/utils/src/commands/mod.rs b/crates/infra/utils/src/commands/mod.rs index a87b92f2cb..46a9f79929 100644 --- a/crates/infra/utils/src/commands/mod.rs +++ b/crates/infra/utils/src/commands/mod.rs @@ -26,6 +26,7 @@ pub struct Command { } impl Command { + #[must_use] pub fn new(name: impl Into) -> Self { Self { name: name.into(), @@ -35,18 +36,21 @@ impl Command { } } + #[must_use] pub fn flag(mut self, flag: impl Into) -> Self { self.args.push(flag.into()); self } + #[must_use] pub fn arg(mut self, arg: impl Into) -> Self { self.args.push(arg.into()); self } + #[must_use] pub fn args(mut self, args: impl IntoIterator>) -> Self { for arg in args { self.args.push(arg.into()); @@ -55,6 +59,7 @@ impl Command { self } + #[must_use] pub fn property(mut self, key: impl Into, value: impl Into) -> Self { self.args.push(key.into()); self.args.push(value.into()); @@ -62,12 +67,14 @@ impl Command { self } + #[must_use] pub fn env(mut self, key: impl Into, value: impl Into) -> Self { self.environment.insert(key.into(), value.into()); self } + #[must_use] pub fn current_dir(mut self, current_dir: impl Into) -> Self { let current_dir = current_dir.into(); if current_dir != Path::repo_root() { @@ -134,6 +141,7 @@ fn run_with_defaults(command: &Command) -> Result<()> { check_status(command, status).map_err(|error| { // Print error and exit process, to skip printing irrelevant backtraces from the parent process: eprintln!("{error}"); + #[allow(clippy::exit)] std::process::exit(1); }) } @@ -199,7 +207,7 @@ fn check_status(command: &Command, status: ExitStatus) -> Result<()> { } impl Display for Command { - fn fmt(&self, formatter: &mut Formatter) -> std::fmt::Result { + fn fmt(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result { let mut parts = vec![]; for (key, value) in &self.environment { diff --git a/crates/infra/utils/src/errors/mod.rs b/crates/infra/utils/src/errors/mod.rs index 4e2d816852..15091cff62 100644 --- a/crates/infra/utils/src/errors/mod.rs +++ b/crates/infra/utils/src/errors/mod.rs @@ -50,7 +50,7 @@ impl InfraErrors { } impl std::fmt::Display for InfraErrors { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { for error in &self.contents { writeln!(f, "{error}")?; } @@ -69,7 +69,7 @@ struct ErrorDescriptor { } impl std::fmt::Display for ErrorDescriptor { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if var("VSCODE_PROBLEM_MATCHER").is_ok() { self.write_problem_matcher(f)?; writeln!(f)?; @@ -82,7 +82,7 @@ impl std::fmt::Display for ErrorDescriptor { } impl ErrorDescriptor { - fn write_ariadne_report(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn write_ariadne_report(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let source_id = self.file_path.unwrap_str(); let source = { let source = self.file_path.read_to_string().unwrap(); @@ -114,7 +114,7 @@ impl ErrorDescriptor { Ok(()) } - fn write_problem_matcher(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn write_problem_matcher(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let severity = "error"; writeln!( diff --git a/crates/solidity/inputs/language/src/grammar.rs b/crates/solidity/inputs/language/src/grammar.rs index 3ce7ae8829..e7323d42f8 100644 --- a/crates/solidity/inputs/language/src/grammar.rs +++ b/crates/solidity/inputs/language/src/grammar.rs @@ -29,14 +29,18 @@ pub trait GrammarConstructorDslV2 { } impl GrammarConstructorDslV2 for Grammar { + #[allow(clippy::too_many_lines)] // TODO: Remove me once the hack below is removed fn from_dsl_v2(lang: &model::Language) -> Grammar { // Collect language items into a lookup table to speed up resolution - let mut items = HashMap::from_iter(lang.items_with_section().map(|(_, topic, item)| { - ( - item.name().clone(), - (topic.lexical_context.clone(), Rc::clone(item)), - ) - })); + let mut items: HashMap<_, _> = lang + .items_with_section() + .map(|(_, topic, item)| { + ( + item.name().clone(), + (topic.lexical_context.clone(), Rc::clone(item)), + ) + }) + .collect(); // TODO(#638): To minimize regression in the parser migration, we keep the existing DSL v1 model // of SourceUnit being followed by `EndOfFileTrivia`. @@ -152,13 +156,13 @@ impl GrammarConstructorDslV2 for Grammar { versions: BTreeSet::from_iter(lang.versions.clone()), leading_trivia_parser: leading_trivia.clone(), trailing_trivia_parser: trailing_trivia.clone(), - elements: HashMap::from_iter( - resolved_items.chain( + elements: resolved_items + .chain( [leading_trivia, trailing_trivia, eof_trivia] .into_iter() .map(|elem| (elem.name(), elem.into())), - ), - ), + ) + .collect(), } } } @@ -245,6 +249,26 @@ impl PrecedenceParserDefinition for NamedPrecedenceParserThunk { } } +enum ParserThunk { + Regular(Rc), + Precedence(Rc), +} +impl ParserThunk { + fn as_regular_def(&self) -> &OnceCell { + match self { + ParserThunk::Regular(thunk) => &thunk.def, + ParserThunk::Precedence(..) => panic!("Expected a regular parser thunk"), + } + } + + fn as_precedence_def(&self) -> &OnceCell { + match self { + ParserThunk::Precedence(thunk) => &thunk.def, + ParserThunk::Regular(..) => panic!("Expected a precedence parser thunk"), + } + } +} + fn enabled_to_range(spec: model::VersionSpecifier) -> Vec { match spec { model::VersionSpecifier::Never => vec![VersionQualityRange { @@ -277,7 +301,8 @@ struct ResolveCtx<'a> { resolved: &'a mut HashMap, } -fn resolve_grammar_element(ident: &Identifier, ctx: &mut ResolveCtx) -> GrammarElement { +#[allow(clippy::too_many_lines)] // FIXME: Simplify me when we simplify the v2-to-v1 interface +fn resolve_grammar_element(ident: &Identifier, ctx: &mut ResolveCtx<'_>) -> GrammarElement { if ident.as_str() == "EndOfFileTrivia" { return ctx.resolved.get(ident).unwrap().clone(); } @@ -287,28 +312,8 @@ fn resolve_grammar_element(ident: &Identifier, ctx: &mut ResolveCtx) -> GrammarE // FIXME: Don't leak let lex_ctx = lex_ctx .as_ref() - .map(|l| l.to_string().leak() as &_) - .unwrap_or("Default"); - - enum ParserThunk { - Regular(Rc), - Precedence(Rc), - } - impl ParserThunk { - fn as_regular_def(&self) -> &OnceCell { - match self { - ParserThunk::Regular(thunk) => &thunk.def, - _ => panic!("Expected a regular parser thunk"), - } - } + .map_or("Default", |l| l.to_string().leak() as &_); - fn as_precedence_def(&self) -> &OnceCell { - match self { - ParserThunk::Precedence(thunk) => &thunk.def, - _ => panic!("Expected a precedence parser thunk"), - } - } - } // The non-terminals are mutually recursive (so will be the resolution of their definitions), // so make sure to insert a thunk for non-terminals to resolve to break the cycle. let inserted_thunk = match (elem.as_ref(), ctx.resolved.contains_key(ident)) { @@ -427,7 +432,7 @@ fn resolve_grammar_element(ident: &Identifier, ctx: &mut ResolveCtx) -> GrammarE } } -fn resolve_scanner(scanner: model::Scanner, ctx: &mut ResolveCtx) -> ScannerDefinitionNode { +fn resolve_scanner(scanner: model::Scanner, ctx: &mut ResolveCtx<'_>) -> ScannerDefinitionNode { match scanner { model::Scanner::Optional { scanner } => { ScannerDefinitionNode::Optional(Box::new(resolve_scanner(*scanner, ctx))) @@ -472,11 +477,14 @@ fn resolve_scanner(scanner: model::Scanner, ctx: &mut ResolveCtx) -> ScannerDefi } } -fn resolve_fragment(fragment: model::FragmentItem, ctx: &mut ResolveCtx) -> ScannerDefinitionNode { +fn resolve_fragment( + fragment: model::FragmentItem, + ctx: &mut ResolveCtx<'_>, +) -> ScannerDefinitionNode { resolve_scanner(fragment.scanner, ctx).versioned(fragment.enabled) } -fn resolve_token(token: model::TokenItem, ctx: &mut ResolveCtx) -> ScannerDefinitionNode { +fn resolve_token(token: model::TokenItem, ctx: &mut ResolveCtx<'_>) -> ScannerDefinitionNode { let resolved_defs: Vec<_> = token .definitions .into_iter() @@ -546,7 +554,7 @@ fn resolve_keyword_value(value: model::KeywordValue) -> ScannerDefinitionNode { } } -fn resolve_trivia(parser: model::TriviaParser, ctx: &mut ResolveCtx) -> ParserDefinitionNode { +fn resolve_trivia(parser: model::TriviaParser, ctx: &mut ResolveCtx<'_>) -> ParserDefinitionNode { match parser { model::TriviaParser::Optional { parser } => { ParserDefinitionNode::Optional(Box::new(resolve_trivia(*parser, ctx))) @@ -578,7 +586,7 @@ fn resolve_trivia(parser: model::TriviaParser, ctx: &mut ResolveCtx) -> ParserDe } } -fn resolve_field(field: model::Field, ctx: &mut ResolveCtx) -> ParserDefinitionNode { +fn resolve_field(field: model::Field, ctx: &mut ResolveCtx<'_>) -> ParserDefinitionNode { match field { model::Field::Required { reference } => { resolve_grammar_element(&reference, ctx).into_parser_def_node() @@ -595,7 +603,7 @@ fn resolve_sequence_like( enabled: Option, fields: IndexMap, error_recovery: Option, - ctx: &mut ResolveCtx, + ctx: &mut ResolveCtx<'_>, ) -> ParserDefinitionNode { let (terminator, delimiters) = match error_recovery { Some(FieldsErrorRecovery { @@ -635,7 +643,6 @@ fn resolve_sequence_like( let mut delims = fields .drain(open_idx..=open_idx + 1) .map(|(_, field)| field); - dbg!(delims.size_hint()); let open = delims.next().unwrap(); let close = delims.next().unwrap(); @@ -674,7 +681,7 @@ fn resolve_sequence_like( .versioned(enabled) } -fn resolve_choice(item: model::EnumItem, ctx: &mut ResolveCtx) -> ParserDefinitionNode { +fn resolve_choice(item: model::EnumItem, ctx: &mut ResolveCtx<'_>) -> ParserDefinitionNode { let variants = item .variants .into_iter() @@ -688,13 +695,13 @@ fn resolve_choice(item: model::EnumItem, ctx: &mut ResolveCtx) -> ParserDefiniti ParserDefinitionNode::Choice(variants).versioned(item.enabled) } -fn resolve_repeated(item: model::RepeatedItem, ctx: &mut ResolveCtx) -> ParserDefinitionNode { +fn resolve_repeated(item: model::RepeatedItem, ctx: &mut ResolveCtx<'_>) -> ParserDefinitionNode { let body = Box::new(resolve_grammar_element(&item.repeated, ctx).into_parser_def_node()); ParserDefinitionNode::OneOrMore(body).versioned(item.enabled) } -fn resolve_separated(item: model::SeparatedItem, ctx: &mut ResolveCtx) -> ParserDefinitionNode { +fn resolve_separated(item: model::SeparatedItem, ctx: &mut ResolveCtx<'_>) -> ParserDefinitionNode { let body = resolve_grammar_element(&item.separated, ctx).into_parser_def_node(); let separator = resolve_grammar_element(&item.separator, ctx).into_parser_def_node(); @@ -704,7 +711,7 @@ fn resolve_separated(item: model::SeparatedItem, ctx: &mut ResolveCtx) -> Parser fn resolve_precedence( item: model::PrecedenceItem, lex_ctx: &'static str, - ctx: &mut ResolveCtx, + ctx: &mut ResolveCtx<'_>, ) -> PrecedenceParserDefinitionNode { let primaries: Vec<_> = item .primary_expressions @@ -721,6 +728,7 @@ fn resolve_precedence( _ => ParserDefinitionNode::Choice(primaries), }); + #[allow(clippy::items_after_statements)] // simple and specific to this site fn model_to_enum(model: model::OperatorModel) -> PrecedenceOperatorModel { match model { model::OperatorModel::BinaryLeftAssociative => { @@ -773,7 +781,7 @@ fn resolve_precedence( .collect(); let def = match defs.len() { - 0 => panic!("Precedence operator {} has no definitions", name), + 0 => panic!("Precedence operator {name} has no definitions"), 1 => defs.into_iter().next().unwrap(), _ => ParserDefinitionNode::Choice(defs), }; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/cst.rs b/crates/solidity/outputs/cargo/crate/src/generated/cst.rs index b4d799140c..a85816fc3a 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/cst.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/cst.rs @@ -75,29 +75,29 @@ impl Node { pub fn as_rule(&self) -> Option<&Rc> { match self { - Self::Rule(node) => Some(node), - _ => None, + Self::Rule(rule) => Some(rule), + Self::Token(..) => None, } } pub fn into_rule(self) -> Option> { match self { - Self::Rule(node) => Some(node), - _ => None, + Self::Rule(rule) => Some(rule), + Self::Token(..) => None, } } pub fn as_token(&self) -> Option<&Rc> { match self { - Self::Token(node) => Some(node), - _ => None, + Self::Token(token) => Some(token), + Self::Rule(..) => None, } } pub fn into_token(self) -> Option> { match self { - Self::Token(node) => Some(node), - _ => None, + Self::Token(token) => Some(token), + Self::Rule(..) => None, } } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/cursor.rs b/crates/solidity/outputs/cargo/crate/src/generated/cursor.rs index a8c95ace34..2b64bdada7 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/cursor.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/cursor.rs @@ -118,6 +118,7 @@ impl Cursor { /// Unlike `clone`, this re-roots at the current node. /// It does preserve the correct text offset however, /// even though the path is reset. + #[must_use] pub fn spawn(&self) -> Self { Self { path: vec![], @@ -207,17 +208,14 @@ impl Cursor { /// /// Returns `false` if the cursor is finished and at the root. pub fn go_to_parent(&mut self) -> bool { - match self.path.pop() { - Some(parent) => { - self.current = parent.into_path_node(); + if let Some(parent) = self.path.pop() { + self.current = parent.into_path_node(); - true - } - None => { - self.is_completed = true; + true + } else { + self.is_completed = true; - false - } + false } } @@ -292,7 +290,7 @@ impl Cursor { let text_offset = parent.text_offset + parent.rule_node.children[..child_number] .iter() - .map(|child| child.text_len()) + .map(Node::text_len) .sum(); self.path.push(parent); diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index 122fe15bfc..183df95f28 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -1,5 +1,14 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +// This file is generated; we can't reasonably satisfy some of these lints. +#![allow( + clippy::if_not_else, + clippy::too_many_lines, + clippy::unused_self, + clippy::struct_excessive_bools, + clippy::similar_names +)] + #[cfg(feature = "slang_napi_interfaces")] use {napi::bindgen_prelude::*, napi_derive::napi}; @@ -185,7 +194,7 @@ impl Language { ********************************************/ #[allow(unused_assignments, unused_parens)] - fn abi_coder_pragma(&self, input: &mut ParserContext) -> ParserResult { + fn abi_coder_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -201,7 +210,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn address_type(&self, input: &mut ParserContext) -> ParserResult { + fn address_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -219,7 +228,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn array_expression(&self, input: &mut ParserContext) -> ParserResult { + fn array_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBracket); let input = delim_guard.ctx(); @@ -246,7 +255,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn array_values(&self, input: &mut ParserContext) -> ParserResult { + fn array_values(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -257,7 +266,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn ascii_string_literals(&self, input: &mut ParserContext) -> ParserResult { + fn ascii_string_literals(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { self.parse_token_with_trivia::( input, @@ -268,7 +277,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn assembly_flags(&self, input: &mut ParserContext) -> ParserResult { + fn assembly_flags(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -284,7 +293,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn assembly_flags_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn assembly_flags_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -311,7 +320,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn assembly_statement(&self, input: &mut ParserContext) -> ParserResult { + fn assembly_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -333,7 +342,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn block(&self, input: &mut ParserContext) -> ParserResult { + fn block(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); @@ -360,7 +369,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn break_statement(&self, input: &mut ParserContext) -> ParserResult { + fn break_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -384,7 +393,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn catch_clause(&self, input: &mut ParserContext) -> ParserResult { + fn catch_clause(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -402,7 +411,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn catch_clause_error(&self, input: &mut ParserContext) -> ParserResult { + fn catch_clause_error(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform( @@ -421,7 +430,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn catch_clauses(&self, input: &mut ParserContext) -> ParserResult { + fn catch_clauses(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| self.catch_clause(input)) } else { @@ -431,7 +440,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn constant_definition(&self, input: &mut ParserContext) -> ParserResult { + fn constant_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_7_4 { SequenceHelper::run(|mut seq| { seq.elem( @@ -472,7 +481,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn constructor_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn constructor_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_4_22 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_4_22 { @@ -507,7 +516,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn constructor_definition(&self, input: &mut ParserContext) -> ParserResult { + fn constructor_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_4_22 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -528,7 +537,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn continue_statement(&self, input: &mut ParserContext) -> ParserResult { + fn continue_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -552,7 +561,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn contract_definition(&self, input: &mut ParserContext) -> ParserResult { + fn contract_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { if self.version_is_at_least_0_6_0 { seq.elem(OptionalHelper::transform( @@ -599,7 +608,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn contract_members(&self, input: &mut ParserContext) -> ParserResult { + fn contract_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.using_directive(input); @@ -647,7 +656,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn decimal_number_expression(&self, input: &mut ParserContext) -> ParserResult { + fn decimal_number_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -728,7 +737,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn delete_statement(&self, input: &mut ParserContext) -> ParserResult { + fn delete_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -756,7 +765,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn do_while_statement(&self, input: &mut ParserContext) -> ParserResult { + fn do_while_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -858,7 +867,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn else_branch(&self, input: &mut ParserContext) -> ParserResult { + fn else_branch(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -919,7 +928,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn emit_statement(&self, input: &mut ParserContext) -> ParserResult { + fn emit_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_4_21 { SequenceHelper::run(|mut seq| { seq.elem( @@ -958,7 +967,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn end_of_file_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn end_of_file_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = @@ -982,7 +991,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn enum_definition(&self, input: &mut ParserContext) -> ParserResult { + fn enum_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -1020,7 +1029,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn enum_members(&self, input: &mut ParserContext) -> ParserResult { + fn enum_members(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -1036,7 +1045,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn error_definition(&self, input: &mut ParserContext) -> ParserResult { + fn error_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SequenceHelper::run(|mut seq| { seq.elem( @@ -1072,7 +1081,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn error_parameter(&self, input: &mut ParserContext) -> ParserResult { + fn error_parameter(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; @@ -1091,7 +1100,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn error_parameters(&self, input: &mut ParserContext) -> ParserResult { + fn error_parameters(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SeparatedHelper::run::<_, LexicalContextType::Default>( input, @@ -1106,7 +1115,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn error_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn error_parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); @@ -1137,7 +1146,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn event_definition(&self, input: &mut ParserContext) -> ParserResult { + fn event_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -1175,7 +1184,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn event_parameter(&self, input: &mut ParserContext) -> ParserResult { + fn event_parameter(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; seq.elem(OptionalHelper::transform( @@ -1196,7 +1205,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn event_parameters(&self, input: &mut ParserContext) -> ParserResult { + fn event_parameters(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -1207,7 +1216,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn event_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn event_parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -1234,7 +1243,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn experimental_pragma(&self, input: &mut ParserContext) -> ParserResult { + fn experimental_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -1259,9 +1268,9 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn expression(&self, input: &mut ParserContext) -> ParserResult { + fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 1u8, @@ -1332,7 +1341,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 3u8, @@ -1403,7 +1412,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 5u8, @@ -1474,7 +1483,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 7u8, @@ -1545,7 +1554,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 9u8, @@ -1616,7 +1625,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 11u8, @@ -1687,7 +1696,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 13u8, @@ -1758,7 +1767,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 15u8, @@ -1829,7 +1838,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 17u8, @@ -1900,7 +1909,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 19u8, @@ -1971,7 +1980,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 21u8, @@ -2042,7 +2051,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 23u8, @@ -2113,7 +2122,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_conditional_expression = |input: &mut ParserContext| { + let parse_conditional_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::ConditionalExpression, 25u8, @@ -2133,7 +2142,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_or_expression = |input: &mut ParserContext| { + let parse_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 27u8, @@ -2145,7 +2154,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_and_expression = |input: &mut ParserContext| { + let parse_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 29u8, @@ -2157,7 +2166,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext| { + let parse_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 31u8, @@ -2178,7 +2187,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext| { + let parse_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 33u8, @@ -2199,7 +2208,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 35u8, @@ -2230,7 +2239,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 37u8, @@ -2261,7 +2270,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 39u8, @@ -2292,7 +2301,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 41u8, @@ -2323,7 +2332,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_bitwise_or_expression = |input: &mut ParserContext| { + let parse_bitwise_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 43u8, @@ -2332,7 +2341,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_bitwise_xor_expression = |input: &mut ParserContext| { + let parse_bitwise_xor_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 45u8, @@ -2344,7 +2353,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_bitwise_and_expression = |input: &mut ParserContext| { + let parse_bitwise_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 47u8, @@ -2356,7 +2365,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext| { + let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 49u8, @@ -2382,7 +2391,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext| { + let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 51u8, @@ -2408,7 +2417,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext| { + let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 53u8, @@ -2434,7 +2443,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext| { + let parse_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 55u8, @@ -2455,7 +2464,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext| { + let parse_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 57u8, @@ -2476,7 +2485,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext| { + let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 59u8, @@ -2502,7 +2511,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext| { + let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 61u8, @@ -2528,7 +2537,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext| { + let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 63u8, @@ -2554,7 +2563,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 65u8, @@ -2579,7 +2588,9 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext< + '_, + >| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 67u8 + 1, @@ -2604,7 +2615,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext| { + let parse_postfix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::UnaryPostfixExpression, 69u8, @@ -2624,7 +2635,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext| { + let parse_postfix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::UnaryPostfixExpression, 71u8, @@ -2644,7 +2655,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext| { + let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 73u8, @@ -2686,7 +2697,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext| { + let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 75u8, @@ -2728,7 +2739,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext| { + let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 77u8, @@ -2770,7 +2781,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext| { + let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 79u8, @@ -2812,7 +2823,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext| { + let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 81u8, @@ -2854,7 +2865,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext| { + let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 83u8, @@ -2896,7 +2907,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_function_call_expression = |input: &mut ParserContext| { + let parse_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::FunctionCallExpression, 85u8, @@ -2934,7 +2945,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_member_access_expression = |input: &mut ParserContext| { + let parse_member_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, 87u8, @@ -2961,7 +2972,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_index_access_expression = |input: &mut ParserContext| { + let parse_index_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, 89u8, @@ -2994,7 +3005,7 @@ impl Language { ) }; #[allow(unused_variables)] - let prefix_operator_parser = |input: &mut ParserContext| { + let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_prefix_expression(input); choice.consider(input, result)?; @@ -3014,7 +3025,7 @@ impl Language { }) }; #[allow(unused_variables)] - let primary_expression_parser = |input: &mut ParserContext| { + let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.new_expression(input); choice.consider(input, result)?; @@ -3114,7 +3125,7 @@ impl Language { }) }; #[allow(unused_variables)] - let postfix_operator_parser = |input: &mut ParserContext| { + let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_conditional_expression(input); choice.consider(input, result)?; @@ -3132,7 +3143,7 @@ impl Language { }) }; #[allow(unused_variables)] - let binary_operand_parser = |input: &mut ParserContext| { + let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(ZeroOrMoreHelper::run(input, |input| { prefix_operator_parser(input) @@ -3145,7 +3156,7 @@ impl Language { }) }; #[allow(unused_variables)] - let binary_operator_parser = |input: &mut ParserContext| { + let binary_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_assignment_expression(input); choice.consider(input, result)?; @@ -3221,7 +3232,7 @@ impl Language { }) }; #[allow(unused_variables)] - let linear_expression_parser = |input: &mut ParserContext| { + let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; seq.elem(ZeroOrMoreHelper::run(input, |input| { @@ -3242,7 +3253,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn expression_statement(&self, input: &mut ParserContext) -> ParserResult { + fn expression_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.expression(input) @@ -3263,7 +3274,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn fallback_function_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn fallback_function_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_6_0 { @@ -3310,7 +3321,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn fallback_function_definition(&self, input: &mut ParserContext) -> ParserResult { + fn fallback_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -3341,7 +3352,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn for_statement(&self, input: &mut ParserContext) -> ParserResult { + fn for_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3453,7 +3464,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn function_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn function_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.modifier_invocation(input); @@ -3516,7 +3527,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn function_definition(&self, input: &mut ParserContext) -> ParserResult { + fn function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3559,7 +3570,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn function_type(&self, input: &mut ParserContext) -> ParserResult { + fn function_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3576,7 +3587,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn function_type_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn function_type_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -3621,7 +3632,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_number_expression(&self, input: &mut ParserContext) -> ParserResult { + fn hex_number_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3708,7 +3719,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_string_literals(&self, input: &mut ParserContext) -> ParserResult { + fn hex_string_literals(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { self.parse_token_with_trivia::( input, @@ -3719,7 +3730,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn identifier_path(&self, input: &mut ParserContext) -> ParserResult { + fn identifier_path(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -3735,7 +3746,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn if_statement(&self, input: &mut ParserContext) -> ParserResult { + fn if_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3819,7 +3830,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn import_alias(&self, input: &mut ParserContext) -> ParserResult { + fn import_alias(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3835,7 +3846,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn import_deconstruction(&self, input: &mut ParserContext) -> ParserResult { + fn import_deconstruction(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); @@ -3873,7 +3884,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn import_deconstruction_symbol(&self, input: &mut ParserContext) -> ParserResult { + fn import_deconstruction_symbol(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3886,7 +3897,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn import_deconstruction_symbols(&self, input: &mut ParserContext) -> ParserResult { + fn import_deconstruction_symbols(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -3897,7 +3908,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn import_directive(&self, input: &mut ParserContext) -> ParserResult { + fn import_directive(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -3933,7 +3944,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn index_access_end(&self, input: &mut ParserContext) -> ParserResult { + fn index_access_end(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -3948,7 +3959,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn inheritance_specifier(&self, input: &mut ParserContext) -> ParserResult { + fn inheritance_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3961,7 +3972,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn inheritance_type(&self, input: &mut ParserContext) -> ParserResult { + fn inheritance_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; seq.elem(OptionalHelper::transform(ChoiceHelper::run( @@ -3980,7 +3991,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn inheritance_types(&self, input: &mut ParserContext) -> ParserResult { + fn inheritance_types(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -3991,7 +4002,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn interface_definition(&self, input: &mut ParserContext) -> ParserResult { + fn interface_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4030,7 +4041,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn interface_members(&self, input: &mut ParserContext) -> ParserResult { + fn interface_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.using_directive(input); @@ -4078,7 +4089,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn leading_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = @@ -4102,7 +4113,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn library_definition(&self, input: &mut ParserContext) -> ParserResult { + fn library_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4140,7 +4151,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn library_members(&self, input: &mut ParserContext) -> ParserResult { + fn library_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.using_directive(input); @@ -4188,7 +4199,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn mapping_key(&self, input: &mut ParserContext) -> ParserResult { + fn mapping_key(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(ChoiceHelper::run(input, |mut choice, input| { let result = ChoiceHelper::run(input, |mut choice, input| { @@ -4262,7 +4273,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn mapping_type(&self, input: &mut ParserContext) -> ParserResult { + fn mapping_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4304,7 +4315,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn mapping_value(&self, input: &mut ParserContext) -> ParserResult { + fn mapping_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; if self.version_is_at_least_0_8_18 { @@ -4321,7 +4332,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn modifier_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn modifier_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.override_specifier(input); @@ -4340,7 +4351,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn modifier_definition(&self, input: &mut ParserContext) -> ParserResult { + fn modifier_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4370,7 +4381,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn modifier_invocation(&self, input: &mut ParserContext) -> ParserResult { + fn modifier_invocation(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; seq.elem(OptionalHelper::transform(ChoiceHelper::run( @@ -4389,7 +4400,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_argument(&self, input: &mut ParserContext) -> ParserResult { + fn named_argument(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4408,7 +4419,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_argument_group(&self, input: &mut ParserContext) -> ParserResult { + fn named_argument_group(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); @@ -4435,7 +4446,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_argument_groups(&self, input: &mut ParserContext) -> ParserResult { + fn named_argument_groups(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { OneOrMoreHelper::run(input, |input| self.named_argument_group(input)) } else { @@ -4445,7 +4456,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_arguments(&self, input: &mut ParserContext) -> ParserResult { + fn named_arguments(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -4456,7 +4467,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn named_arguments_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -4483,7 +4494,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_import(&self, input: &mut ParserContext) -> ParserResult { + fn named_import(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4504,7 +4515,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn new_expression(&self, input: &mut ParserContext) -> ParserResult { + fn new_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4517,7 +4528,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn override_paths(&self, input: &mut ParserContext) -> ParserResult { + fn override_paths(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -4528,7 +4539,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn override_paths_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn override_paths_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -4555,7 +4566,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn override_specifier(&self, input: &mut ParserContext) -> ParserResult { + fn override_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4570,7 +4581,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn parameter(&self, input: &mut ParserContext) -> ParserResult { + fn parameter(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; seq.elem(OptionalHelper::transform(ChoiceHelper::run( @@ -4608,7 +4619,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn parameters(&self, input: &mut ParserContext) -> ParserResult { + fn parameters(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -4619,7 +4630,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -4646,7 +4657,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn path_import(&self, input: &mut ParserContext) -> ParserResult { + fn path_import(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4659,7 +4670,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn positional_arguments(&self, input: &mut ParserContext) -> ParserResult { + fn positional_arguments(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -4670,7 +4681,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn positional_arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn positional_arguments_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -4697,7 +4708,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn pragma_directive(&self, input: &mut ParserContext) -> ParserResult { + fn pragma_directive(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -4733,7 +4744,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn receive_function_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn receive_function_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_6_0 { @@ -4770,7 +4781,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn receive_function_definition(&self, input: &mut ParserContext) -> ParserResult { + fn receive_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -4800,7 +4811,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn return_statement(&self, input: &mut ParserContext) -> ParserResult { + fn return_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -4828,7 +4839,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn returns_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn returns_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4841,7 +4852,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn revert_statement(&self, input: &mut ParserContext) -> ParserResult { + fn revert_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SequenceHelper::run(|mut seq| { seq.elem( @@ -4880,7 +4891,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn source_unit(&self, input: &mut ParserContext) -> ParserResult { + fn source_unit(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform(self.source_unit_members(input)))?; seq.elem(OptionalHelper::transform(self.end_of_file_trivia(input)))?; @@ -4890,7 +4901,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn source_unit_members(&self, input: &mut ParserContext) -> ParserResult { + fn source_unit_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.pragma_directive(input); @@ -4942,7 +4953,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn state_variable_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn state_variable_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.override_specifier(input); @@ -4981,7 +4992,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn state_variable_definition(&self, input: &mut ParserContext) -> ParserResult { + fn state_variable_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -5015,7 +5026,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn state_variable_definition_value(&self, input: &mut ParserContext) -> ParserResult { + fn state_variable_definition_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -5030,7 +5041,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn statements(&self, input: &mut ParserContext) -> ParserResult { + fn statements(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.expression_statement(input); @@ -5086,7 +5097,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn struct_definition(&self, input: &mut ParserContext) -> ParserResult { + fn struct_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -5124,7 +5135,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn struct_member(&self, input: &mut ParserContext) -> ParserResult { + fn struct_member(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -5152,13 +5163,13 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn struct_members(&self, input: &mut ParserContext) -> ParserResult { + fn struct_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| self.struct_member(input)) .with_kind(RuleKind::StructMembers) } #[allow(unused_assignments, unused_parens)] - fn throw_statement(&self, input: &mut ParserContext) -> ParserResult { + fn throw_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if !self.version_is_at_least_0_5_0 { SequenceHelper::run(|mut seq| { seq.elem( @@ -5186,7 +5197,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn trailing_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform( self.parse_token::(input, TokenKind::Whitespace), @@ -5204,7 +5215,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn try_statement(&self, input: &mut ParserContext) -> ParserResult { + fn try_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -5224,7 +5235,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_deconstruction_element(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_deconstruction_element(&self, input: &mut ParserContext<'_>) -> ParserResult { OptionalHelper::transform(ChoiceHelper::run(input, |mut choice, input| { let result = self.typed_tuple_member(input); choice.consider(input, result)?; @@ -5236,7 +5247,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_deconstruction_elements(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_deconstruction_elements(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -5247,7 +5258,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_deconstruction_statement(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_deconstruction_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -5297,7 +5308,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_expression(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -5324,12 +5335,12 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_value(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_value(&self, input: &mut ParserContext<'_>) -> ParserResult { OptionalHelper::transform(self.expression(input)).with_kind(RuleKind::TupleValue) } #[allow(unused_assignments, unused_parens)] - fn tuple_values(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_values(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -5340,7 +5351,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn type_expression(&self, input: &mut ParserContext) -> ParserResult { + fn type_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_5_3 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -5378,9 +5389,9 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn type_name(&self, input: &mut ParserContext) -> ParserResult { + fn type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { #[allow(unused_variables)] - let parse_array_type_name = |input: &mut ParserContext| { + let parse_array_type_name = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, @@ -5409,7 +5420,7 @@ impl Language { ) }; #[allow(unused_variables)] - let primary_expression_parser = |input: &mut ParserContext| { + let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.function_type(input); choice.consider(input, result)?; @@ -5474,7 +5485,7 @@ impl Language { }) }; #[allow(unused_variables)] - let postfix_operator_parser = |input: &mut ParserContext| { + let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_array_type_name(input); choice.consider(input, result)?; @@ -5482,7 +5493,7 @@ impl Language { }) }; #[allow(unused_variables)] - let linear_expression_parser = |input: &mut ParserContext| { + let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; seq.elem(ZeroOrMoreHelper::run(input, |input| { @@ -5499,7 +5510,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn typed_tuple_member(&self, input: &mut ParserContext) -> ParserResult { + fn typed_tuple_member(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; seq.elem(OptionalHelper::transform(ChoiceHelper::run( @@ -5535,7 +5546,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unchecked_block(&self, input: &mut ParserContext) -> ParserResult { + fn unchecked_block(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -5552,7 +5563,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unicode_string_literals(&self, input: &mut ParserContext) -> ParserResult { + fn unicode_string_literals(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_7_0 { OneOrMoreHelper::run(input, |input| { self.parse_token_with_trivia::( @@ -5567,7 +5578,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unnamed_function_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn unnamed_function_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { if !self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if !self.version_is_at_least_0_6_0 { @@ -5609,7 +5620,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unnamed_function_definition(&self, input: &mut ParserContext) -> ParserResult { + fn unnamed_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if !self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -5639,7 +5650,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn untyped_tuple_member(&self, input: &mut ParserContext) -> ParserResult { + fn untyped_tuple_member(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform(ChoiceHelper::run( input, @@ -5674,7 +5685,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn user_defined_value_type_definition(&self, input: &mut ParserContext) -> ParserResult { + fn user_defined_value_type_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_8 { SequenceHelper::run(|mut seq| { seq.elem( @@ -5774,7 +5785,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_alias(&self, input: &mut ParserContext) -> ParserResult { + fn using_alias(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_19 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -5872,7 +5883,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_deconstruction(&self, input: &mut ParserContext) -> ParserResult { + fn using_deconstruction(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_13 { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); @@ -5903,7 +5914,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_deconstruction_symbol(&self, input: &mut ParserContext) -> ParserResult { + fn using_deconstruction_symbol(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_13 { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; @@ -5919,7 +5930,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_deconstruction_symbols(&self, input: &mut ParserContext) -> ParserResult { + fn using_deconstruction_symbols(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_13 { SeparatedHelper::run::<_, LexicalContextType::Default>( input, @@ -5934,7 +5945,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_directive(&self, input: &mut ParserContext) -> ParserResult { + fn using_directive(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -5992,7 +6003,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + fn variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -6061,7 +6072,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { + fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -6076,7 +6087,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma(&self, input: &mut ParserContext) -> ParserResult { + fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6089,9 +6100,9 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma_expression(&self, input: &mut ParserContext) -> ParserResult { + fn version_pragma_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { #[allow(unused_variables)] - let parse_version_pragma_or_expression = |input: &mut ParserContext| { + let parse_version_pragma_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::VersionPragmaBinaryExpression, 1u8, @@ -6103,7 +6114,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_range_expression = |input: &mut ParserContext| { + let parse_version_pragma_range_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::VersionPragmaBinaryExpression, 3u8, @@ -6112,7 +6123,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 5u8, @@ -6157,7 +6168,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 7u8, @@ -6202,7 +6213,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 9u8, @@ -6247,7 +6258,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 11u8, @@ -6292,7 +6303,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 13u8, @@ -6337,7 +6348,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 15u8, @@ -6382,7 +6393,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 17u8, @@ -6427,7 +6438,7 @@ impl Language { ) }; #[allow(unused_variables)] - let prefix_operator_parser = |input: &mut ParserContext| { + let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_version_pragma_prefix_expression(input); choice.consider(input, result)?; @@ -6448,9 +6459,9 @@ impl Language { }; #[allow(unused_variables)] let primary_expression_parser = - |input: &mut ParserContext| self.version_pragma_specifier(input); + |input: &mut ParserContext<'_>| self.version_pragma_specifier(input); #[allow(unused_variables)] - let binary_operand_parser = |input: &mut ParserContext| { + let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(ZeroOrMoreHelper::run(input, |input| { prefix_operator_parser(input) @@ -6460,7 +6471,7 @@ impl Language { }) }; #[allow(unused_variables)] - let binary_operator_parser = |input: &mut ParserContext| { + let binary_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_version_pragma_or_expression(input); choice.consider(input, result)?; @@ -6470,7 +6481,7 @@ impl Language { }) }; #[allow(unused_variables)] - let linear_expression_parser = |input: &mut ParserContext| { + let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; seq.elem(ZeroOrMoreHelper::run(input, |input| { @@ -6491,13 +6502,13 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma_expressions(&self, input: &mut ParserContext) -> ParserResult { + fn version_pragma_expressions(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| self.version_pragma_expression(input)) .with_kind(RuleKind::VersionPragmaExpressions) } #[allow(unused_assignments, unused_parens)] - fn version_pragma_specifier(&self, input: &mut ParserContext) -> ParserResult { + fn version_pragma_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Pragma>( input, self, @@ -6513,7 +6524,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn while_statement(&self, input: &mut ParserContext) -> ParserResult { + fn while_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6596,7 +6607,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_arguments(&self, input: &mut ParserContext) -> ParserResult { + fn yul_arguments(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, @@ -6607,7 +6618,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_assignment_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_assignment_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.yul_identifier_paths(input))?; seq.elem( @@ -6623,7 +6634,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_block(&self, input: &mut ParserContext) -> ParserResult { + fn yul_block(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); @@ -6654,13 +6665,13 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_break_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_break_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { self.parse_token_with_trivia::(input, TokenKind::YulBreakKeyword) .with_kind(RuleKind::YulBreakStatement) } #[allow(unused_assignments, unused_parens)] - fn yul_continue_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_continue_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { self.parse_token_with_trivia::( input, TokenKind::YulContinueKeyword, @@ -6669,7 +6680,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_default_case(&self, input: &mut ParserContext) -> ParserResult { + fn yul_default_case(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6682,9 +6693,9 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_expression(&self, input: &mut ParserContext) -> ParserResult { + fn yul_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { #[allow(unused_variables)] - let parse_yul_function_call_expression = |input: &mut ParserContext| { + let parse_yul_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::YulFunctionCallExpression, 1u8, @@ -6713,7 +6724,7 @@ impl Language { ) }; #[allow(unused_variables)] - let primary_expression_parser = |input: &mut ParserContext| { + let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -6755,7 +6766,7 @@ impl Language { }) }; #[allow(unused_variables)] - let postfix_operator_parser = |input: &mut ParserContext| { + let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_yul_function_call_expression(input); choice.consider(input, result)?; @@ -6763,7 +6774,7 @@ impl Language { }) }; #[allow(unused_variables)] - let linear_expression_parser = |input: &mut ParserContext| { + let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; seq.elem(ZeroOrMoreHelper::run(input, |input| { @@ -6780,7 +6791,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_for_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_for_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6796,7 +6807,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_function_definition(&self, input: &mut ParserContext) -> ParserResult { + fn yul_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6817,7 +6828,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_identifier_path(&self, input: &mut ParserContext) -> ParserResult { + fn yul_identifier_path(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, @@ -6833,7 +6844,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_identifier_paths(&self, input: &mut ParserContext) -> ParserResult { + fn yul_identifier_paths(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, @@ -6844,7 +6855,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_if_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_if_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6858,7 +6869,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_leave_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_leave_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { self.parse_token_with_trivia::( input, @@ -6871,7 +6882,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_parameters(&self, input: &mut ParserContext) -> ParserResult { + fn yul_parameters(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, @@ -6887,7 +6898,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn yul_parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -6918,7 +6929,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_return_variables(&self, input: &mut ParserContext) -> ParserResult { + fn yul_return_variables(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, @@ -6934,7 +6945,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_returns_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn yul_returns_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6947,7 +6958,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_statements(&self, input: &mut ParserContext) -> ParserResult { + fn yul_statements(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.yul_block(input); @@ -6981,7 +6992,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_switch_cases(&self, input: &mut ParserContext) -> ParserResult { + fn yul_switch_cases(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.yul_default_case(input); @@ -6995,7 +7006,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_switch_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -7009,7 +7020,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_value_case(&self, input: &mut ParserContext) -> ParserResult { + fn yul_value_case(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -7055,7 +7066,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -7071,7 +7082,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { + fn yul_variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -7090,7 +7101,7 @@ impl Language { ********************************************/ #[allow(unused_assignments, unused_parens)] - fn ascii_escape(&self, input: &mut ParserContext) -> bool { + fn ascii_escape(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_chars!(input, 't'), @@ -7105,7 +7116,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn ascii_string_literal(&self, input: &mut ParserContext) -> bool { + fn ascii_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, self.single_quoted_ascii_string_literal(input), @@ -7114,7 +7125,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn bytes_keyword(&self, input: &mut ParserContext) -> bool { + fn bytes_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'b', 'y', 't', 'e', 's'), scan_optional!( @@ -7159,7 +7170,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn decimal_digits(&self, input: &mut ParserContext) -> bool { + fn decimal_digits(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_one_or_more!(input, scan_char_range!(input, '0'..='9')), scan_zero_or_more!( @@ -7173,7 +7184,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn decimal_exponent(&self, input: &mut ParserContext) -> bool { + fn decimal_exponent(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_choice!(input, scan_chars!(input, 'e'), scan_chars!(input, 'E')), scan_optional!(input, scan_chars!(input, '-')), @@ -7182,7 +7193,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn decimal_literal(&self, input: &mut ParserContext) -> bool { + fn decimal_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_not_followed_by!( @@ -7236,7 +7247,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn double_quoted_ascii_string_literal(&self, input: &mut ParserContext) -> bool { + fn double_quoted_ascii_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, '"'), scan_zero_or_more!( @@ -7254,7 +7265,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn double_quoted_hex_string_literal(&self, input: &mut ParserContext) -> bool { + fn double_quoted_hex_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'h', 'e', 'x', '"'), scan_optional!(input, self.hex_string_contents(input)), @@ -7263,7 +7274,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn double_quoted_unicode_string_literal(&self, input: &mut ParserContext) -> bool { + fn double_quoted_unicode_string_literal(&self, input: &mut ParserContext<'_>) -> bool { if self.version_is_at_least_0_7_0 { scan_sequence!( scan_chars!(input, 'u', 'n', 'i', 'c', 'o', 'd', 'e', '"'), @@ -7283,7 +7294,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn end_of_line(&self, input: &mut ParserContext) -> bool { + fn end_of_line(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_optional!(input, scan_chars!(input, '\r')), scan_chars!(input, '\n') @@ -7291,7 +7302,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn escape_sequence(&self, input: &mut ParserContext) -> bool { + fn escape_sequence(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, '\\'), scan_choice!( @@ -7304,7 +7315,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn fixed_keyword(&self, input: &mut ParserContext) -> bool { + fn fixed_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), @@ -7587,7 +7598,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_byte_escape(&self, input: &mut ParserContext) -> bool { + fn hex_byte_escape(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'x'), self.hex_character(input), @@ -7596,7 +7607,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_character(&self, input: &mut ParserContext) -> bool { + fn hex_character(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_char_range!(input, '0'..='9'), @@ -7606,7 +7617,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_literal(&self, input: &mut ParserContext) -> bool { + fn hex_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_not_followed_by!( @@ -7647,7 +7658,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_string_contents(&self, input: &mut ParserContext) -> bool { + fn hex_string_contents(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( self.hex_character(input), self.hex_character(input), @@ -7663,7 +7674,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_string_literal(&self, input: &mut ParserContext) -> bool { + fn hex_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, self.single_quoted_hex_string_literal(input), @@ -7672,12 +7683,12 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn identifier(&self, input: &mut ParserContext) -> bool { + fn identifier(&self, input: &mut ParserContext<'_>) -> bool { self.raw_identifier(input) } #[allow(unused_assignments, unused_parens)] - fn identifier_part(&self, input: &mut ParserContext) -> bool { + fn identifier_part(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, self.identifier_start(input), @@ -7686,7 +7697,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn identifier_start(&self, input: &mut ParserContext) -> bool { + fn identifier_start(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_chars!(input, '_'), @@ -7697,7 +7708,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn int_keyword(&self, input: &mut ParserContext) -> bool { + fn int_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'i', 'n', 't'), scan_optional!( @@ -7742,7 +7753,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn multiline_comment(&self, input: &mut ParserContext) -> bool { + fn multiline_comment(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, '/'), scan_chars!(input, '*'), @@ -7760,7 +7771,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn raw_identifier(&self, input: &mut ParserContext) -> bool { + fn raw_identifier(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( self.identifier_start(input), scan_zero_or_more!(input, self.identifier_part(input)) @@ -7768,7 +7779,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn single_line_comment(&self, input: &mut ParserContext) -> bool { + fn single_line_comment(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, '/', '/'), scan_zero_or_more!(input, scan_none_of!(input, '\r', '\n')) @@ -7776,7 +7787,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn single_quoted_ascii_string_literal(&self, input: &mut ParserContext) -> bool { + fn single_quoted_ascii_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, '\''), scan_zero_or_more!( @@ -7794,7 +7805,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn single_quoted_hex_string_literal(&self, input: &mut ParserContext) -> bool { + fn single_quoted_hex_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'h', 'e', 'x', '\''), scan_optional!(input, self.hex_string_contents(input)), @@ -7803,7 +7814,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn single_quoted_unicode_string_literal(&self, input: &mut ParserContext) -> bool { + fn single_quoted_unicode_string_literal(&self, input: &mut ParserContext<'_>) -> bool { if self.version_is_at_least_0_7_0 { scan_sequence!( scan_chars!(input, 'u', 'n', 'i', 'c', 'o', 'd', 'e', '\''), @@ -7823,7 +7834,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn ufixed_keyword(&self, input: &mut ParserContext) -> bool { + fn ufixed_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), @@ -8106,7 +8117,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn uint_keyword(&self, input: &mut ParserContext) -> bool { + fn uint_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'u', 'i', 'n', 't'), scan_optional!( @@ -8151,7 +8162,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unicode_escape(&self, input: &mut ParserContext) -> bool { + fn unicode_escape(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'u'), self.hex_character(input), @@ -8162,7 +8173,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unicode_string_literal(&self, input: &mut ParserContext) -> bool { + fn unicode_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, if self.version_is_at_least_0_7_0 { @@ -8179,7 +8190,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma_value(&self, input: &mut ParserContext) -> bool { + fn version_pragma_value(&self, input: &mut ParserContext<'_>) -> bool { scan_one_or_more!( input, scan_choice!( @@ -8193,7 +8204,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn whitespace(&self, input: &mut ParserContext) -> bool { + fn whitespace(&self, input: &mut ParserContext<'_>) -> bool { scan_one_or_more!( input, scan_choice!(input, scan_chars!(input, ' '), scan_chars!(input, '\t')) @@ -8201,7 +8212,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_bytes_keyword(&self, input: &mut ParserContext) -> bool { + fn yul_bytes_keyword(&self, input: &mut ParserContext<'_>) -> bool { if !self.version_is_at_least_0_7_1 { scan_sequence!( scan_chars!(input, 'b', 'y', 't', 'e', 's'), @@ -8250,7 +8261,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_decimal_literal(&self, input: &mut ParserContext) -> bool { + fn yul_decimal_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_not_followed_by!( input, scan_choice!( @@ -8266,7 +8277,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_fixed_keyword(&self, input: &mut ParserContext) -> bool { + fn yul_fixed_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, if !self.version_is_at_least_0_7_1 { @@ -8561,7 +8572,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_hex_literal(&self, input: &mut ParserContext) -> bool { + fn yul_hex_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_not_followed_by!( input, scan_sequence!( @@ -8573,12 +8584,12 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_identifier(&self, input: &mut ParserContext) -> bool { + fn yul_identifier(&self, input: &mut ParserContext<'_>) -> bool { self.raw_identifier(input) } #[allow(unused_assignments, unused_parens)] - fn yul_int_keyword(&self, input: &mut ParserContext) -> bool { + fn yul_int_keyword(&self, input: &mut ParserContext<'_>) -> bool { if !self.version_is_at_least_0_7_1 { scan_sequence!( scan_chars!(input, 'i', 'n', 't'), @@ -8627,7 +8638,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_ufixed_keyword(&self, input: &mut ParserContext) -> bool { + fn yul_ufixed_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, if !self.version_is_at_least_0_7_1 { @@ -8922,7 +8933,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_uint_keyword(&self, input: &mut ParserContext) -> bool { + fn yul_uint_keyword(&self, input: &mut ParserContext<'_>) -> bool { if !self.version_is_at_least_0_7_1 { scan_sequence!( scan_chars!(input, 'u', 'i', 'n', 't'), @@ -9223,11 +9234,11 @@ impl Language { } impl Lexer for Language { - fn leading_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { Language::leading_trivia(self, input) } - fn trailing_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { Language::trailing_trivia(self, input) } @@ -9246,7 +9257,10 @@ impl Lexer for Language { } } - fn next_token(&self, input: &mut ParserContext) -> Option { + fn next_token( + &self, + input: &mut ParserContext<'_>, + ) -> Option { let save = input.position(); let mut furthest_position = input.position(); let mut longest_token = None; @@ -11434,6 +11448,8 @@ impl Lexer for Language { } #[cfg(feature = "slang_napi_interfaces")] +// NAPI-exposed functions have to accept owned values. +#[allow(clippy::needless_pass_by_value)] #[napi(namespace = "language")] impl Language { #[napi(constructor)] diff --git a/crates/solidity/outputs/cargo/crate/src/generated/lexer.rs b/crates/solidity/outputs/cargo/crate/src/generated/lexer.rs index 4661f4e2b7..0457cfdc70 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/lexer.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/lexer.rs @@ -9,18 +9,24 @@ use crate::{ pub trait Lexer { // Generated by the templating engine #[doc(hidden)] - fn next_token(&self, input: &mut ParserContext) -> Option; + fn next_token( + &self, + input: &mut ParserContext<'_>, + ) -> Option; // NOTE: These are context-insensitive #[doc(hidden)] - fn leading_trivia(&self, input: &mut ParserContext) -> ParserResult; + fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; #[doc(hidden)] - fn trailing_trivia(&self, input: &mut ParserContext) -> ParserResult; + fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; #[doc(hidden)] /// Returns valid grouping delimiters in the given lexical context. fn delimiters() -> &'static [(TokenKind, TokenKind)]; /// Peeks the next token, including trivia. Does not advance the input. - fn peek_token(&self, input: &mut ParserContext) -> Option { + fn peek_token( + &self, + input: &mut ParserContext<'_>, + ) -> Option { let start = input.position(); let token = self.next_token::(input); input.set_position(start); @@ -30,7 +36,7 @@ pub trait Lexer { /// Peeks the next significant (i.e. non-trivia) token. Does not advance the input. fn peek_token_with_trivia( &self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, ) -> Option { let start = input.position(); @@ -44,7 +50,7 @@ pub trait Lexer { /// Attempts to consume the next expected token. Advances the input only if the token matches. fn parse_token( &self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, kind: TokenKind, ) -> ParserResult { let start = input.position(); @@ -64,7 +70,7 @@ pub trait Lexer { /// Advances the input only if the token matches. fn parse_token_with_trivia( &self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, kind: TokenKind, ) -> ParserResult { let mut children = vec![]; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cursor.rs b/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cursor.rs index 7ea067c144..9a531b242d 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cursor.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cursor.rs @@ -1,5 +1,10 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +// NAPI-exposed functions have to accept owned values +#![allow(clippy::needless_pass_by_value)] +// The functions are meant to be definitions for export, so they're not really used +#![allow(clippy::return_self_not_must_use)] + use { napi::{bindgen_prelude::Env, JsObject}, napi_derive::napi, @@ -26,12 +31,12 @@ impl Cursor { #[napi] pub fn reset(&mut self) { - self.0.reset() + self.0.reset(); } #[napi] pub fn complete(&mut self) { - self.0.complete() + self.0.complete(); } #[napi] @@ -65,6 +70,7 @@ impl Cursor { (&self.0.text_range()).into() } + #[allow(clippy::cast_possible_truncation)] // Cursor depth can't reasonably be larger than u32 #[napi(getter)] pub fn depth(&self) -> u32 { self.0.depth() as u32 diff --git a/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_parse_error.rs b/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_parse_error.rs index 1013a69213..1b1959dcaf 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_parse_error.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_parse_error.rs @@ -1,5 +1,8 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +// NAPI-exposed functions have to accept owned values. +#![allow(clippy::needless_pass_by_value)] + use napi_derive::napi; use super::{napi_text_index, RustParseError}; @@ -23,11 +26,7 @@ impl ParseError { } pub fn tokens_that_would_have_allowed_more_progress(&self) -> Vec { - self.0 - .tokens_that_would_have_allowed_more_progress() - .iter() - .map(|x| x.to_string()) - .collect() + self.0.tokens_that_would_have_allowed_more_progress() } #[napi(namespace = "parse_error")] diff --git a/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_text_index.rs b/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_text_index.rs index 64f69d576a..e95cad36f2 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_text_index.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_text_index.rs @@ -14,6 +14,8 @@ pub struct TextIndex { impl From<&RustTextIndex> for TextIndex { fn from(value: &RustTextIndex) -> Self { + // We only support 32-byte indices on TS side. + #[allow(clippy::cast_possible_truncation)] Self { utf8: value.utf8 as u32, utf16: value.utf16 as u32, diff --git a/crates/solidity/outputs/cargo/crate/src/generated/parse_error.rs b/crates/solidity/outputs/cargo/crate/src/generated/parse_error.rs index fce07cfa9a..7a7282b328 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/parse_error.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/parse_error.rs @@ -22,12 +22,11 @@ impl ParseError { let tokens_that_would_have_allowed_more_progress = self .tokens_that_would_have_allowed_more_progress .iter() - .map(|kind| kind.as_ref()) .collect::>(); tokens_that_would_have_allowed_more_progress .into_iter() - .map(|token| token.to_string()) + .map(TokenKind::to_string) .collect() } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/choice_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/choice_helper.rs index 412d7b32fd..022982185c 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/choice_helper.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/choice_helper.rs @@ -20,7 +20,7 @@ pub struct ChoiceHelper { } impl ChoiceHelper { - pub fn new(input: &mut ParserContext) -> Self { + pub fn new(input: &mut ParserContext<'_>) -> Self { Self { result: ParserResult::no_match(vec![]), start_position: input.mark(), @@ -39,7 +39,7 @@ impl ChoiceHelper { } /// Store the next result if it's a better match; otherwise, we retain the existing one. - fn attempt_pick(&mut self, input: &mut ParserContext, next_result: ParserResult) { + fn attempt_pick(&mut self, input: &mut ParserContext<'_>, next_result: ParserResult) { let better_pick = match (&mut self.result, &next_result) { // We settle for the first full match. (ParserResult::Match(running), _) if running.is_full_recursive() => { @@ -56,10 +56,8 @@ impl ChoiceHelper { running.expected_tokens.extend(next.expected_tokens.clone()); false } - // Otherwise, we have some match and we ignore a missing next one. - (ParserResult::IncompleteMatch(..), ParserResult::NoMatch(..)) - | (ParserResult::SkippedUntil(..), ParserResult::NoMatch(..)) - | (ParserResult::Match(..), ParserResult::NoMatch(..)) => false, + // Otherwise, we already have some match, so we ignore a next missing one. + (_, ParserResult::NoMatch(..)) => false, // Try to improve our match. (_, ParserResult::Match(next)) if next.is_full_recursive() => true, @@ -82,8 +80,8 @@ impl ChoiceHelper { /// /// Useful when you want to eagerly return a result from the parse function (e.g. when the choice was fully matched). pub fn run( - input: &mut ParserContext, - f: impl FnOnce(Self, &mut ParserContext) -> ControlFlow, + input: &mut ParserContext<'_>, + f: impl FnOnce(Self, &mut ParserContext<'_>) -> ControlFlow, ) -> ParserResult { match f(ChoiceHelper::new(input), input) { ControlFlow::Break(result) => result, @@ -98,7 +96,7 @@ impl ChoiceHelper { /// If a value is considered as a full match, it is returned, otherwise we backtrack and continue. pub fn consider( &mut self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, value: ParserResult, ) -> ControlFlow { self.attempt_pick(input, value); @@ -112,7 +110,7 @@ impl ChoiceHelper { } /// Finishes the choice parse, returning the accumulated match. - pub fn finish(self, input: &mut ParserContext) -> ControlFlow { + pub fn finish(self, input: &mut ParserContext<'_>) -> ControlFlow { assert!(!self.is_done()); // We didn't break early, so undo the rewind that has happened in the meantime. input.set_position(self.last_progress); diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/context.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/context.rs index 3d787cecaa..1e3b5fa86a 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/context.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/context.rs @@ -32,7 +32,7 @@ impl<'s> ParserContext<'s> { pub fn new(source: &'s str) -> Self { Self { source, - position: Default::default(), + position: TextIndex::ZERO, undo_position: None, errors: vec![], closing_delimiters: vec![], diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/parser_function.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/parser_function.rs index 52deea1703..08b1f69d8f 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/parser_function.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/parser_function.rs @@ -13,14 +13,14 @@ use super::{ pub trait ParserFunction where - Self: Fn(&L, &mut ParserContext) -> ParserResult, + Self: Fn(&L, &mut ParserContext<'_>) -> ParserResult, { fn parse(&self, language: &L, input: &str) -> ParseOutput; } impl ParserFunction for F where - F: Fn(&L, &mut ParserContext) -> ParserResult, + F: Fn(&L, &mut ParserContext<'_>) -> ParserResult, { fn parse(&self, language: &L, input: &str) -> ParseOutput { let mut stream = ParserContext::new(input); @@ -35,7 +35,7 @@ where ParserResult::NoMatch(no_match) => ParseOutput { parse_tree: cst::Node::token(TokenKind::SKIPPED, input.to_string()), errors: vec![ParseError::new_covering_range( - Default::default()..input.into(), + TextIndex::ZERO..input.into(), no_match.expected_tokens, )], }, diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/parser_result.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/parser_result.rs index f88dfcfae2..49e7f51785 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/parser_result.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/parser_result.rs @@ -56,6 +56,7 @@ impl ParserResult { matches!(self, ParserResult::NoMatch(_)) } + #[must_use] pub fn with_kind(self, new_kind: RuleKind) -> ParserResult { match self { ParserResult::Match(r#match) => ParserResult::r#match( diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs index 0e71667e81..0ee251bda3 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs @@ -4,7 +4,7 @@ use super::{ super::{cst, kinds::RuleKind}, parser_result::{ ParserResult, - PrattElement::{self, *}, + PrattElement::{self, Binary, Expression, Postfix, Prefix}, }, }; @@ -58,6 +58,8 @@ impl PrecedenceHelper { _ => result, } } + + #[allow(clippy::too_many_lines)] // Explicit on purpose, see below. pub fn reduce_precedence_result( child_kind: Option, result: ParserResult, @@ -69,6 +71,7 @@ impl PrecedenceHelper { // If the input is valid this should be correct by construction. + #[allow(clippy::redundant_else)] match result { ParserResult::PrattOperatorMatch(pratt_operator_match) => { let mut pratt_elements = pratt_operator_match.elements; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/recovery.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/recovery.rs index d6d3e1016b..d3e158ed02 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/recovery.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/recovery.rs @@ -11,20 +11,21 @@ use super::parser_result::SkippedUntil; use super::ParserContext; /// An explicit parameter for the [`ParserResult::recover_until_with_nested_delims`] method. +#[derive(Clone, Copy)] pub enum RecoverFromNoMatch { Yes, No, } impl RecoverFromNoMatch { - pub fn as_bool(&self) -> bool { + pub fn as_bool(self) -> bool { matches!(self, RecoverFromNoMatch::Yes) } } fn opt_parse( - input: &mut ParserContext, - parse: impl Fn(&mut ParserContext) -> ParserResult, + input: &mut ParserContext<'_>, + parse: impl Fn(&mut ParserContext<'_>) -> ParserResult, ) -> Vec { let start = input.position(); if let ParserResult::Match(r#match) = parse(input) { @@ -42,21 +43,22 @@ impl ParserResult { /// /// Respects nested delimiters, i.e. the `expected` token is only accepted if it's not nested inside. /// Does not consume the `expected` token. + #[must_use] pub fn recover_until_with_nested_delims( self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, lexer: &L, expected: TokenKind, recover_from_no_match: RecoverFromNoMatch, ) -> ParserResult { - let before_recovery = input.position(); - enum ParseResultKind { Match, Incomplete, NoMatch, } + let before_recovery = input.position(); + let (mut nodes, mut expected_tokens, result_kind) = match self { ParserResult::IncompleteMatch(result) => ( result.nodes, @@ -77,38 +79,37 @@ impl ParserResult { let leading_trivia = opt_parse(input, |input| lexer.leading_trivia(input)); - match skip_until_with_nested_delims::<_, LexCtx>(input, lexer, expected) { - Some((found, skipped_range)) => { - nodes.extend(leading_trivia); - if matches!(result_kind, ParseResultKind::Match) { - expected_tokens.push(expected); - } + if let Some((found, skipped_range)) = + skip_until_with_nested_delims::<_, LexCtx>(input, lexer, expected) + { + nodes.extend(leading_trivia); + if matches!(result_kind, ParseResultKind::Match) { + expected_tokens.push(expected); + } - let skipped = input.content(skipped_range.utf8()); + let skipped = input.content(skipped_range.utf8()); - input.emit(ParseError { - text_range: skipped_range, - tokens_that_would_have_allowed_more_progress: expected_tokens.clone(), - }); + input.emit(ParseError { + text_range: skipped_range, + tokens_that_would_have_allowed_more_progress: expected_tokens.clone(), + }); - ParserResult::SkippedUntil(SkippedUntil { - nodes, - expected, - skipped, - found, - }) - } + ParserResult::SkippedUntil(SkippedUntil { + nodes, + skipped, + found, + expected, + }) + } else { // Not found till EOF, revert any recovery attempt - None => { - input.set_position(before_recovery); - - match result_kind { - ParseResultKind::Match => ParserResult::r#match(nodes, expected_tokens), - ParseResultKind::Incomplete => { - ParserResult::incomplete_match(nodes, expected_tokens) - } - ParseResultKind::NoMatch => ParserResult::no_match(expected_tokens), + input.set_position(before_recovery); + + match result_kind { + ParseResultKind::Match => ParserResult::r#match(nodes, expected_tokens), + ParseResultKind::Incomplete => { + ParserResult::incomplete_match(nodes, expected_tokens) } + ParseResultKind::NoMatch => ParserResult::no_match(expected_tokens), } } } @@ -120,7 +121,7 @@ impl ParserResult { /// /// Returns the found token and the range of skipped tokens on success. pub fn skip_until_with_nested_delims( - input: &mut ParserContext, + input: &mut ParserContext<'_>, lexer: &L, until: TokenKind, ) -> Option<(TokenKind, TextRange)> { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/repetition_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/repetition_helper.rs index ba430364a1..a60b04bb80 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/repetition_helper.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/repetition_helper.rs @@ -11,8 +11,8 @@ pub type ZeroOrMoreHelper = RepetitionHelper<0>; pub type OneOrMoreHelper = RepetitionHelper<1>; impl RepetitionHelper { - pub fn run ParserResult>( - input: &mut ParserContext, + pub fn run) -> ParserResult>( + input: &mut ParserContext<'_>, parser: F, ) -> ParserResult { if MIN_COUNT > 1 { @@ -28,9 +28,7 @@ impl RepetitionHelper { // Couldn't get a full match but we allow 0 items - return an empty match // so the parse is considered valid but note the expected tokens - ParserResult::NoMatch(NoMatch { - expected_tokens, .. - }) if MIN_COUNT == 0 => { + ParserResult::NoMatch(NoMatch { expected_tokens }) if MIN_COUNT == 0 => { return ParserResult::r#match(vec![], expected_tokens); } // Don't try repeating if we don't have a full match and we require at least one @@ -86,7 +84,9 @@ impl RepetitionHelper { return ParserResult::SkippedUntil(skipped); } - (ParserResult::PrattOperatorMatch(..), ParserResult::SkippedUntil(_)) => todo!(), + (ParserResult::PrattOperatorMatch(..), ParserResult::SkippedUntil(_)) => { + unreachable!("We don't do recovery when reducing the Pratt matches") + } ( ParserResult::IncompleteMatch(..) diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/scanner_macros.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/scanner_macros.rs index cd8c824e35..8bc08d4c11 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/scanner_macros.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/scanner_macros.rs @@ -85,6 +85,7 @@ macro_rules! scan_zero_or_more { macro_rules! scan_one_or_more { ($stream:ident, $scanner:expr) => {{ let mut count = 0; + #[allow(clippy::redundant_else)] loop { let save = $stream.position(); if !($scanner) { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/separated_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/separated_helper.rs index 5447bbb533..5e5efa5f0a 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/separated_helper.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/separated_helper.rs @@ -17,9 +17,9 @@ pub struct SeparatedHelper; impl SeparatedHelper { pub fn run( - input: &mut ParserContext, + input: &mut ParserContext<'_>, lexer: &L, - body_parser: impl Fn(&mut ParserContext) -> ParserResult, + body_parser: impl Fn(&mut ParserContext<'_>) -> ParserResult, separator: TokenKind, ) -> ParserResult { let mut accum = vec![]; @@ -88,11 +88,11 @@ impl SeparatedHelper { } } ParserResult::NoMatch(no_match) => { - if accum.is_empty() { - return ParserResult::no_match(no_match.expected_tokens); + return if accum.is_empty() { + ParserResult::no_match(no_match.expected_tokens) } else { - return ParserResult::incomplete_match(accum, no_match.expected_tokens); - } + ParserResult::incomplete_match(accum, no_match.expected_tokens) + }; } ParserResult::SkippedUntil(skipped) => { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/sequence_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/sequence_helper.rs index decdee623f..b968bda06c 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/sequence_helper.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/sequence_helper.rs @@ -35,6 +35,7 @@ impl SequenceHelper { ) } + #[allow(clippy::too_many_lines)] // Big switch that purely defines the sequence logic /// Attempts to append the next result until we hit an incomplete/no match. fn attempt_append(&mut self, next_result: ParserResult) { match self.result { @@ -95,7 +96,7 @@ impl SequenceHelper { self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut cur.elements) .into_iter() - .flat_map(|pratt| pratt.into_nodes()) + .flat_map(PrattElement::into_nodes) .chain(next.nodes) .collect(), next.expected_tokens, @@ -105,7 +106,7 @@ impl SequenceHelper { self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut cur.elements) .into_iter() - .flat_map(|pratt| pratt.into_nodes()) + .flat_map(PrattElement::into_nodes) .collect(), next.expected_tokens, )); diff --git a/crates/solidity/outputs/cargo/crate/src/main.rs b/crates/solidity/outputs/cargo/crate/src/main.rs index 71787d2ec1..54d31402e2 100644 --- a/crates/solidity/outputs/cargo/crate/src/main.rs +++ b/crates/solidity/outputs/cargo/crate/src/main.rs @@ -1,4 +1,4 @@ -use std::{fs, path::PathBuf}; +use std::{fs, path::PathBuf, process::ExitCode}; use anyhow::{Context, Result}; use clap::{Parser as ClapParser, Subcommand}; @@ -42,17 +42,17 @@ enum Commands { }, } -fn main() -> Result<()> { +fn main() -> Result { match Cli::parse().command { Commands::Parse { file_path, version, json, - } => execute_parse_command(file_path, version, json), + } => execute_parse_command(&file_path, version, json), } } -fn execute_parse_command(file_path_string: String, version: Version, json: bool) -> Result<()> { +fn execute_parse_command(file_path_string: &str, version: Version, json: bool) -> Result { let file_path = PathBuf::from(&file_path_string) .canonicalize() .with_context(|| format!("Failed to find file path: {file_path_string:?}"))?; @@ -63,7 +63,7 @@ fn execute_parse_command(file_path_string: String, version: Version, json: bool) let errors = output.errors(); for error in errors { - let report = error.to_error_report(&file_path_string, &input, /* with_color */ true); + let report = error.to_error_report(file_path_string, &input, /* with_color */ true); eprintln!("{report}"); } @@ -73,11 +73,12 @@ fn execute_parse_command(file_path_string: String, version: Version, json: bool) println!("{json}"); } - if !errors.is_empty() { - std::process::exit(1); + if errors.is_empty() { + Ok(ExitCode::SUCCESS) + } else { + eprintln!("Couldn't parse the Solidity source file."); + Ok(ExitCode::FAILURE) } - - Ok(()) } #[test] diff --git a/crates/solidity/outputs/npm/crate/src/generated/cst.rs b/crates/solidity/outputs/npm/crate/src/generated/cst.rs index b4d799140c..a85816fc3a 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/cst.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/cst.rs @@ -75,29 +75,29 @@ impl Node { pub fn as_rule(&self) -> Option<&Rc> { match self { - Self::Rule(node) => Some(node), - _ => None, + Self::Rule(rule) => Some(rule), + Self::Token(..) => None, } } pub fn into_rule(self) -> Option> { match self { - Self::Rule(node) => Some(node), - _ => None, + Self::Rule(rule) => Some(rule), + Self::Token(..) => None, } } pub fn as_token(&self) -> Option<&Rc> { match self { - Self::Token(node) => Some(node), - _ => None, + Self::Token(token) => Some(token), + Self::Rule(..) => None, } } pub fn into_token(self) -> Option> { match self { - Self::Token(node) => Some(node), - _ => None, + Self::Token(token) => Some(token), + Self::Rule(..) => None, } } diff --git a/crates/solidity/outputs/npm/crate/src/generated/cursor.rs b/crates/solidity/outputs/npm/crate/src/generated/cursor.rs index a8c95ace34..2b64bdada7 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/cursor.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/cursor.rs @@ -118,6 +118,7 @@ impl Cursor { /// Unlike `clone`, this re-roots at the current node. /// It does preserve the correct text offset however, /// even though the path is reset. + #[must_use] pub fn spawn(&self) -> Self { Self { path: vec![], @@ -207,17 +208,14 @@ impl Cursor { /// /// Returns `false` if the cursor is finished and at the root. pub fn go_to_parent(&mut self) -> bool { - match self.path.pop() { - Some(parent) => { - self.current = parent.into_path_node(); + if let Some(parent) = self.path.pop() { + self.current = parent.into_path_node(); - true - } - None => { - self.is_completed = true; + true + } else { + self.is_completed = true; - false - } + false } } @@ -292,7 +290,7 @@ impl Cursor { let text_offset = parent.text_offset + parent.rule_node.children[..child_number] .iter() - .map(|child| child.text_len()) + .map(Node::text_len) .sum(); self.path.push(parent); diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index 122fe15bfc..183df95f28 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -1,5 +1,14 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +// This file is generated; we can't reasonably satisfy some of these lints. +#![allow( + clippy::if_not_else, + clippy::too_many_lines, + clippy::unused_self, + clippy::struct_excessive_bools, + clippy::similar_names +)] + #[cfg(feature = "slang_napi_interfaces")] use {napi::bindgen_prelude::*, napi_derive::napi}; @@ -185,7 +194,7 @@ impl Language { ********************************************/ #[allow(unused_assignments, unused_parens)] - fn abi_coder_pragma(&self, input: &mut ParserContext) -> ParserResult { + fn abi_coder_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -201,7 +210,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn address_type(&self, input: &mut ParserContext) -> ParserResult { + fn address_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -219,7 +228,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn array_expression(&self, input: &mut ParserContext) -> ParserResult { + fn array_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBracket); let input = delim_guard.ctx(); @@ -246,7 +255,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn array_values(&self, input: &mut ParserContext) -> ParserResult { + fn array_values(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -257,7 +266,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn ascii_string_literals(&self, input: &mut ParserContext) -> ParserResult { + fn ascii_string_literals(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { self.parse_token_with_trivia::( input, @@ -268,7 +277,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn assembly_flags(&self, input: &mut ParserContext) -> ParserResult { + fn assembly_flags(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -284,7 +293,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn assembly_flags_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn assembly_flags_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -311,7 +320,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn assembly_statement(&self, input: &mut ParserContext) -> ParserResult { + fn assembly_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -333,7 +342,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn block(&self, input: &mut ParserContext) -> ParserResult { + fn block(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); @@ -360,7 +369,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn break_statement(&self, input: &mut ParserContext) -> ParserResult { + fn break_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -384,7 +393,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn catch_clause(&self, input: &mut ParserContext) -> ParserResult { + fn catch_clause(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -402,7 +411,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn catch_clause_error(&self, input: &mut ParserContext) -> ParserResult { + fn catch_clause_error(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform( @@ -421,7 +430,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn catch_clauses(&self, input: &mut ParserContext) -> ParserResult { + fn catch_clauses(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| self.catch_clause(input)) } else { @@ -431,7 +440,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn constant_definition(&self, input: &mut ParserContext) -> ParserResult { + fn constant_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_7_4 { SequenceHelper::run(|mut seq| { seq.elem( @@ -472,7 +481,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn constructor_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn constructor_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_4_22 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_4_22 { @@ -507,7 +516,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn constructor_definition(&self, input: &mut ParserContext) -> ParserResult { + fn constructor_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_4_22 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -528,7 +537,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn continue_statement(&self, input: &mut ParserContext) -> ParserResult { + fn continue_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -552,7 +561,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn contract_definition(&self, input: &mut ParserContext) -> ParserResult { + fn contract_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { if self.version_is_at_least_0_6_0 { seq.elem(OptionalHelper::transform( @@ -599,7 +608,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn contract_members(&self, input: &mut ParserContext) -> ParserResult { + fn contract_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.using_directive(input); @@ -647,7 +656,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn decimal_number_expression(&self, input: &mut ParserContext) -> ParserResult { + fn decimal_number_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -728,7 +737,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn delete_statement(&self, input: &mut ParserContext) -> ParserResult { + fn delete_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -756,7 +765,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn do_while_statement(&self, input: &mut ParserContext) -> ParserResult { + fn do_while_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -858,7 +867,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn else_branch(&self, input: &mut ParserContext) -> ParserResult { + fn else_branch(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -919,7 +928,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn emit_statement(&self, input: &mut ParserContext) -> ParserResult { + fn emit_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_4_21 { SequenceHelper::run(|mut seq| { seq.elem( @@ -958,7 +967,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn end_of_file_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn end_of_file_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = @@ -982,7 +991,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn enum_definition(&self, input: &mut ParserContext) -> ParserResult { + fn enum_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -1020,7 +1029,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn enum_members(&self, input: &mut ParserContext) -> ParserResult { + fn enum_members(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -1036,7 +1045,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn error_definition(&self, input: &mut ParserContext) -> ParserResult { + fn error_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SequenceHelper::run(|mut seq| { seq.elem( @@ -1072,7 +1081,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn error_parameter(&self, input: &mut ParserContext) -> ParserResult { + fn error_parameter(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; @@ -1091,7 +1100,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn error_parameters(&self, input: &mut ParserContext) -> ParserResult { + fn error_parameters(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SeparatedHelper::run::<_, LexicalContextType::Default>( input, @@ -1106,7 +1115,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn error_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn error_parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); @@ -1137,7 +1146,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn event_definition(&self, input: &mut ParserContext) -> ParserResult { + fn event_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -1175,7 +1184,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn event_parameter(&self, input: &mut ParserContext) -> ParserResult { + fn event_parameter(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; seq.elem(OptionalHelper::transform( @@ -1196,7 +1205,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn event_parameters(&self, input: &mut ParserContext) -> ParserResult { + fn event_parameters(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -1207,7 +1216,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn event_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn event_parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -1234,7 +1243,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn experimental_pragma(&self, input: &mut ParserContext) -> ParserResult { + fn experimental_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -1259,9 +1268,9 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn expression(&self, input: &mut ParserContext) -> ParserResult { + fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 1u8, @@ -1332,7 +1341,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 3u8, @@ -1403,7 +1412,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 5u8, @@ -1474,7 +1483,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 7u8, @@ -1545,7 +1554,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 9u8, @@ -1616,7 +1625,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 11u8, @@ -1687,7 +1696,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 13u8, @@ -1758,7 +1767,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 15u8, @@ -1829,7 +1838,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 17u8, @@ -1900,7 +1909,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 19u8, @@ -1971,7 +1980,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 21u8, @@ -2042,7 +2051,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 23u8, @@ -2113,7 +2122,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_conditional_expression = |input: &mut ParserContext| { + let parse_conditional_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::ConditionalExpression, 25u8, @@ -2133,7 +2142,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_or_expression = |input: &mut ParserContext| { + let parse_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 27u8, @@ -2145,7 +2154,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_and_expression = |input: &mut ParserContext| { + let parse_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 29u8, @@ -2157,7 +2166,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext| { + let parse_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 31u8, @@ -2178,7 +2187,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext| { + let parse_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 33u8, @@ -2199,7 +2208,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 35u8, @@ -2230,7 +2239,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 37u8, @@ -2261,7 +2270,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 39u8, @@ -2292,7 +2301,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 41u8, @@ -2323,7 +2332,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_bitwise_or_expression = |input: &mut ParserContext| { + let parse_bitwise_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 43u8, @@ -2332,7 +2341,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_bitwise_xor_expression = |input: &mut ParserContext| { + let parse_bitwise_xor_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 45u8, @@ -2344,7 +2353,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_bitwise_and_expression = |input: &mut ParserContext| { + let parse_bitwise_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 47u8, @@ -2356,7 +2365,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext| { + let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 49u8, @@ -2382,7 +2391,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext| { + let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 51u8, @@ -2408,7 +2417,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext| { + let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 53u8, @@ -2434,7 +2443,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext| { + let parse_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 55u8, @@ -2455,7 +2464,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext| { + let parse_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 57u8, @@ -2476,7 +2485,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext| { + let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 59u8, @@ -2502,7 +2511,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext| { + let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 61u8, @@ -2528,7 +2537,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext| { + let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 63u8, @@ -2554,7 +2563,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 65u8, @@ -2579,7 +2588,9 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext< + '_, + >| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 67u8 + 1, @@ -2604,7 +2615,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext| { + let parse_postfix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::UnaryPostfixExpression, 69u8, @@ -2624,7 +2635,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext| { + let parse_postfix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::UnaryPostfixExpression, 71u8, @@ -2644,7 +2655,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext| { + let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 73u8, @@ -2686,7 +2697,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext| { + let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 75u8, @@ -2728,7 +2739,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext| { + let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 77u8, @@ -2770,7 +2781,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext| { + let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 79u8, @@ -2812,7 +2823,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext| { + let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 81u8, @@ -2854,7 +2865,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext| { + let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 83u8, @@ -2896,7 +2907,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_function_call_expression = |input: &mut ParserContext| { + let parse_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::FunctionCallExpression, 85u8, @@ -2934,7 +2945,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_member_access_expression = |input: &mut ParserContext| { + let parse_member_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, 87u8, @@ -2961,7 +2972,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_index_access_expression = |input: &mut ParserContext| { + let parse_index_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, 89u8, @@ -2994,7 +3005,7 @@ impl Language { ) }; #[allow(unused_variables)] - let prefix_operator_parser = |input: &mut ParserContext| { + let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_prefix_expression(input); choice.consider(input, result)?; @@ -3014,7 +3025,7 @@ impl Language { }) }; #[allow(unused_variables)] - let primary_expression_parser = |input: &mut ParserContext| { + let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.new_expression(input); choice.consider(input, result)?; @@ -3114,7 +3125,7 @@ impl Language { }) }; #[allow(unused_variables)] - let postfix_operator_parser = |input: &mut ParserContext| { + let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_conditional_expression(input); choice.consider(input, result)?; @@ -3132,7 +3143,7 @@ impl Language { }) }; #[allow(unused_variables)] - let binary_operand_parser = |input: &mut ParserContext| { + let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(ZeroOrMoreHelper::run(input, |input| { prefix_operator_parser(input) @@ -3145,7 +3156,7 @@ impl Language { }) }; #[allow(unused_variables)] - let binary_operator_parser = |input: &mut ParserContext| { + let binary_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_assignment_expression(input); choice.consider(input, result)?; @@ -3221,7 +3232,7 @@ impl Language { }) }; #[allow(unused_variables)] - let linear_expression_parser = |input: &mut ParserContext| { + let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; seq.elem(ZeroOrMoreHelper::run(input, |input| { @@ -3242,7 +3253,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn expression_statement(&self, input: &mut ParserContext) -> ParserResult { + fn expression_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.expression(input) @@ -3263,7 +3274,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn fallback_function_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn fallback_function_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_6_0 { @@ -3310,7 +3321,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn fallback_function_definition(&self, input: &mut ParserContext) -> ParserResult { + fn fallback_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -3341,7 +3352,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn for_statement(&self, input: &mut ParserContext) -> ParserResult { + fn for_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3453,7 +3464,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn function_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn function_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.modifier_invocation(input); @@ -3516,7 +3527,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn function_definition(&self, input: &mut ParserContext) -> ParserResult { + fn function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3559,7 +3570,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn function_type(&self, input: &mut ParserContext) -> ParserResult { + fn function_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3576,7 +3587,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn function_type_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn function_type_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -3621,7 +3632,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_number_expression(&self, input: &mut ParserContext) -> ParserResult { + fn hex_number_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3708,7 +3719,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_string_literals(&self, input: &mut ParserContext) -> ParserResult { + fn hex_string_literals(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { self.parse_token_with_trivia::( input, @@ -3719,7 +3730,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn identifier_path(&self, input: &mut ParserContext) -> ParserResult { + fn identifier_path(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -3735,7 +3746,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn if_statement(&self, input: &mut ParserContext) -> ParserResult { + fn if_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3819,7 +3830,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn import_alias(&self, input: &mut ParserContext) -> ParserResult { + fn import_alias(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3835,7 +3846,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn import_deconstruction(&self, input: &mut ParserContext) -> ParserResult { + fn import_deconstruction(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); @@ -3873,7 +3884,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn import_deconstruction_symbol(&self, input: &mut ParserContext) -> ParserResult { + fn import_deconstruction_symbol(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3886,7 +3897,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn import_deconstruction_symbols(&self, input: &mut ParserContext) -> ParserResult { + fn import_deconstruction_symbols(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -3897,7 +3908,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn import_directive(&self, input: &mut ParserContext) -> ParserResult { + fn import_directive(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -3933,7 +3944,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn index_access_end(&self, input: &mut ParserContext) -> ParserResult { + fn index_access_end(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -3948,7 +3959,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn inheritance_specifier(&self, input: &mut ParserContext) -> ParserResult { + fn inheritance_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -3961,7 +3972,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn inheritance_type(&self, input: &mut ParserContext) -> ParserResult { + fn inheritance_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; seq.elem(OptionalHelper::transform(ChoiceHelper::run( @@ -3980,7 +3991,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn inheritance_types(&self, input: &mut ParserContext) -> ParserResult { + fn inheritance_types(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -3991,7 +4002,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn interface_definition(&self, input: &mut ParserContext) -> ParserResult { + fn interface_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4030,7 +4041,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn interface_members(&self, input: &mut ParserContext) -> ParserResult { + fn interface_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.using_directive(input); @@ -4078,7 +4089,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn leading_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = @@ -4102,7 +4113,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn library_definition(&self, input: &mut ParserContext) -> ParserResult { + fn library_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4140,7 +4151,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn library_members(&self, input: &mut ParserContext) -> ParserResult { + fn library_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.using_directive(input); @@ -4188,7 +4199,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn mapping_key(&self, input: &mut ParserContext) -> ParserResult { + fn mapping_key(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(ChoiceHelper::run(input, |mut choice, input| { let result = ChoiceHelper::run(input, |mut choice, input| { @@ -4262,7 +4273,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn mapping_type(&self, input: &mut ParserContext) -> ParserResult { + fn mapping_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4304,7 +4315,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn mapping_value(&self, input: &mut ParserContext) -> ParserResult { + fn mapping_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; if self.version_is_at_least_0_8_18 { @@ -4321,7 +4332,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn modifier_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn modifier_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.override_specifier(input); @@ -4340,7 +4351,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn modifier_definition(&self, input: &mut ParserContext) -> ParserResult { + fn modifier_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4370,7 +4381,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn modifier_invocation(&self, input: &mut ParserContext) -> ParserResult { + fn modifier_invocation(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; seq.elem(OptionalHelper::transform(ChoiceHelper::run( @@ -4389,7 +4400,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_argument(&self, input: &mut ParserContext) -> ParserResult { + fn named_argument(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4408,7 +4419,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_argument_group(&self, input: &mut ParserContext) -> ParserResult { + fn named_argument_group(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); @@ -4435,7 +4446,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_argument_groups(&self, input: &mut ParserContext) -> ParserResult { + fn named_argument_groups(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { OneOrMoreHelper::run(input, |input| self.named_argument_group(input)) } else { @@ -4445,7 +4456,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_arguments(&self, input: &mut ParserContext) -> ParserResult { + fn named_arguments(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -4456,7 +4467,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn named_arguments_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -4483,7 +4494,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn named_import(&self, input: &mut ParserContext) -> ParserResult { + fn named_import(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4504,7 +4515,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn new_expression(&self, input: &mut ParserContext) -> ParserResult { + fn new_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4517,7 +4528,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn override_paths(&self, input: &mut ParserContext) -> ParserResult { + fn override_paths(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -4528,7 +4539,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn override_paths_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn override_paths_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -4555,7 +4566,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn override_specifier(&self, input: &mut ParserContext) -> ParserResult { + fn override_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4570,7 +4581,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn parameter(&self, input: &mut ParserContext) -> ParserResult { + fn parameter(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; seq.elem(OptionalHelper::transform(ChoiceHelper::run( @@ -4608,7 +4619,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn parameters(&self, input: &mut ParserContext) -> ParserResult { + fn parameters(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -4619,7 +4630,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -4646,7 +4657,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn path_import(&self, input: &mut ParserContext) -> ParserResult { + fn path_import(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4659,7 +4670,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn positional_arguments(&self, input: &mut ParserContext) -> ParserResult { + fn positional_arguments(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -4670,7 +4681,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn positional_arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn positional_arguments_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -4697,7 +4708,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn pragma_directive(&self, input: &mut ParserContext) -> ParserResult { + fn pragma_directive(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -4733,7 +4744,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn receive_function_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn receive_function_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_6_0 { @@ -4770,7 +4781,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn receive_function_definition(&self, input: &mut ParserContext) -> ParserResult { + fn receive_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -4800,7 +4811,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn return_statement(&self, input: &mut ParserContext) -> ParserResult { + fn return_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -4828,7 +4839,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn returns_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn returns_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -4841,7 +4852,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn revert_statement(&self, input: &mut ParserContext) -> ParserResult { + fn revert_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { SequenceHelper::run(|mut seq| { seq.elem( @@ -4880,7 +4891,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn source_unit(&self, input: &mut ParserContext) -> ParserResult { + fn source_unit(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform(self.source_unit_members(input)))?; seq.elem(OptionalHelper::transform(self.end_of_file_trivia(input)))?; @@ -4890,7 +4901,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn source_unit_members(&self, input: &mut ParserContext) -> ParserResult { + fn source_unit_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.pragma_directive(input); @@ -4942,7 +4953,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn state_variable_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn state_variable_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.override_specifier(input); @@ -4981,7 +4992,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn state_variable_definition(&self, input: &mut ParserContext) -> ParserResult { + fn state_variable_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -5015,7 +5026,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn state_variable_definition_value(&self, input: &mut ParserContext) -> ParserResult { + fn state_variable_definition_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -5030,7 +5041,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn statements(&self, input: &mut ParserContext) -> ParserResult { + fn statements(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.expression_statement(input); @@ -5086,7 +5097,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn struct_definition(&self, input: &mut ParserContext) -> ParserResult { + fn struct_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -5124,7 +5135,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn struct_member(&self, input: &mut ParserContext) -> ParserResult { + fn struct_member(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -5152,13 +5163,13 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn struct_members(&self, input: &mut ParserContext) -> ParserResult { + fn struct_members(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| self.struct_member(input)) .with_kind(RuleKind::StructMembers) } #[allow(unused_assignments, unused_parens)] - fn throw_statement(&self, input: &mut ParserContext) -> ParserResult { + fn throw_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if !self.version_is_at_least_0_5_0 { SequenceHelper::run(|mut seq| { seq.elem( @@ -5186,7 +5197,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn trailing_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform( self.parse_token::(input, TokenKind::Whitespace), @@ -5204,7 +5215,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn try_statement(&self, input: &mut ParserContext) -> ParserResult { + fn try_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -5224,7 +5235,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_deconstruction_element(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_deconstruction_element(&self, input: &mut ParserContext<'_>) -> ParserResult { OptionalHelper::transform(ChoiceHelper::run(input, |mut choice, input| { let result = self.typed_tuple_member(input); choice.consider(input, result)?; @@ -5236,7 +5247,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_deconstruction_elements(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_deconstruction_elements(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -5247,7 +5258,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_deconstruction_statement(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_deconstruction_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -5297,7 +5308,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_expression(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -5324,12 +5335,12 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_value(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_value(&self, input: &mut ParserContext<'_>) -> ParserResult { OptionalHelper::transform(self.expression(input)).with_kind(RuleKind::TupleValue) } #[allow(unused_assignments, unused_parens)] - fn tuple_values(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_values(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, @@ -5340,7 +5351,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn type_expression(&self, input: &mut ParserContext) -> ParserResult { + fn type_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_5_3 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -5378,9 +5389,9 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn type_name(&self, input: &mut ParserContext) -> ParserResult { + fn type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { #[allow(unused_variables)] - let parse_array_type_name = |input: &mut ParserContext| { + let parse_array_type_name = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, @@ -5409,7 +5420,7 @@ impl Language { ) }; #[allow(unused_variables)] - let primary_expression_parser = |input: &mut ParserContext| { + let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.function_type(input); choice.consider(input, result)?; @@ -5474,7 +5485,7 @@ impl Language { }) }; #[allow(unused_variables)] - let postfix_operator_parser = |input: &mut ParserContext| { + let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_array_type_name(input); choice.consider(input, result)?; @@ -5482,7 +5493,7 @@ impl Language { }) }; #[allow(unused_variables)] - let linear_expression_parser = |input: &mut ParserContext| { + let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; seq.elem(ZeroOrMoreHelper::run(input, |input| { @@ -5499,7 +5510,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn typed_tuple_member(&self, input: &mut ParserContext) -> ParserResult { + fn typed_tuple_member(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.type_name(input))?; seq.elem(OptionalHelper::transform(ChoiceHelper::run( @@ -5535,7 +5546,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unchecked_block(&self, input: &mut ParserContext) -> ParserResult { + fn unchecked_block(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -5552,7 +5563,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unicode_string_literals(&self, input: &mut ParserContext) -> ParserResult { + fn unicode_string_literals(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_7_0 { OneOrMoreHelper::run(input, |input| { self.parse_token_with_trivia::( @@ -5567,7 +5578,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unnamed_function_attributes(&self, input: &mut ParserContext) -> ParserResult { + fn unnamed_function_attributes(&self, input: &mut ParserContext<'_>) -> ParserResult { if !self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if !self.version_is_at_least_0_6_0 { @@ -5609,7 +5620,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unnamed_function_definition(&self, input: &mut ParserContext) -> ParserResult { + fn unnamed_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if !self.version_is_at_least_0_6_0 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -5639,7 +5650,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn untyped_tuple_member(&self, input: &mut ParserContext) -> ParserResult { + fn untyped_tuple_member(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform(ChoiceHelper::run( input, @@ -5674,7 +5685,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn user_defined_value_type_definition(&self, input: &mut ParserContext) -> ParserResult { + fn user_defined_value_type_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_8 { SequenceHelper::run(|mut seq| { seq.elem( @@ -5774,7 +5785,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_alias(&self, input: &mut ParserContext) -> ParserResult { + fn using_alias(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_19 { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( @@ -5872,7 +5883,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_deconstruction(&self, input: &mut ParserContext) -> ParserResult { + fn using_deconstruction(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_13 { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); @@ -5903,7 +5914,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_deconstruction_symbol(&self, input: &mut ParserContext) -> ParserResult { + fn using_deconstruction_symbol(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_13 { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; @@ -5919,7 +5930,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_deconstruction_symbols(&self, input: &mut ParserContext) -> ParserResult { + fn using_deconstruction_symbols(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_13 { SeparatedHelper::run::<_, LexicalContextType::Default>( input, @@ -5934,7 +5945,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_directive(&self, input: &mut ParserContext) -> ParserResult { + fn using_directive(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -5992,7 +6003,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + fn variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { @@ -6061,7 +6072,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { + fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -6076,7 +6087,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma(&self, input: &mut ParserContext) -> ParserResult { + fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6089,9 +6100,9 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma_expression(&self, input: &mut ParserContext) -> ParserResult { + fn version_pragma_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { #[allow(unused_variables)] - let parse_version_pragma_or_expression = |input: &mut ParserContext| { + let parse_version_pragma_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::VersionPragmaBinaryExpression, 1u8, @@ -6103,7 +6114,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_range_expression = |input: &mut ParserContext| { + let parse_version_pragma_range_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::VersionPragmaBinaryExpression, 3u8, @@ -6112,7 +6123,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 5u8, @@ -6157,7 +6168,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 7u8, @@ -6202,7 +6213,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 9u8, @@ -6247,7 +6258,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 11u8, @@ -6292,7 +6303,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 13u8, @@ -6337,7 +6348,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 15u8, @@ -6382,7 +6393,7 @@ impl Language { ) }; #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 17u8, @@ -6427,7 +6438,7 @@ impl Language { ) }; #[allow(unused_variables)] - let prefix_operator_parser = |input: &mut ParserContext| { + let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_version_pragma_prefix_expression(input); choice.consider(input, result)?; @@ -6448,9 +6459,9 @@ impl Language { }; #[allow(unused_variables)] let primary_expression_parser = - |input: &mut ParserContext| self.version_pragma_specifier(input); + |input: &mut ParserContext<'_>| self.version_pragma_specifier(input); #[allow(unused_variables)] - let binary_operand_parser = |input: &mut ParserContext| { + let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(ZeroOrMoreHelper::run(input, |input| { prefix_operator_parser(input) @@ -6460,7 +6471,7 @@ impl Language { }) }; #[allow(unused_variables)] - let binary_operator_parser = |input: &mut ParserContext| { + let binary_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_version_pragma_or_expression(input); choice.consider(input, result)?; @@ -6470,7 +6481,7 @@ impl Language { }) }; #[allow(unused_variables)] - let linear_expression_parser = |input: &mut ParserContext| { + let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; seq.elem(ZeroOrMoreHelper::run(input, |input| { @@ -6491,13 +6502,13 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma_expressions(&self, input: &mut ParserContext) -> ParserResult { + fn version_pragma_expressions(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| self.version_pragma_expression(input)) .with_kind(RuleKind::VersionPragmaExpressions) } #[allow(unused_assignments, unused_parens)] - fn version_pragma_specifier(&self, input: &mut ParserContext) -> ParserResult { + fn version_pragma_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Pragma>( input, self, @@ -6513,7 +6524,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn while_statement(&self, input: &mut ParserContext) -> ParserResult { + fn while_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6596,7 +6607,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_arguments(&self, input: &mut ParserContext) -> ParserResult { + fn yul_arguments(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, @@ -6607,7 +6618,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_assignment_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_assignment_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.yul_identifier_paths(input))?; seq.elem( @@ -6623,7 +6634,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_block(&self, input: &mut ParserContext) -> ParserResult { + fn yul_block(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); @@ -6654,13 +6665,13 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_break_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_break_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { self.parse_token_with_trivia::(input, TokenKind::YulBreakKeyword) .with_kind(RuleKind::YulBreakStatement) } #[allow(unused_assignments, unused_parens)] - fn yul_continue_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_continue_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { self.parse_token_with_trivia::( input, TokenKind::YulContinueKeyword, @@ -6669,7 +6680,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_default_case(&self, input: &mut ParserContext) -> ParserResult { + fn yul_default_case(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6682,9 +6693,9 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_expression(&self, input: &mut ParserContext) -> ParserResult { + fn yul_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { #[allow(unused_variables)] - let parse_yul_function_call_expression = |input: &mut ParserContext| { + let parse_yul_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::YulFunctionCallExpression, 1u8, @@ -6713,7 +6724,7 @@ impl Language { ) }; #[allow(unused_variables)] - let primary_expression_parser = |input: &mut ParserContext| { + let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -6755,7 +6766,7 @@ impl Language { }) }; #[allow(unused_variables)] - let postfix_operator_parser = |input: &mut ParserContext| { + let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = parse_yul_function_call_expression(input); choice.consider(input, result)?; @@ -6763,7 +6774,7 @@ impl Language { }) }; #[allow(unused_variables)] - let linear_expression_parser = |input: &mut ParserContext| { + let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; seq.elem(ZeroOrMoreHelper::run(input, |input| { @@ -6780,7 +6791,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_for_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_for_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6796,7 +6807,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_function_definition(&self, input: &mut ParserContext) -> ParserResult { + fn yul_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6817,7 +6828,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_identifier_path(&self, input: &mut ParserContext) -> ParserResult { + fn yul_identifier_path(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, @@ -6833,7 +6844,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_identifier_paths(&self, input: &mut ParserContext) -> ParserResult { + fn yul_identifier_paths(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, @@ -6844,7 +6855,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_if_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_if_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6858,7 +6869,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_leave_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_leave_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { self.parse_token_with_trivia::( input, @@ -6871,7 +6882,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_parameters(&self, input: &mut ParserContext) -> ParserResult { + fn yul_parameters(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, @@ -6887,7 +6898,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn yul_parameters_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); @@ -6918,7 +6929,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_return_variables(&self, input: &mut ParserContext) -> ParserResult { + fn yul_return_variables(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, @@ -6934,7 +6945,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_returns_declaration(&self, input: &mut ParserContext) -> ParserResult { + fn yul_returns_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -6947,7 +6958,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_statements(&self, input: &mut ParserContext) -> ParserResult { + fn yul_statements(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.yul_block(input); @@ -6981,7 +6992,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_switch_cases(&self, input: &mut ParserContext) -> ParserResult { + fn yul_switch_cases(&self, input: &mut ParserContext<'_>) -> ParserResult { OneOrMoreHelper::run(input, |input| { ChoiceHelper::run(input, |mut choice, input| { let result = self.yul_default_case(input); @@ -6995,7 +7006,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_switch_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -7009,7 +7020,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_value_case(&self, input: &mut ParserContext) -> ParserResult { + fn yul_value_case(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -7055,7 +7066,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -7071,7 +7082,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { + fn yul_variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( self.parse_token_with_trivia::( @@ -7090,7 +7101,7 @@ impl Language { ********************************************/ #[allow(unused_assignments, unused_parens)] - fn ascii_escape(&self, input: &mut ParserContext) -> bool { + fn ascii_escape(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_chars!(input, 't'), @@ -7105,7 +7116,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn ascii_string_literal(&self, input: &mut ParserContext) -> bool { + fn ascii_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, self.single_quoted_ascii_string_literal(input), @@ -7114,7 +7125,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn bytes_keyword(&self, input: &mut ParserContext) -> bool { + fn bytes_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'b', 'y', 't', 'e', 's'), scan_optional!( @@ -7159,7 +7170,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn decimal_digits(&self, input: &mut ParserContext) -> bool { + fn decimal_digits(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_one_or_more!(input, scan_char_range!(input, '0'..='9')), scan_zero_or_more!( @@ -7173,7 +7184,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn decimal_exponent(&self, input: &mut ParserContext) -> bool { + fn decimal_exponent(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_choice!(input, scan_chars!(input, 'e'), scan_chars!(input, 'E')), scan_optional!(input, scan_chars!(input, '-')), @@ -7182,7 +7193,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn decimal_literal(&self, input: &mut ParserContext) -> bool { + fn decimal_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_not_followed_by!( @@ -7236,7 +7247,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn double_quoted_ascii_string_literal(&self, input: &mut ParserContext) -> bool { + fn double_quoted_ascii_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, '"'), scan_zero_or_more!( @@ -7254,7 +7265,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn double_quoted_hex_string_literal(&self, input: &mut ParserContext) -> bool { + fn double_quoted_hex_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'h', 'e', 'x', '"'), scan_optional!(input, self.hex_string_contents(input)), @@ -7263,7 +7274,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn double_quoted_unicode_string_literal(&self, input: &mut ParserContext) -> bool { + fn double_quoted_unicode_string_literal(&self, input: &mut ParserContext<'_>) -> bool { if self.version_is_at_least_0_7_0 { scan_sequence!( scan_chars!(input, 'u', 'n', 'i', 'c', 'o', 'd', 'e', '"'), @@ -7283,7 +7294,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn end_of_line(&self, input: &mut ParserContext) -> bool { + fn end_of_line(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_optional!(input, scan_chars!(input, '\r')), scan_chars!(input, '\n') @@ -7291,7 +7302,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn escape_sequence(&self, input: &mut ParserContext) -> bool { + fn escape_sequence(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, '\\'), scan_choice!( @@ -7304,7 +7315,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn fixed_keyword(&self, input: &mut ParserContext) -> bool { + fn fixed_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), @@ -7587,7 +7598,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_byte_escape(&self, input: &mut ParserContext) -> bool { + fn hex_byte_escape(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'x'), self.hex_character(input), @@ -7596,7 +7607,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_character(&self, input: &mut ParserContext) -> bool { + fn hex_character(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_char_range!(input, '0'..='9'), @@ -7606,7 +7617,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_literal(&self, input: &mut ParserContext) -> bool { + fn hex_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_not_followed_by!( @@ -7647,7 +7658,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_string_contents(&self, input: &mut ParserContext) -> bool { + fn hex_string_contents(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( self.hex_character(input), self.hex_character(input), @@ -7663,7 +7674,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn hex_string_literal(&self, input: &mut ParserContext) -> bool { + fn hex_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, self.single_quoted_hex_string_literal(input), @@ -7672,12 +7683,12 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn identifier(&self, input: &mut ParserContext) -> bool { + fn identifier(&self, input: &mut ParserContext<'_>) -> bool { self.raw_identifier(input) } #[allow(unused_assignments, unused_parens)] - fn identifier_part(&self, input: &mut ParserContext) -> bool { + fn identifier_part(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, self.identifier_start(input), @@ -7686,7 +7697,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn identifier_start(&self, input: &mut ParserContext) -> bool { + fn identifier_start(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_chars!(input, '_'), @@ -7697,7 +7708,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn int_keyword(&self, input: &mut ParserContext) -> bool { + fn int_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'i', 'n', 't'), scan_optional!( @@ -7742,7 +7753,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn multiline_comment(&self, input: &mut ParserContext) -> bool { + fn multiline_comment(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, '/'), scan_chars!(input, '*'), @@ -7760,7 +7771,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn raw_identifier(&self, input: &mut ParserContext) -> bool { + fn raw_identifier(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( self.identifier_start(input), scan_zero_or_more!(input, self.identifier_part(input)) @@ -7768,7 +7779,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn single_line_comment(&self, input: &mut ParserContext) -> bool { + fn single_line_comment(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, '/', '/'), scan_zero_or_more!(input, scan_none_of!(input, '\r', '\n')) @@ -7776,7 +7787,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn single_quoted_ascii_string_literal(&self, input: &mut ParserContext) -> bool { + fn single_quoted_ascii_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, '\''), scan_zero_or_more!( @@ -7794,7 +7805,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn single_quoted_hex_string_literal(&self, input: &mut ParserContext) -> bool { + fn single_quoted_hex_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'h', 'e', 'x', '\''), scan_optional!(input, self.hex_string_contents(input)), @@ -7803,7 +7814,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn single_quoted_unicode_string_literal(&self, input: &mut ParserContext) -> bool { + fn single_quoted_unicode_string_literal(&self, input: &mut ParserContext<'_>) -> bool { if self.version_is_at_least_0_7_0 { scan_sequence!( scan_chars!(input, 'u', 'n', 'i', 'c', 'o', 'd', 'e', '\''), @@ -7823,7 +7834,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn ufixed_keyword(&self, input: &mut ParserContext) -> bool { + fn ufixed_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), @@ -8106,7 +8117,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn uint_keyword(&self, input: &mut ParserContext) -> bool { + fn uint_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'u', 'i', 'n', 't'), scan_optional!( @@ -8151,7 +8162,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unicode_escape(&self, input: &mut ParserContext) -> bool { + fn unicode_escape(&self, input: &mut ParserContext<'_>) -> bool { scan_sequence!( scan_chars!(input, 'u'), self.hex_character(input), @@ -8162,7 +8173,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn unicode_string_literal(&self, input: &mut ParserContext) -> bool { + fn unicode_string_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, if self.version_is_at_least_0_7_0 { @@ -8179,7 +8190,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma_value(&self, input: &mut ParserContext) -> bool { + fn version_pragma_value(&self, input: &mut ParserContext<'_>) -> bool { scan_one_or_more!( input, scan_choice!( @@ -8193,7 +8204,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn whitespace(&self, input: &mut ParserContext) -> bool { + fn whitespace(&self, input: &mut ParserContext<'_>) -> bool { scan_one_or_more!( input, scan_choice!(input, scan_chars!(input, ' '), scan_chars!(input, '\t')) @@ -8201,7 +8212,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_bytes_keyword(&self, input: &mut ParserContext) -> bool { + fn yul_bytes_keyword(&self, input: &mut ParserContext<'_>) -> bool { if !self.version_is_at_least_0_7_1 { scan_sequence!( scan_chars!(input, 'b', 'y', 't', 'e', 's'), @@ -8250,7 +8261,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_decimal_literal(&self, input: &mut ParserContext) -> bool { + fn yul_decimal_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_not_followed_by!( input, scan_choice!( @@ -8266,7 +8277,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_fixed_keyword(&self, input: &mut ParserContext) -> bool { + fn yul_fixed_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, if !self.version_is_at_least_0_7_1 { @@ -8561,7 +8572,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_hex_literal(&self, input: &mut ParserContext) -> bool { + fn yul_hex_literal(&self, input: &mut ParserContext<'_>) -> bool { scan_not_followed_by!( input, scan_sequence!( @@ -8573,12 +8584,12 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_identifier(&self, input: &mut ParserContext) -> bool { + fn yul_identifier(&self, input: &mut ParserContext<'_>) -> bool { self.raw_identifier(input) } #[allow(unused_assignments, unused_parens)] - fn yul_int_keyword(&self, input: &mut ParserContext) -> bool { + fn yul_int_keyword(&self, input: &mut ParserContext<'_>) -> bool { if !self.version_is_at_least_0_7_1 { scan_sequence!( scan_chars!(input, 'i', 'n', 't'), @@ -8627,7 +8638,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_ufixed_keyword(&self, input: &mut ParserContext) -> bool { + fn yul_ufixed_keyword(&self, input: &mut ParserContext<'_>) -> bool { scan_choice!( input, if !self.version_is_at_least_0_7_1 { @@ -8922,7 +8933,7 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn yul_uint_keyword(&self, input: &mut ParserContext) -> bool { + fn yul_uint_keyword(&self, input: &mut ParserContext<'_>) -> bool { if !self.version_is_at_least_0_7_1 { scan_sequence!( scan_chars!(input, 'u', 'i', 'n', 't'), @@ -9223,11 +9234,11 @@ impl Language { } impl Lexer for Language { - fn leading_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { Language::leading_trivia(self, input) } - fn trailing_trivia(&self, input: &mut ParserContext) -> ParserResult { + fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult { Language::trailing_trivia(self, input) } @@ -9246,7 +9257,10 @@ impl Lexer for Language { } } - fn next_token(&self, input: &mut ParserContext) -> Option { + fn next_token( + &self, + input: &mut ParserContext<'_>, + ) -> Option { let save = input.position(); let mut furthest_position = input.position(); let mut longest_token = None; @@ -11434,6 +11448,8 @@ impl Lexer for Language { } #[cfg(feature = "slang_napi_interfaces")] +// NAPI-exposed functions have to accept owned values. +#[allow(clippy::needless_pass_by_value)] #[napi(namespace = "language")] impl Language { #[napi(constructor)] diff --git a/crates/solidity/outputs/npm/crate/src/generated/lexer.rs b/crates/solidity/outputs/npm/crate/src/generated/lexer.rs index 4661f4e2b7..0457cfdc70 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/lexer.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/lexer.rs @@ -9,18 +9,24 @@ use crate::{ pub trait Lexer { // Generated by the templating engine #[doc(hidden)] - fn next_token(&self, input: &mut ParserContext) -> Option; + fn next_token( + &self, + input: &mut ParserContext<'_>, + ) -> Option; // NOTE: These are context-insensitive #[doc(hidden)] - fn leading_trivia(&self, input: &mut ParserContext) -> ParserResult; + fn leading_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; #[doc(hidden)] - fn trailing_trivia(&self, input: &mut ParserContext) -> ParserResult; + fn trailing_trivia(&self, input: &mut ParserContext<'_>) -> ParserResult; #[doc(hidden)] /// Returns valid grouping delimiters in the given lexical context. fn delimiters() -> &'static [(TokenKind, TokenKind)]; /// Peeks the next token, including trivia. Does not advance the input. - fn peek_token(&self, input: &mut ParserContext) -> Option { + fn peek_token( + &self, + input: &mut ParserContext<'_>, + ) -> Option { let start = input.position(); let token = self.next_token::(input); input.set_position(start); @@ -30,7 +36,7 @@ pub trait Lexer { /// Peeks the next significant (i.e. non-trivia) token. Does not advance the input. fn peek_token_with_trivia( &self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, ) -> Option { let start = input.position(); @@ -44,7 +50,7 @@ pub trait Lexer { /// Attempts to consume the next expected token. Advances the input only if the token matches. fn parse_token( &self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, kind: TokenKind, ) -> ParserResult { let start = input.position(); @@ -64,7 +70,7 @@ pub trait Lexer { /// Advances the input only if the token matches. fn parse_token_with_trivia( &self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, kind: TokenKind, ) -> ParserResult { let mut children = vec![]; diff --git a/crates/solidity/outputs/npm/crate/src/generated/napi/napi_cursor.rs b/crates/solidity/outputs/npm/crate/src/generated/napi/napi_cursor.rs index 7ea067c144..9a531b242d 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/napi/napi_cursor.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/napi/napi_cursor.rs @@ -1,5 +1,10 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +// NAPI-exposed functions have to accept owned values +#![allow(clippy::needless_pass_by_value)] +// The functions are meant to be definitions for export, so they're not really used +#![allow(clippy::return_self_not_must_use)] + use { napi::{bindgen_prelude::Env, JsObject}, napi_derive::napi, @@ -26,12 +31,12 @@ impl Cursor { #[napi] pub fn reset(&mut self) { - self.0.reset() + self.0.reset(); } #[napi] pub fn complete(&mut self) { - self.0.complete() + self.0.complete(); } #[napi] @@ -65,6 +70,7 @@ impl Cursor { (&self.0.text_range()).into() } + #[allow(clippy::cast_possible_truncation)] // Cursor depth can't reasonably be larger than u32 #[napi(getter)] pub fn depth(&self) -> u32 { self.0.depth() as u32 diff --git a/crates/solidity/outputs/npm/crate/src/generated/napi/napi_parse_error.rs b/crates/solidity/outputs/npm/crate/src/generated/napi/napi_parse_error.rs index 1013a69213..1b1959dcaf 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/napi/napi_parse_error.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/napi/napi_parse_error.rs @@ -1,5 +1,8 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +// NAPI-exposed functions have to accept owned values. +#![allow(clippy::needless_pass_by_value)] + use napi_derive::napi; use super::{napi_text_index, RustParseError}; @@ -23,11 +26,7 @@ impl ParseError { } pub fn tokens_that_would_have_allowed_more_progress(&self) -> Vec { - self.0 - .tokens_that_would_have_allowed_more_progress() - .iter() - .map(|x| x.to_string()) - .collect() + self.0.tokens_that_would_have_allowed_more_progress() } #[napi(namespace = "parse_error")] diff --git a/crates/solidity/outputs/npm/crate/src/generated/napi/napi_text_index.rs b/crates/solidity/outputs/npm/crate/src/generated/napi/napi_text_index.rs index 64f69d576a..e95cad36f2 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/napi/napi_text_index.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/napi/napi_text_index.rs @@ -14,6 +14,8 @@ pub struct TextIndex { impl From<&RustTextIndex> for TextIndex { fn from(value: &RustTextIndex) -> Self { + // We only support 32-byte indices on TS side. + #[allow(clippy::cast_possible_truncation)] Self { utf8: value.utf8 as u32, utf16: value.utf16 as u32, diff --git a/crates/solidity/outputs/npm/crate/src/generated/parse_error.rs b/crates/solidity/outputs/npm/crate/src/generated/parse_error.rs index fce07cfa9a..7a7282b328 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/parse_error.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/parse_error.rs @@ -22,12 +22,11 @@ impl ParseError { let tokens_that_would_have_allowed_more_progress = self .tokens_that_would_have_allowed_more_progress .iter() - .map(|kind| kind.as_ref()) .collect::>(); tokens_that_would_have_allowed_more_progress .into_iter() - .map(|token| token.to_string()) + .map(TokenKind::to_string) .collect() } diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/choice_helper.rs b/crates/solidity/outputs/npm/crate/src/generated/support/choice_helper.rs index 412d7b32fd..022982185c 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/choice_helper.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/choice_helper.rs @@ -20,7 +20,7 @@ pub struct ChoiceHelper { } impl ChoiceHelper { - pub fn new(input: &mut ParserContext) -> Self { + pub fn new(input: &mut ParserContext<'_>) -> Self { Self { result: ParserResult::no_match(vec![]), start_position: input.mark(), @@ -39,7 +39,7 @@ impl ChoiceHelper { } /// Store the next result if it's a better match; otherwise, we retain the existing one. - fn attempt_pick(&mut self, input: &mut ParserContext, next_result: ParserResult) { + fn attempt_pick(&mut self, input: &mut ParserContext<'_>, next_result: ParserResult) { let better_pick = match (&mut self.result, &next_result) { // We settle for the first full match. (ParserResult::Match(running), _) if running.is_full_recursive() => { @@ -56,10 +56,8 @@ impl ChoiceHelper { running.expected_tokens.extend(next.expected_tokens.clone()); false } - // Otherwise, we have some match and we ignore a missing next one. - (ParserResult::IncompleteMatch(..), ParserResult::NoMatch(..)) - | (ParserResult::SkippedUntil(..), ParserResult::NoMatch(..)) - | (ParserResult::Match(..), ParserResult::NoMatch(..)) => false, + // Otherwise, we already have some match, so we ignore a next missing one. + (_, ParserResult::NoMatch(..)) => false, // Try to improve our match. (_, ParserResult::Match(next)) if next.is_full_recursive() => true, @@ -82,8 +80,8 @@ impl ChoiceHelper { /// /// Useful when you want to eagerly return a result from the parse function (e.g. when the choice was fully matched). pub fn run( - input: &mut ParserContext, - f: impl FnOnce(Self, &mut ParserContext) -> ControlFlow, + input: &mut ParserContext<'_>, + f: impl FnOnce(Self, &mut ParserContext<'_>) -> ControlFlow, ) -> ParserResult { match f(ChoiceHelper::new(input), input) { ControlFlow::Break(result) => result, @@ -98,7 +96,7 @@ impl ChoiceHelper { /// If a value is considered as a full match, it is returned, otherwise we backtrack and continue. pub fn consider( &mut self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, value: ParserResult, ) -> ControlFlow { self.attempt_pick(input, value); @@ -112,7 +110,7 @@ impl ChoiceHelper { } /// Finishes the choice parse, returning the accumulated match. - pub fn finish(self, input: &mut ParserContext) -> ControlFlow { + pub fn finish(self, input: &mut ParserContext<'_>) -> ControlFlow { assert!(!self.is_done()); // We didn't break early, so undo the rewind that has happened in the meantime. input.set_position(self.last_progress); diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/context.rs b/crates/solidity/outputs/npm/crate/src/generated/support/context.rs index 3d787cecaa..1e3b5fa86a 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/context.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/context.rs @@ -32,7 +32,7 @@ impl<'s> ParserContext<'s> { pub fn new(source: &'s str) -> Self { Self { source, - position: Default::default(), + position: TextIndex::ZERO, undo_position: None, errors: vec![], closing_delimiters: vec![], diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/parser_function.rs b/crates/solidity/outputs/npm/crate/src/generated/support/parser_function.rs index 52deea1703..08b1f69d8f 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/parser_function.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/parser_function.rs @@ -13,14 +13,14 @@ use super::{ pub trait ParserFunction where - Self: Fn(&L, &mut ParserContext) -> ParserResult, + Self: Fn(&L, &mut ParserContext<'_>) -> ParserResult, { fn parse(&self, language: &L, input: &str) -> ParseOutput; } impl ParserFunction for F where - F: Fn(&L, &mut ParserContext) -> ParserResult, + F: Fn(&L, &mut ParserContext<'_>) -> ParserResult, { fn parse(&self, language: &L, input: &str) -> ParseOutput { let mut stream = ParserContext::new(input); @@ -35,7 +35,7 @@ where ParserResult::NoMatch(no_match) => ParseOutput { parse_tree: cst::Node::token(TokenKind::SKIPPED, input.to_string()), errors: vec![ParseError::new_covering_range( - Default::default()..input.into(), + TextIndex::ZERO..input.into(), no_match.expected_tokens, )], }, diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/parser_result.rs b/crates/solidity/outputs/npm/crate/src/generated/support/parser_result.rs index f88dfcfae2..49e7f51785 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/parser_result.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/parser_result.rs @@ -56,6 +56,7 @@ impl ParserResult { matches!(self, ParserResult::NoMatch(_)) } + #[must_use] pub fn with_kind(self, new_kind: RuleKind) -> ParserResult { match self { ParserResult::Match(r#match) => ParserResult::r#match( diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs b/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs index 0e71667e81..0ee251bda3 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs @@ -4,7 +4,7 @@ use super::{ super::{cst, kinds::RuleKind}, parser_result::{ ParserResult, - PrattElement::{self, *}, + PrattElement::{self, Binary, Expression, Postfix, Prefix}, }, }; @@ -58,6 +58,8 @@ impl PrecedenceHelper { _ => result, } } + + #[allow(clippy::too_many_lines)] // Explicit on purpose, see below. pub fn reduce_precedence_result( child_kind: Option, result: ParserResult, @@ -69,6 +71,7 @@ impl PrecedenceHelper { // If the input is valid this should be correct by construction. + #[allow(clippy::redundant_else)] match result { ParserResult::PrattOperatorMatch(pratt_operator_match) => { let mut pratt_elements = pratt_operator_match.elements; diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/recovery.rs b/crates/solidity/outputs/npm/crate/src/generated/support/recovery.rs index d6d3e1016b..d3e158ed02 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/recovery.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/recovery.rs @@ -11,20 +11,21 @@ use super::parser_result::SkippedUntil; use super::ParserContext; /// An explicit parameter for the [`ParserResult::recover_until_with_nested_delims`] method. +#[derive(Clone, Copy)] pub enum RecoverFromNoMatch { Yes, No, } impl RecoverFromNoMatch { - pub fn as_bool(&self) -> bool { + pub fn as_bool(self) -> bool { matches!(self, RecoverFromNoMatch::Yes) } } fn opt_parse( - input: &mut ParserContext, - parse: impl Fn(&mut ParserContext) -> ParserResult, + input: &mut ParserContext<'_>, + parse: impl Fn(&mut ParserContext<'_>) -> ParserResult, ) -> Vec { let start = input.position(); if let ParserResult::Match(r#match) = parse(input) { @@ -42,21 +43,22 @@ impl ParserResult { /// /// Respects nested delimiters, i.e. the `expected` token is only accepted if it's not nested inside. /// Does not consume the `expected` token. + #[must_use] pub fn recover_until_with_nested_delims( self, - input: &mut ParserContext, + input: &mut ParserContext<'_>, lexer: &L, expected: TokenKind, recover_from_no_match: RecoverFromNoMatch, ) -> ParserResult { - let before_recovery = input.position(); - enum ParseResultKind { Match, Incomplete, NoMatch, } + let before_recovery = input.position(); + let (mut nodes, mut expected_tokens, result_kind) = match self { ParserResult::IncompleteMatch(result) => ( result.nodes, @@ -77,38 +79,37 @@ impl ParserResult { let leading_trivia = opt_parse(input, |input| lexer.leading_trivia(input)); - match skip_until_with_nested_delims::<_, LexCtx>(input, lexer, expected) { - Some((found, skipped_range)) => { - nodes.extend(leading_trivia); - if matches!(result_kind, ParseResultKind::Match) { - expected_tokens.push(expected); - } + if let Some((found, skipped_range)) = + skip_until_with_nested_delims::<_, LexCtx>(input, lexer, expected) + { + nodes.extend(leading_trivia); + if matches!(result_kind, ParseResultKind::Match) { + expected_tokens.push(expected); + } - let skipped = input.content(skipped_range.utf8()); + let skipped = input.content(skipped_range.utf8()); - input.emit(ParseError { - text_range: skipped_range, - tokens_that_would_have_allowed_more_progress: expected_tokens.clone(), - }); + input.emit(ParseError { + text_range: skipped_range, + tokens_that_would_have_allowed_more_progress: expected_tokens.clone(), + }); - ParserResult::SkippedUntil(SkippedUntil { - nodes, - expected, - skipped, - found, - }) - } + ParserResult::SkippedUntil(SkippedUntil { + nodes, + skipped, + found, + expected, + }) + } else { // Not found till EOF, revert any recovery attempt - None => { - input.set_position(before_recovery); - - match result_kind { - ParseResultKind::Match => ParserResult::r#match(nodes, expected_tokens), - ParseResultKind::Incomplete => { - ParserResult::incomplete_match(nodes, expected_tokens) - } - ParseResultKind::NoMatch => ParserResult::no_match(expected_tokens), + input.set_position(before_recovery); + + match result_kind { + ParseResultKind::Match => ParserResult::r#match(nodes, expected_tokens), + ParseResultKind::Incomplete => { + ParserResult::incomplete_match(nodes, expected_tokens) } + ParseResultKind::NoMatch => ParserResult::no_match(expected_tokens), } } } @@ -120,7 +121,7 @@ impl ParserResult { /// /// Returns the found token and the range of skipped tokens on success. pub fn skip_until_with_nested_delims( - input: &mut ParserContext, + input: &mut ParserContext<'_>, lexer: &L, until: TokenKind, ) -> Option<(TokenKind, TextRange)> { diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/repetition_helper.rs b/crates/solidity/outputs/npm/crate/src/generated/support/repetition_helper.rs index ba430364a1..a60b04bb80 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/repetition_helper.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/repetition_helper.rs @@ -11,8 +11,8 @@ pub type ZeroOrMoreHelper = RepetitionHelper<0>; pub type OneOrMoreHelper = RepetitionHelper<1>; impl RepetitionHelper { - pub fn run ParserResult>( - input: &mut ParserContext, + pub fn run) -> ParserResult>( + input: &mut ParserContext<'_>, parser: F, ) -> ParserResult { if MIN_COUNT > 1 { @@ -28,9 +28,7 @@ impl RepetitionHelper { // Couldn't get a full match but we allow 0 items - return an empty match // so the parse is considered valid but note the expected tokens - ParserResult::NoMatch(NoMatch { - expected_tokens, .. - }) if MIN_COUNT == 0 => { + ParserResult::NoMatch(NoMatch { expected_tokens }) if MIN_COUNT == 0 => { return ParserResult::r#match(vec![], expected_tokens); } // Don't try repeating if we don't have a full match and we require at least one @@ -86,7 +84,9 @@ impl RepetitionHelper { return ParserResult::SkippedUntil(skipped); } - (ParserResult::PrattOperatorMatch(..), ParserResult::SkippedUntil(_)) => todo!(), + (ParserResult::PrattOperatorMatch(..), ParserResult::SkippedUntil(_)) => { + unreachable!("We don't do recovery when reducing the Pratt matches") + } ( ParserResult::IncompleteMatch(..) diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/scanner_macros.rs b/crates/solidity/outputs/npm/crate/src/generated/support/scanner_macros.rs index cd8c824e35..8bc08d4c11 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/scanner_macros.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/scanner_macros.rs @@ -85,6 +85,7 @@ macro_rules! scan_zero_or_more { macro_rules! scan_one_or_more { ($stream:ident, $scanner:expr) => {{ let mut count = 0; + #[allow(clippy::redundant_else)] loop { let save = $stream.position(); if !($scanner) { diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/separated_helper.rs b/crates/solidity/outputs/npm/crate/src/generated/support/separated_helper.rs index 5447bbb533..5e5efa5f0a 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/separated_helper.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/separated_helper.rs @@ -17,9 +17,9 @@ pub struct SeparatedHelper; impl SeparatedHelper { pub fn run( - input: &mut ParserContext, + input: &mut ParserContext<'_>, lexer: &L, - body_parser: impl Fn(&mut ParserContext) -> ParserResult, + body_parser: impl Fn(&mut ParserContext<'_>) -> ParserResult, separator: TokenKind, ) -> ParserResult { let mut accum = vec![]; @@ -88,11 +88,11 @@ impl SeparatedHelper { } } ParserResult::NoMatch(no_match) => { - if accum.is_empty() { - return ParserResult::no_match(no_match.expected_tokens); + return if accum.is_empty() { + ParserResult::no_match(no_match.expected_tokens) } else { - return ParserResult::incomplete_match(accum, no_match.expected_tokens); - } + ParserResult::incomplete_match(accum, no_match.expected_tokens) + }; } ParserResult::SkippedUntil(skipped) => { diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/sequence_helper.rs b/crates/solidity/outputs/npm/crate/src/generated/support/sequence_helper.rs index decdee623f..b968bda06c 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/sequence_helper.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/sequence_helper.rs @@ -35,6 +35,7 @@ impl SequenceHelper { ) } + #[allow(clippy::too_many_lines)] // Big switch that purely defines the sequence logic /// Attempts to append the next result until we hit an incomplete/no match. fn attempt_append(&mut self, next_result: ParserResult) { match self.result { @@ -95,7 +96,7 @@ impl SequenceHelper { self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut cur.elements) .into_iter() - .flat_map(|pratt| pratt.into_nodes()) + .flat_map(PrattElement::into_nodes) .chain(next.nodes) .collect(), next.expected_tokens, @@ -105,7 +106,7 @@ impl SequenceHelper { self.result = State::Running(ParserResult::incomplete_match( std::mem::take(&mut cur.elements) .into_iter() - .flat_map(|pratt| pratt.into_nodes()) + .flat_map(PrattElement::into_nodes) .collect(), next.expected_tokens, )); diff --git a/crates/solidity/testing/sanctuary/src/main.rs b/crates/solidity/testing/sanctuary/src/main.rs index 15818dae87..8686223481 100644 --- a/crates/solidity/testing/sanctuary/src/main.rs +++ b/crates/solidity/testing/sanctuary/src/main.rs @@ -1,7 +1,7 @@ mod datasets; mod reporting; -use std::{collections::BTreeSet, path::Path}; +use std::{collections::BTreeSet, ops::ControlFlow, path::Path, process::ExitCode}; use anyhow::Result; use infra_utils::paths::PathExtensions; @@ -16,22 +16,23 @@ use crate::{ reporting::Reporter, }; -fn main() { +fn main() -> Result { let versions = SolidityDefinition::create().collect_breaking_versions(); - // Fail the parent process if a child thread panics: - std::panic::catch_unwind(|| -> Result<()> { - for dataset in get_all_datasets()? { - process_dataset(&dataset, &versions)?; + for dataset in get_all_datasets()? { + match process_dataset(&dataset, &versions)? { + ControlFlow::Continue(..) => {} + ControlFlow::Break(exit_code) => return Ok(exit_code), } + } - Ok(()) - }) - .unwrap() - .unwrap(); + Ok(ExitCode::SUCCESS) } -fn process_dataset(dataset: &impl Dataset, versions: &BTreeSet) -> Result<()> { +fn process_dataset( + dataset: &impl Dataset, + versions: &BTreeSet, +) -> Result> { println!(); println!(); println!(" ๐Ÿงช Dataset: {title}", title = dataset.get_title()); @@ -51,6 +52,8 @@ fn process_dataset(dataset: &impl Dataset, versions: &BTreeSet) -> Resu source_files .par_iter() + // Halt as soon as possible if a child panics. + .panic_fuse() .map(|file_path| { process_source_file(file_path, versions, &reporter)?; reporter.report_file_completed(); @@ -60,10 +63,11 @@ fn process_dataset(dataset: &impl Dataset, versions: &BTreeSet) -> Resu let total_errors = reporter.finish(); if total_errors > 0 { - std::process::exit(1); + println!("There were errors processing the dataset."); + Ok(ControlFlow::Break(ExitCode::FAILURE)) + } else { + Ok(ControlFlow::Continue(())) } - - Ok(()) } fn process_source_file( @@ -75,9 +79,7 @@ fn process_source_file( let source = &file_path.read_to_string()?; let latest_version = versions.iter().max().unwrap(); - let pragmas = if let Ok(pragmas) = extract_version_pragmas(source, latest_version) { - pragmas - } else { + let Ok(pragmas) = extract_version_pragmas(source, latest_version) else { // Skip this file if we failed to filter compatible versions. return Ok(()); }; diff --git a/crates/solidity/testing/sanctuary/src/reporting.rs b/crates/solidity/testing/sanctuary/src/reporting.rs index fb00e39b86..15921f9d14 100644 --- a/crates/solidity/testing/sanctuary/src/reporting.rs +++ b/crates/solidity/testing/sanctuary/src/reporting.rs @@ -44,10 +44,11 @@ impl Reporter { let failed_tests = self.failed_tests.load(Ordering::Relaxed); let total_tests = self.total_tests.load(Ordering::Relaxed); - let failure_percent = (100_f64 * (failed_tests as f64) / (total_tests as f64)) as usize; + #[allow(clippy::cast_precision_loss)] + let failure_percent = 100f64 * (failed_tests as f64) / (total_tests as f64); self.progress_bar.set_message(format!( - "{failed_tests}/{total_tests} tests failed ({failure_percent}%)", + "{failed_tests}/{total_tests} tests failed ({failure_percent:.0}%)", )); } diff --git a/crates/solidity/testing/utils/src/cst_snapshots/mod.rs b/crates/solidity/testing/utils/src/cst_snapshots/mod.rs index 4c9dabe4de..fe3580b0a3 100644 --- a/crates/solidity/testing/utils/src/cst_snapshots/mod.rs +++ b/crates/solidity/testing/utils/src/cst_snapshots/mod.rs @@ -53,7 +53,7 @@ fn write_source(w: &mut W, source: &str) -> Result<()> { writeln!(w, "Source: >")?; let mut offset = 0; - for (index, line, bytes, chars) in line_data.iter() { + for (index, line, bytes, chars) in &line_data { let range = offset..(offset + bytes); writeln!( w, @@ -141,7 +141,7 @@ fn write_node( (format!(" {preview}"), range_string) } else { // # 1..2 "foo" - ("".to_owned(), format!("{range_string} {preview}")) + (String::new(), format!("{range_string} {preview}")) } }; diff --git a/crates/solidity/testing/utils/src/version_pragmas/mod.rs b/crates/solidity/testing/utils/src/version_pragmas/mod.rs index f48bb65a28..ea9b722b2f 100644 --- a/crates/solidity/testing/utils/src/version_pragmas/mod.rs +++ b/crates/solidity/testing/utils/src/version_pragmas/mod.rs @@ -46,9 +46,8 @@ pub fn extract_version_pragmas( } fn extract_pragma(expression_node: &Node) -> Result { - let expression_rule = match expression_node { - Node::Rule(rule) => rule, - _ => bail!("Expected rule: {expression_node:?}"), + let Node::Rule(expression_rule) = expression_node else { + bail!("Expected rule: {expression_node:?}") }; ensure!( @@ -57,10 +56,8 @@ fn extract_pragma(expression_node: &Node) -> Result { ); let inner_expression = match &expression_rule.children[..] { - [child] => match child { - Node::Rule(rule) => rule, - _ => bail!("Expected rule: {child:?}"), - }, + [Node::Rule(rule)] => rule, + [Node::Token(token)] => bail!("Expected rule: {token:?}"), _ => unreachable!("Expected single child: {expression_rule:?}"), }; @@ -73,12 +70,11 @@ fn extract_pragma(expression_node: &Node) -> Result { match inner_expression.kind { RuleKind::VersionPragmaBinaryExpression => match &inner_children[..] { [left, operator, right] => { - let operator_kind = match operator { - Node::Token(token) => token.kind, - _ => bail!("Expected rule: {operator:?}"), + let Node::Token(operator) = operator else { + bail!("Expected rule: {operator:?}"); }; - match operator_kind { + match operator.kind { TokenKind::BarBar => { let left = extract_pragma(left)?; let right = extract_pragma(right)?;