From 51e5b6182129b274e9d151602ba6b8c613a709f6 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 13 Dec 2023 12:35:12 +0100 Subject: [PATCH] Auto-format imports using `Module` granularity (#702) Part of #155 This is going to be a fun one :laughing: I've pushed two preview commits: the first one imports using the `Crate` granularity, the other one with `Module` granularity. Disclaimer: I'm biased :smiley: I've used this style since I started using Rust and it's also being used by vast majority of projects in the ecosystem that I've used or looked at; it's also used by the Rust compiler, Cargo and the tools like Rustfmt or Clippy. Here's a summary of the possible options: https://github.com/rust-lang/rustfmt/issues/3362. Here is an RFC discussion about setting on a variant: https://github.com/rust-lang/style-team/issues/140, I highly recommend reading it. To give a brief summary, it seems that people stand behind two options: - `Module` - good trade-off between readability and conciseness - `Item` - minimizes conflicts when many people edit the same files often To bring back some of the arguments raised in favor of the `Module` and explain some of my reasoning as well: - it naturally settles on the module as the, well, module/boundary from which items can be imported... - thus, helps build the intuition how to use and structure Rust crates - less verbose than Java-style (`Item`) imports, which can often explode and take unreasonable amount of space (and we don't really benefit enough from minimized conflicts as we probably won't be a team of 50 or the like)... - but repeats enough information to quickly trace a module path rather than having to reconstruct the paths from the `crate`-style use import tree... - and already often takes less space in our case, line-wise; - quite good `grep`pability --- .rustfmt.toml | 1 + .vscode/settings.json | 3 ++ crates/codegen/ebnf/src/precedence_parser.rs | 3 +- crates/codegen/grammar/src/grammar.rs | 7 ++-- .../codegen/grammar/src/parser_definition.rs | 6 ++-- .../src/precedence_parser_definition.rs | 2 +- .../codegen/grammar/src/scanner_definition.rs | 2 +- crates/codegen/grammar/src/visitor.rs | 2 +- .../src/compiler/analysis/definitions.rs | 12 +++---- .../definition/src/compiler/analysis/mod.rs | 15 ++++---- .../src/compiler/analysis/reachability.rs | 7 ++-- .../src/compiler/analysis/references.rs | 28 +++++++-------- .../definition/src/compiler/analysis/utils.rs | 7 ++-- .../definition/src/compiler/emitter.rs | 3 +- .../language/definition/src/compiler/mod.rs | 7 ++-- .../definition/src/compiler/version_set.rs | 4 ++- .../internals/parse_input_tokens/adapter.rs | 6 ++-- .../parse_input_tokens/external_types.rs | 11 +++--- .../internals/parse_input_tokens/helpers.rs | 6 ++-- .../language/definition/src/model/manifest.rs | 3 +- .../definition/src/model/utils/identifier.rs | 3 +- .../internal_macros/src/derive/spanned.rs | 3 +- .../internal_macros/src/input_model.rs | 6 ++-- .../parser/generator/src/code_generator.rs | 20 +++++------ .../src/precedence_parser_definition.rs | 2 +- .../generator/src/scanner_definition.rs | 2 +- crates/codegen/parser/generator/src/trie.rs | 5 +-- crates/codegen/parser/runtime/src/cst.rs | 8 ++--- crates/codegen/parser/runtime/src/cursor.rs | 8 ++--- crates/codegen/parser/runtime/src/lexer.rs | 8 ++--- crates/codegen/parser/runtime/src/napi/mod.rs | 18 +++++----- .../parser/runtime/src/napi/napi_cst.rs | 21 ++++------- .../parser/runtime/src/napi/napi_cursor.rs | 9 +++-- .../runtime/src/napi/napi_parse_error.rs | 2 +- .../runtime/src/napi/napi_parse_output.rs | 5 +-- .../runtime/src/napi/napi_text_index.rs | 2 +- .../codegen/parser/runtime/src/parse_error.rs | 6 ++-- .../parser/runtime/src/parse_output.rs | 5 ++- .../runtime/src/support/choice_helper.rs | 8 +++-- .../parser/runtime/src/support/context.rs | 2 +- .../runtime/src/support/optional_helper.rs | 2 +- .../runtime/src/support/parser_function.rs | 15 ++++---- .../runtime/src/support/parser_result.rs | 8 ++--- .../runtime/src/support/precedence_helper.rs | 11 +++--- .../parser/runtime/src/support/recovery.rs | 4 +-- .../runtime/src/support/repetition_helper.rs | 6 ++-- .../runtime/src/support/separated_helper.rs | 20 +++++------ .../runtime/src/support/sequence_helper.rs | 5 +-- .../runtime/src/templates/language.rs.jinja2 | 35 ++++++++++--------- .../codegen/parser/runtime/src/text_index.rs | 6 ++-- crates/codegen/schema/src/compiler.rs | 18 ++++------ crates/codegen/schema/src/types/language.rs | 3 +- crates/codegen/schema/src/types/production.rs | 4 ++- .../rules/definitions/keywords/collector.rs | 6 ++-- .../rules/definitions/keywords/mod.rs | 13 +++---- .../rules/definitions/keywords/validator.rs | 10 ++---- .../src/validation/rules/definitions/mod.rs | 15 ++++---- .../rules/definitions/operators/mod.rs | 6 ++-- .../rules/definitions/productions/mod.rs | 6 ++-- .../rules/definitions/versions/mod.rs | 6 ++-- .../validation/rules/lints/children_count.rs | 10 +++--- .../rules/lints/consistent_shape.rs | 10 +++--- .../schema/src/validation/rules/lints/mod.rs | 11 +++--- .../validation/rules/references/collector.rs | 10 ++---- .../validation/rules/references/metadata.rs | 6 ++-- .../src/validation/rules/references/mod.rs | 12 +++---- .../validation/rules/references/validator.rs | 15 ++++---- .../src/validation/visitors/location.rs | 3 +- .../src/validation/visitors/receivers.rs | 15 ++++---- .../src/validation/visitors/reporter.rs | 13 +++---- .../src/validation/visitors/version_set.rs | 10 +++--- .../schema/src/validation/visitors/visitor.rs | 18 ++++------ crates/codegen/schema/src/yaml/parser.rs | 18 ++++------ .../codegen/schema/src/yaml/serialization.rs | 6 ++-- crates/codegen/spec/src/grammar.rs | 4 ++- crates/codegen/spec/src/lib.rs | 10 +++--- crates/codegen/spec/src/markdown.rs | 3 +- crates/codegen/spec/src/reference.rs | 3 +- crates/codegen/testing/src/cst_output.rs | 12 +++---- crates/infra/cli/build.rs | 6 ++-- crates/infra/cli/src/commands/check/mod.rs | 10 ++---- crates/infra/cli/src/commands/ci/mod.rs | 7 ++-- crates/infra/cli/src/commands/lint/mod.rs | 10 +++--- crates/infra/cli/src/commands/mod.rs | 12 ++++--- .../cli/src/commands/publish/cargo/mod.rs | 4 ++- .../src/commands/publish/changesets/mod.rs | 8 ++--- .../commands/publish/github_release/mod.rs | 4 ++- .../src/commands/publish/lock_files/mod.rs | 3 +- crates/infra/cli/src/commands/publish/mod.rs | 13 ++++--- .../infra/cli/src/commands/publish/npm/mod.rs | 4 ++- crates/infra/cli/src/commands/run/mod.rs | 3 +- .../infra/cli/src/commands/setup/cargo/mod.rs | 3 +- crates/infra/cli/src/commands/setup/mod.rs | 8 ++--- .../infra/cli/src/commands/setup/npm/mod.rs | 3 +- .../cli/src/commands/setup/pipenv/mod.rs | 11 +++--- crates/infra/cli/src/commands/test/mod.rs | 4 ++- crates/infra/cli/src/commands/watch/mod.rs | 6 ++-- crates/infra/cli/src/main.rs | 3 +- crates/infra/cli/src/toolchains/mkdocs/mod.rs | 3 +- crates/infra/cli/src/toolchains/napi/cli.rs | 3 +- .../infra/cli/src/toolchains/napi/compiler.rs | 15 ++++---- .../infra/cli/src/toolchains/napi/config.rs | 3 +- crates/infra/cli/src/utils.rs | 6 ++-- crates/infra/utils/src/cargo/manifest.rs | 6 ++-- crates/infra/utils/src/cargo/workspace.rs | 13 ++++--- .../utils/src/codegen/common/file_system.rs | 6 ++-- .../utils/src/codegen/common/formatting.rs | 12 +++---- crates/infra/utils/src/codegen/read_write.rs | 4 ++- crates/infra/utils/src/codegen/write_only.rs | 16 ++++----- crates/infra/utils/src/commands/mod.rs | 22 +++++------- crates/infra/utils/src/errors/mod.rs | 3 +- crates/infra/utils/src/github/mod.rs | 6 ++-- crates/infra/utils/src/paths/extensions.rs | 6 ++-- crates/infra/utils/src/paths/walker.rs | 3 +- crates/solidity/inputs/language/build.rs | 3 +- .../solidity/inputs/language/src/grammar.rs | 21 ++++------- .../solidity/outputs/cargo/build/src/main.rs | 3 +- crates/solidity/outputs/cargo/crate/build.rs | 3 +- .../outputs/cargo/crate/src/generated/cst.rs | 8 ++--- .../cargo/crate/src/generated/cursor.rs | 8 ++--- .../cargo/crate/src/generated/language.rs | 20 +++++------ .../cargo/crate/src/generated/lexer.rs | 8 ++--- .../cargo/crate/src/generated/napi/mod.rs | 18 +++++----- .../crate/src/generated/napi/napi_cst.rs | 21 ++++------- .../crate/src/generated/napi/napi_cursor.rs | 9 +++-- .../src/generated/napi/napi_parse_error.rs | 2 +- .../src/generated/napi/napi_parse_output.rs | 5 +-- .../src/generated/napi/napi_text_index.rs | 2 +- .../cargo/crate/src/generated/parse_error.rs | 6 ++-- .../cargo/crate/src/generated/parse_output.rs | 5 ++- .../src/generated/support/choice_helper.rs | 8 +++-- .../crate/src/generated/support/context.rs | 2 +- .../src/generated/support/optional_helper.rs | 2 +- .../src/generated/support/parser_function.rs | 15 ++++---- .../src/generated/support/parser_result.rs | 8 ++--- .../generated/support/precedence_helper.rs | 11 +++--- .../crate/src/generated/support/recovery.rs | 4 +-- .../generated/support/repetition_helper.rs | 6 ++-- .../src/generated/support/separated_helper.rs | 20 +++++------ .../src/generated/support/sequence_helper.rs | 5 +-- .../cargo/crate/src/generated/text_index.rs | 6 ++-- .../solidity/outputs/cargo/crate/src/lib.rs | 4 +-- .../solidity/outputs/cargo/crate/src/main.rs | 13 ++++--- .../cargo/tests/src/cst_output/runner.rs | 7 ++-- .../tests/src/doc_examples/cursor_api.rs | 6 ++-- .../tests/src/doc_examples/simple_contract.rs | 8 ++--- .../outputs/cargo/tests/src/scanner/mod.rs | 6 ++-- crates/solidity/outputs/npm/build/src/main.rs | 3 +- crates/solidity/outputs/npm/crate/build.rs | 3 +- .../outputs/npm/crate/src/generated/cst.rs | 8 ++--- .../outputs/npm/crate/src/generated/cursor.rs | 8 ++--- .../npm/crate/src/generated/language.rs | 20 +++++------ .../outputs/npm/crate/src/generated/lexer.rs | 8 ++--- .../npm/crate/src/generated/napi/mod.rs | 18 +++++----- .../npm/crate/src/generated/napi/napi_cst.rs | 21 ++++------- .../crate/src/generated/napi/napi_cursor.rs | 9 +++-- .../src/generated/napi/napi_parse_error.rs | 2 +- .../src/generated/napi/napi_parse_output.rs | 5 +-- .../src/generated/napi/napi_text_index.rs | 2 +- .../npm/crate/src/generated/parse_error.rs | 6 ++-- .../npm/crate/src/generated/parse_output.rs | 5 ++- .../src/generated/support/choice_helper.rs | 8 +++-- .../crate/src/generated/support/context.rs | 2 +- .../src/generated/support/optional_helper.rs | 2 +- .../src/generated/support/parser_function.rs | 15 ++++---- .../src/generated/support/parser_result.rs | 8 ++--- .../generated/support/precedence_helper.rs | 11 +++--- .../crate/src/generated/support/recovery.rs | 4 +-- .../generated/support/repetition_helper.rs | 6 ++-- .../src/generated/support/separated_helper.rs | 20 +++++------ .../src/generated/support/sequence_helper.rs | 5 +-- .../npm/crate/src/generated/text_index.rs | 6 ++-- .../testing/sanctuary/src/datasets/git.rs | 14 +++----- crates/solidity/testing/sanctuary/src/main.rs | 14 ++++---- .../testing/sanctuary/src/reporting.rs | 6 ++-- .../testing/solc/src/utils/binaries.rs | 12 ++++--- .../testing/utils/src/cst_snapshots/mod.rs | 13 ++++--- .../testing/utils/src/node_extensions/mod.rs | 6 ++-- .../utils/src/node_extensions/tests.rs | 3 +- .../testing/utils/src/version_pragmas/mod.rs | 4 ++- 180 files changed, 665 insertions(+), 800 deletions(-) diff --git a/.rustfmt.toml b/.rustfmt.toml index 5cd356339d..3fc0d8e3d6 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -2,3 +2,4 @@ # https://github.com/rust-lang/rustfmt/blob/master/Configurations.md group_imports = "StdExternalCrate" +imports_granularity = "Module" diff --git a/.vscode/settings.json b/.vscode/settings.json index f2f66de70c..14ce20a8e7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,6 +9,9 @@ "rust-analyzer.check.allTargets": true, "rust-analyzer.check.command": "clippy", "rust-analyzer.check.features": "all", + "rust-analyzer.imports.granularity.enforce": true, + "rust-analyzer.imports.granularity.group": "module", + "rust-analyzer.imports.prefix": "crate", "rust-analyzer.rustfmt.extraArgs": [ "+nightly-2023-12-01" // Keep in sync with other "RUST_NIGHTLY_VERSION" references ], diff --git a/crates/codegen/ebnf/src/precedence_parser.rs b/crates/codegen/ebnf/src/precedence_parser.rs index 84d58cb6c5..587f9289e8 100644 --- a/crates/codegen/ebnf/src/precedence_parser.rs +++ b/crates/codegen/ebnf/src/precedence_parser.rs @@ -1,6 +1,7 @@ use codegen_schema::types::{OperatorModel, PrecedenceParserRef}; -use crate::{nodes::EbnfNode, EbnfSerializer}; +use crate::nodes::EbnfNode; +use crate::EbnfSerializer; impl EbnfNode { pub fn from_precedence_parser( diff --git a/crates/codegen/grammar/src/grammar.rs b/crates/codegen/grammar/src/grammar.rs index 72790ddea5..a3859f7506 100644 --- a/crates/codegen/grammar/src/grammar.rs +++ b/crates/codegen/grammar/src/grammar.rs @@ -2,10 +2,9 @@ use std::collections::{BTreeSet, HashMap}; use semver::Version; -use super::{ - GrammarVisitor, ParserDefinitionRef, PrecedenceParserDefinitionRef, ScannerDefinitionRef, - TriviaParserDefinitionRef, Visitable, -}; +use crate::parser_definition::{ParserDefinitionRef, TriviaParserDefinitionRef}; +use crate::visitor::{GrammarVisitor, Visitable}; +use crate::{PrecedenceParserDefinitionRef, ScannerDefinitionRef}; pub struct Grammar { pub name: String, diff --git a/crates/codegen/grammar/src/parser_definition.rs b/crates/codegen/grammar/src/parser_definition.rs index 6ff53c684f..bfe8cdfc8a 100644 --- a/crates/codegen/grammar/src/parser_definition.rs +++ b/crates/codegen/grammar/src/parser_definition.rs @@ -1,10 +1,8 @@ use std::fmt::Debug; use std::rc::Rc; -use super::{ - GrammarVisitor, PrecedenceParserDefinitionRef, ScannerDefinitionRef, VersionQualityRange, - Visitable, -}; +use crate::visitor::{GrammarVisitor, Visitable}; +use crate::{PrecedenceParserDefinitionRef, ScannerDefinitionRef, VersionQualityRange}; pub trait ParserDefinition: Debug { fn name(&self) -> &'static str; diff --git a/crates/codegen/grammar/src/precedence_parser_definition.rs b/crates/codegen/grammar/src/precedence_parser_definition.rs index dcbba9fdad..8f0c105415 100644 --- a/crates/codegen/grammar/src/precedence_parser_definition.rs +++ b/crates/codegen/grammar/src/precedence_parser_definition.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; use std::rc::Rc; -use super::{GrammarVisitor, ParserDefinitionNode, Visitable}; +use crate::{GrammarVisitor, ParserDefinitionNode, Visitable}; pub trait PrecedenceParserDefinition: Debug { fn name(&self) -> &'static str; diff --git a/crates/codegen/grammar/src/scanner_definition.rs b/crates/codegen/grammar/src/scanner_definition.rs index 31bd9c59cb..19a0cc1e65 100644 --- a/crates/codegen/grammar/src/scanner_definition.rs +++ b/crates/codegen/grammar/src/scanner_definition.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; use std::rc::Rc; -use super::{GrammarVisitor, VersionQualityRange, Visitable}; +use crate::{GrammarVisitor, VersionQualityRange, Visitable}; pub trait ScannerDefinition: Debug { fn name(&self) -> &'static str; diff --git a/crates/codegen/grammar/src/visitor.rs b/crates/codegen/grammar/src/visitor.rs index 5504840201..d6ce34521d 100644 --- a/crates/codegen/grammar/src/visitor.rs +++ b/crates/codegen/grammar/src/visitor.rs @@ -1,4 +1,4 @@ -use super::{ +use crate::{ Grammar, ParserDefinitionNode, ParserDefinitionRef, PrecedenceParserDefinitionNode, PrecedenceParserDefinitionRef, ScannerDefinitionNode, ScannerDefinitionRef, TriviaParserDefinitionRef, diff --git a/crates/codegen/language/definition/src/compiler/analysis/definitions.rs b/crates/codegen/language/definition/src/compiler/analysis/definitions.rs index 3972ae4a01..76ccdd088b 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/definitions.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/definitions.rs @@ -1,13 +1,9 @@ use std::collections::HashSet; -use crate::{ - compiler::{ - analysis::{Analysis, ItemMetadata}, - version_set::VersionSet, - }, - internals::Spanned, - model::{Identifier, SpannedItem, SpannedVersionSpecifier}, -}; +use crate::compiler::analysis::{Analysis, ItemMetadata}; +use crate::compiler::version_set::VersionSet; +use crate::internals::Spanned; +use crate::model::{Identifier, SpannedItem, SpannedVersionSpecifier}; pub(crate) fn analyze_definitions(analysis: &mut Analysis) { collect_top_level_items(analysis); diff --git a/crates/codegen/language/definition/src/compiler/analysis/mod.rs b/crates/codegen/language/definition/src/compiler/analysis/mod.rs index 402cbb5b44..249fb3d7fa 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/mod.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/mod.rs @@ -8,15 +8,12 @@ use std::rc::Rc; use indexmap::IndexMap; use proc_macro2::Span; -use crate::{ - compiler::analysis::{ - definitions::analyze_definitions, reachability::analyze_reachability, - references::analyze_references, - }, - compiler::version_set::VersionSet, - internals::{ErrorsCollection, ParseOutput, Spanned}, - model::{Identifier, SpannedItem, SpannedLanguage}, -}; +use crate::compiler::analysis::definitions::analyze_definitions; +use crate::compiler::analysis::reachability::analyze_reachability; +use crate::compiler::analysis::references::analyze_references; +use crate::compiler::version_set::VersionSet; +use crate::internals::{ErrorsCollection, ParseOutput, Spanned}; +use crate::model::{Identifier, SpannedItem, SpannedLanguage}; pub(crate) struct Analysis { pub errors: ErrorsCollection, diff --git a/crates/codegen/language/definition/src/compiler/analysis/reachability.rs b/crates/codegen/language/definition/src/compiler/analysis/reachability.rs index 3829f53020..983c2ed1f1 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/reachability.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/reachability.rs @@ -1,9 +1,8 @@ use std::collections::HashSet; -use crate::{ - compiler::{analysis::Analysis, version_set::VersionSet}, - model::{Identifier, SpannedTriviaParser}, -}; +use crate::compiler::analysis::Analysis; +use crate::compiler::version_set::VersionSet; +use crate::model::{Identifier, SpannedTriviaParser}; pub(crate) fn analyze_reachability(analysis: &mut Analysis) { check_unreachabable_items(analysis); diff --git a/crates/codegen/language/definition/src/compiler/analysis/references.rs b/crates/codegen/language/definition/src/compiler/analysis/references.rs index 6cef7a596c..a324a783f6 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/references.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/references.rs @@ -3,21 +3,19 @@ use std::fmt::Debug; use indexmap::IndexMap; use semver::Version; -use crate::{ - compiler::{analysis::Analysis, version_set::VersionSet}, - internals::Spanned, - model::{ - Identifier, SpannedEnumItem, SpannedEnumVariant, SpannedField, SpannedFragmentItem, - SpannedItem, - SpannedItemDiscriminants::{ - self, Enum, Fragment, Keyword, Precedence, Repeated, Separated, Struct, Token, Trivia, - }, - SpannedKeywordDefinition, SpannedKeywordItem, SpannedPrecedenceExpression, - SpannedPrecedenceItem, SpannedPrecedenceOperator, SpannedPrimaryExpression, - SpannedRepeatedItem, SpannedScanner, SpannedSeparatedItem, SpannedStructItem, - SpannedTokenDefinition, SpannedTokenItem, SpannedTriviaItem, SpannedTriviaParser, - SpannedVersionSpecifier, - }, +use crate::compiler::analysis::Analysis; +use crate::compiler::version_set::VersionSet; +use crate::internals::Spanned; +use crate::model::SpannedItemDiscriminants::{ + self, Enum, Fragment, Keyword, Precedence, Repeated, Separated, Struct, Token, Trivia, +}; +use crate::model::{ + Identifier, SpannedEnumItem, SpannedEnumVariant, SpannedField, SpannedFragmentItem, + SpannedItem, SpannedKeywordDefinition, SpannedKeywordItem, SpannedPrecedenceExpression, + SpannedPrecedenceItem, SpannedPrecedenceOperator, SpannedPrimaryExpression, + SpannedRepeatedItem, SpannedScanner, SpannedSeparatedItem, SpannedStructItem, + SpannedTokenDefinition, SpannedTokenItem, SpannedTriviaItem, SpannedTriviaParser, + SpannedVersionSpecifier, }; pub(crate) fn analyze_references(analysis: &mut Analysis) { diff --git a/crates/codegen/language/definition/src/compiler/analysis/utils.rs b/crates/codegen/language/definition/src/compiler/analysis/utils.rs index 321be973be..7b1ade02b1 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/utils.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/utils.rs @@ -1,7 +1,6 @@ -use crate::{ - compiler::{analysis::Analysis, version_set::VersionSet}, - model::SpannedVersionSpecifier, -}; +use crate::compiler::analysis::Analysis; +use crate::compiler::version_set::VersionSet; +use crate::model::SpannedVersionSpecifier; impl Analysis { pub fn add_specifier(&self, set: &mut VersionSet, specifier: &SpannedVersionSpecifier) { diff --git a/crates/codegen/language/definition/src/compiler/emitter.rs b/crates/codegen/language/definition/src/compiler/emitter.rs index 1c507795d7..73d1132166 100644 --- a/crates/codegen/language/definition/src/compiler/emitter.rs +++ b/crates/codegen/language/definition/src/compiler/emitter.rs @@ -2,7 +2,8 @@ use inflector::Inflector; use proc_macro2::TokenStream; use quote::{format_ident, quote}; -use crate::{compiler::analysis::Analysis, internals::WriteOutputTokens}; +use crate::compiler::analysis::Analysis; +use crate::internals::WriteOutputTokens; pub(crate) struct LanguageEmitter; diff --git a/crates/codegen/language/definition/src/compiler/mod.rs b/crates/codegen/language/definition/src/compiler/mod.rs index 4b73b62cfc..3688569029 100644 --- a/crates/codegen/language/definition/src/compiler/mod.rs +++ b/crates/codegen/language/definition/src/compiler/mod.rs @@ -4,10 +4,9 @@ mod version_set; use proc_macro2::TokenStream; -use crate::{ - compiler::{analysis::Analysis, emitter::LanguageEmitter}, - internals::ParseAdapter, -}; +use crate::compiler::analysis::Analysis; +use crate::compiler::emitter::LanguageEmitter; +use crate::internals::ParseAdapter; pub struct LanguageCompiler; diff --git a/crates/codegen/language/definition/src/compiler/version_set.rs b/crates/codegen/language/definition/src/compiler/version_set.rs index 2af8bf7e0f..0a447c9d93 100644 --- a/crates/codegen/language/definition/src/compiler/version_set.rs +++ b/crates/codegen/language/definition/src/compiler/version_set.rs @@ -1,4 +1,6 @@ -use std::{fmt::Display, mem::swap, ops::Range}; +use std::fmt::Display; +use std::mem::swap; +use std::ops::Range; use semver::Version; 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 951dbe6428..567c6e1033 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,10 +1,8 @@ use proc_macro2::TokenStream; use syn::parse::{Parse, ParseStream}; -use crate::{ - internals::{ErrorsCollection, ParseInputTokens, Result}, - model::SpannedLanguage, -}; +use crate::internals::{ErrorsCollection, ParseInputTokens, Result}; +use crate::model::SpannedLanguage; pub(crate) struct ParseAdapter; 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 270e670888..f1a22f0548 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,13 +1,14 @@ -use std::{fmt::Debug, rc::Rc}; +use std::fmt::Debug; +use std::rc::Rc; use indexmap::{IndexMap, IndexSet}; use proc_macro2::Ident; use semver::Version; -use syn::{parse::ParseStream, LitBool, LitChar, LitStr}; +use syn::parse::ParseStream; +use syn::{LitBool, LitChar, LitStr}; -use crate::internals::{ - parse_input_tokens::ParseHelpers, ErrorsCollection, ParseInputTokens, Result, Spanned, -}; +use crate::internals::parse_input_tokens::ParseHelpers; +use crate::internals::{ErrorsCollection, ParseInputTokens, Result, Spanned}; impl ParseInputTokens for bool { fn parse_value(input: ParseStream<'_>, _: &mut ErrorsCollection) -> Result { 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 fa2f56706d..3b151fd48a 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,8 +1,10 @@ use std::fmt::Debug; use indexmap::IndexMap; -use proc_macro2::{extra::DelimSpan, Delimiter, Ident, TokenStream}; -use syn::{braced, bracketed, parenthesized, parse::ParseStream, Token}; +use proc_macro2::extra::DelimSpan; +use proc_macro2::{Delimiter, Ident, TokenStream}; +use syn::parse::ParseStream; +use syn::{braced, bracketed, parenthesized, Token}; use crate::internals::{Error, ErrorsCollection, ParseInputTokens, Result, Spanned}; diff --git a/crates/codegen/language/definition/src/model/manifest.rs b/crates/codegen/language/definition/src/model/manifest.rs index 9d90a886f3..2ea97f153d 100644 --- a/crates/codegen/language/definition/src/model/manifest.rs +++ b/crates/codegen/language/definition/src/model/manifest.rs @@ -1,4 +1,5 @@ -use std::{collections::BTreeSet, rc::Rc}; +use std::collections::BTreeSet; +use std::rc::Rc; use codegen_language_internal_macros::{derive_spanned_type, ParseInputTokens, WriteOutputTokens}; use indexmap::IndexSet; diff --git a/crates/codegen/language/definition/src/model/utils/identifier.rs b/crates/codegen/language/definition/src/model/utils/identifier.rs index 7857fb4ea1..bf7403a4fd 100644 --- a/crates/codegen/language/definition/src/model/utils/identifier.rs +++ b/crates/codegen/language/definition/src/model/utils/identifier.rs @@ -3,7 +3,8 @@ use std::ops::Deref; use proc_macro2::{Literal, TokenStream}; use quote::quote; use serde::{Deserialize, Serialize}; -use syn::{parse::ParseStream, Ident}; +use syn::parse::ParseStream; +use syn::Ident; use crate::internals::{ ErrorsCollection, ParseHelpers, ParseInputTokens, Result, WriteOutputTokens, diff --git a/crates/codegen/language/internal_macros/src/derive/spanned.rs b/crates/codegen/language/internal_macros/src/derive/spanned.rs index c905a36f94..094b82800c 100644 --- a/crates/codegen/language/internal_macros/src/derive/spanned.rs +++ b/crates/codegen/language/internal_macros/src/derive/spanned.rs @@ -1,6 +1,7 @@ use proc_macro2::TokenStream; use quote::{format_ident, quote, ToTokens}; -use syn::{fold::Fold, parse_quote, Error, GenericArgument, Type}; +use syn::fold::Fold; +use syn::{parse_quote, Error, GenericArgument, Type}; use crate::input_model::{add_spanned_prefix, InputField, InputItem, InputVariant}; diff --git a/crates/codegen/language/internal_macros/src/input_model.rs b/crates/codegen/language/internal_macros/src/input_model.rs index 865be8577e..c6db5afc5f 100644 --- a/crates/codegen/language/internal_macros/src/input_model.rs +++ b/crates/codegen/language/internal_macros/src/input_model.rs @@ -2,10 +2,8 @@ use std::fmt::Display; use itertools::Itertools; use quote::ToTokens; -use syn::{ - parse::{Parse, ParseStream}, - Data, DeriveInput, Error, Fields, FieldsNamed, Ident, Result, Type, Variant, -}; +use syn::parse::{Parse, ParseStream}; +use syn::{Data, DeriveInput, Error, Fields, FieldsNamed, Ident, Result, Type, Variant}; pub enum InputItem { Struct { diff --git a/crates/codegen/parser/generator/src/code_generator.rs b/crates/codegen/parser/generator/src/code_generator.rs index 5f7be8c309..ac95c7eb1c 100644 --- a/crates/codegen/parser/generator/src/code_generator.rs +++ b/crates/codegen/parser/generator/src/code_generator.rs @@ -1,8 +1,6 @@ -use std::{ - collections::{BTreeMap, BTreeSet}, - mem, - path::Path, -}; +use std::collections::{BTreeMap, BTreeSet}; +use std::mem; +use std::path::Path; use anyhow::Result; use codegen_grammar::{ @@ -10,16 +8,16 @@ use codegen_grammar::{ PrecedenceParserDefinitionRef, ScannerDefinitionNode, ScannerDefinitionRef, TriviaParserDefinitionRef, }; -use infra_utils::{cargo::CargoWorkspace, codegen::Codegen}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::codegen::Codegen; use quote::{format_ident, quote}; use semver::Version; use serde::Serialize; -use super::{ - parser_definition::ParserDefinitionExtensions, - precedence_parser_definition::PrecedenceParserDefinitionExtensions, - scanner_definition::ScannerDefinitionExtensions, trie::Trie, -}; +use crate::parser_definition::ParserDefinitionExtensions; +use crate::precedence_parser_definition::PrecedenceParserDefinitionExtensions; +use crate::scanner_definition::ScannerDefinitionExtensions; +use crate::trie::Trie; #[derive(Default, Serialize)] pub struct CodeGenerator { diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index 5abba10cb1..149e619fd9 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -5,7 +5,7 @@ use inflector::Inflector; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; -use super::parser_definition::ParserDefinitionNodeExtensions; +use crate::parser_definition::ParserDefinitionNodeExtensions; pub trait PrecedenceParserDefinitionExtensions { fn to_parser_code(&self) -> TokenStream; diff --git a/crates/codegen/parser/generator/src/scanner_definition.rs b/crates/codegen/parser/generator/src/scanner_definition.rs index 831ee85e38..034d456a5c 100644 --- a/crates/codegen/parser/generator/src/scanner_definition.rs +++ b/crates/codegen/parser/generator/src/scanner_definition.rs @@ -5,7 +5,7 @@ use inflector::Inflector; use proc_macro2::TokenStream; use quote::{format_ident, quote}; -use super::parser_definition::VersionQualityRangeVecExtensions; +use crate::parser_definition::VersionQualityRangeVecExtensions; pub trait ScannerDefinitionExtensions { fn to_scanner_code(&self) -> TokenStream; diff --git a/crates/codegen/parser/generator/src/trie.rs b/crates/codegen/parser/generator/src/trie.rs index 89fd115875..61b586cd63 100644 --- a/crates/codegen/parser/generator/src/trie.rs +++ b/crates/codegen/parser/generator/src/trie.rs @@ -1,10 +1,11 @@ -use std::{collections::BTreeMap, fmt::Debug}; +use std::collections::BTreeMap; +use std::fmt::Debug; use codegen_grammar::{ScannerDefinitionNode, ScannerDefinitionRef}; use proc_macro2::TokenStream; use quote::{format_ident, quote}; -use super::parser_definition::VersionQualityRangeVecExtensions; +use crate::parser_definition::VersionQualityRangeVecExtensions; #[derive(Clone, Debug, Default)] pub struct Trie { diff --git a/crates/codegen/parser/runtime/src/cst.rs b/crates/codegen/parser/runtime/src/cst.rs index 75bae67260..f76f008edb 100644 --- a/crates/codegen/parser/runtime/src/cst.rs +++ b/crates/codegen/parser/runtime/src/cst.rs @@ -2,11 +2,9 @@ use std::rc::Rc; use serde::Serialize; -use super::{ - cursor::Cursor, - kinds::{RuleKind, TokenKind}, - text_index::TextIndex, -}; +use crate::cursor::Cursor; +use crate::kinds::{RuleKind, TokenKind}; +use crate::text_index::TextIndex; #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct RuleNode { diff --git a/crates/codegen/parser/runtime/src/cursor.rs b/crates/codegen/parser/runtime/src/cursor.rs index e8f92483fd..8450548c72 100644 --- a/crates/codegen/parser/runtime/src/cursor.rs +++ b/crates/codegen/parser/runtime/src/cursor.rs @@ -2,11 +2,9 @@ use std::rc::Rc; -use super::{ - cst::{Node, RuleNode}, - kinds::{RuleKind, TokenKind}, - text_index::{TextIndex, TextRange}, -}; +use crate::cst::{Node, RuleNode}; +use crate::kinds::{RuleKind, TokenKind}; +use crate::text_index::{TextIndex, TextRange}; /// A [`PathNode`] that points to a [`RuleNode`]. #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/crates/codegen/parser/runtime/src/lexer.rs b/crates/codegen/parser/runtime/src/lexer.rs index 923249f213..8b80f422e0 100644 --- a/crates/codegen/parser/runtime/src/lexer.rs +++ b/crates/codegen/parser/runtime/src/lexer.rs @@ -1,8 +1,6 @@ -use crate::{ - cst, - kinds::{IsLexicalContext, TokenKind}, - support::{ParserContext, ParserResult}, -}; +use crate::cst; +use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::support::{ParserContext, ParserResult}; pub trait Lexer { // Generated by the templating engine diff --git a/crates/codegen/parser/runtime/src/napi/mod.rs b/crates/codegen/parser/runtime/src/napi/mod.rs index 7591c98118..d6c896e7f3 100644 --- a/crates/codegen/parser/runtime/src/napi/mod.rs +++ b/crates/codegen/parser/runtime/src/napi/mod.rs @@ -4,13 +4,13 @@ pub mod napi_parse_error; pub mod napi_parse_output; pub mod napi_text_index; -pub type RustCursor = super::cursor::Cursor; -pub type RustNode = super::cst::Node; -pub type RustParseOutput = super::parse_output::ParseOutput; -pub type RustParseError = super::parse_error::ParseError; -pub type RustRuleNode = super::cst::RuleNode; -pub type RustTokenNode = super::cst::TokenNode; -pub type RustTextIndex = super::text_index::TextIndex; -pub type RustTextRange = super::text_index::TextRange; +pub type RustCursor = crate::cursor::Cursor; +pub type RustNode = crate::cst::Node; +pub type RustParseOutput = crate::parse_output::ParseOutput; +pub type RustParseError = crate::parse_error::ParseError; +pub type RustRuleNode = crate::cst::RuleNode; +pub type RustTokenNode = crate::cst::TokenNode; +pub type RustTextIndex = crate::text_index::TextIndex; +pub type RustTextRange = crate::text_index::TextRange; -pub use super::kinds::*; +pub use crate::kinds::*; diff --git a/crates/codegen/parser/runtime/src/napi/napi_cst.rs b/crates/codegen/parser/runtime/src/napi/napi_cst.rs index a2393597e1..a49da48d22 100644 --- a/crates/codegen/parser/runtime/src/napi/napi_cst.rs +++ b/crates/codegen/parser/runtime/src/napi/napi_cst.rs @@ -1,19 +1,12 @@ use std::rc::Rc; -use napi_cursor::Cursor; -use napi_text_index::TextIndex; -use { - napi::{ - bindgen_prelude::{Env, ToNapiValue}, - JsObject, NapiValue, - }, - napi_derive::napi, -}; - -use super::{ - napi_cursor, napi_text_index, RuleKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, - TokenKind, -}; +use napi::bindgen_prelude::{Env, ToNapiValue}; +use napi::{JsObject, NapiValue}; +use napi_derive::napi; + +use crate::napi::napi_cursor::Cursor; +use crate::napi::napi_text_index::TextIndex; +use crate::napi::{RuleKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, TokenKind}; #[napi(object, namespace = "cst")] pub enum NodeType { diff --git a/crates/codegen/parser/runtime/src/napi/napi_cursor.rs b/crates/codegen/parser/runtime/src/napi/napi_cursor.rs index 3ccbef7df9..9124b3a447 100644 --- a/crates/codegen/parser/runtime/src/napi/napi_cursor.rs +++ b/crates/codegen/parser/runtime/src/napi/napi_cursor.rs @@ -3,14 +3,13 @@ // 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; +use napi::JsObject; use napi_cst::ToJS; +use napi_derive::napi; use napi_text_index::{TextIndex, TextRange}; -use { - napi::{bindgen_prelude::Env, JsObject}, - napi_derive::napi, -}; -use super::{napi_cst, napi_text_index, RuleKind, RustCursor, TokenKind}; +use crate::napi::{napi_cst, napi_text_index, RuleKind, RustCursor, TokenKind}; #[napi(namespace = "cursor")] pub struct Cursor(Box); 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 2df04c8b6d..00aa2e2d0f 100644 --- a/crates/codegen/parser/runtime/src/napi/napi_parse_error.rs +++ b/crates/codegen/parser/runtime/src/napi/napi_parse_error.rs @@ -4,7 +4,7 @@ use napi_derive::napi; use napi_text_index::TextRange; -use super::{napi_text_index, RustParseError}; +use crate::napi::{napi_text_index, RustParseError}; #[napi(namespace = "parse_error")] #[derive(PartialEq, Clone)] diff --git a/crates/codegen/parser/runtime/src/napi/napi_parse_output.rs b/crates/codegen/parser/runtime/src/napi/napi_parse_output.rs index 4f5464f201..d0ef152b5e 100644 --- a/crates/codegen/parser/runtime/src/napi/napi_parse_output.rs +++ b/crates/codegen/parser/runtime/src/napi/napi_parse_output.rs @@ -1,7 +1,8 @@ +use napi::bindgen_prelude::Env; use napi_cst::ToJS; -use {napi::bindgen_prelude::Env, napi_derive::napi}; +use napi_derive::napi; -use super::{napi_cst, napi_cursor, napi_parse_error, RustParseOutput}; +use crate::napi::{napi_cst, napi_cursor, napi_parse_error, RustParseOutput}; #[napi(namespace = "parse_output")] pub struct ParseOutput(RustParseOutput); 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 ab45af8221..78710c3369 100644 --- a/crates/codegen/parser/runtime/src/napi/napi_text_index.rs +++ b/crates/codegen/parser/runtime/src/napi/napi_text_index.rs @@ -1,6 +1,6 @@ use napi_derive::napi; -use super::{RustTextIndex, RustTextRange}; +use crate::napi::{RustTextIndex, RustTextRange}; #[napi(object, namespace = "text_index")] #[derive(Copy, Clone)] diff --git a/crates/codegen/parser/runtime/src/parse_error.rs b/crates/codegen/parser/runtime/src/parse_error.rs index 9612eaf0e4..b733316b50 100644 --- a/crates/codegen/parser/runtime/src/parse_error.rs +++ b/crates/codegen/parser/runtime/src/parse_error.rs @@ -1,9 +1,7 @@ use std::collections::BTreeSet; -use super::{ - kinds::TokenKind, - text_index::{TextIndex, TextRange}, -}; +use crate::kinds::TokenKind; +use crate::text_index::{TextIndex, TextRange}; #[derive(Debug, PartialEq, Eq, Clone)] pub struct ParseError { diff --git a/crates/codegen/parser/runtime/src/parse_output.rs b/crates/codegen/parser/runtime/src/parse_output.rs index 46ad068169..5477bf511c 100644 --- a/crates/codegen/parser/runtime/src/parse_output.rs +++ b/crates/codegen/parser/runtime/src/parse_output.rs @@ -1,4 +1,7 @@ -use crate::{cst, cursor::Cursor, parse_error::ParseError, text_index::TextIndex}; +use crate::cst; +use crate::cursor::Cursor; +use crate::parse_error::ParseError; +use crate::text_index::TextIndex; #[derive(Debug, PartialEq)] pub struct ParseOutput { diff --git a/crates/codegen/parser/runtime/src/support/choice_helper.rs b/crates/codegen/parser/runtime/src/support/choice_helper.rs index a4505d27a5..6bdc44959c 100644 --- a/crates/codegen/parser/runtime/src/support/choice_helper.rs +++ b/crates/codegen/parser/runtime/src/support/choice_helper.rs @@ -1,8 +1,12 @@ use std::mem; use std::ops::ControlFlow; -use super::{context::Marker, ParserContext, ParserResult}; -use crate::{cst, kinds::TokenKind, parse_error::ParseError, text_index::TextIndex}; +use crate::cst; +use crate::kinds::TokenKind; +use crate::parse_error::ParseError; +use crate::support::context::{Marker, ParserContext}; +use crate::support::ParserResult; +use crate::text_index::TextIndex; /// Starting from a given position in the input, this helper will try to pick (and remember) a best match. Settles on /// a first full match if possible, otherwise on the best incomplete match. diff --git a/crates/codegen/parser/runtime/src/support/context.rs b/crates/codegen/parser/runtime/src/support/context.rs index 791c80c0e9..f8601f13cb 100644 --- a/crates/codegen/parser/runtime/src/support/context.rs +++ b/crates/codegen/parser/runtime/src/support/context.rs @@ -1,9 +1,9 @@ use std::mem; use std::ops::Range; -use super::super::text_index::TextIndex; use crate::kinds::TokenKind; use crate::parse_error::ParseError; +use crate::text_index::TextIndex; pub struct ParserContext<'s> { source: &'s str, diff --git a/crates/codegen/parser/runtime/src/support/optional_helper.rs b/crates/codegen/parser/runtime/src/support/optional_helper.rs index 519ca87858..6d06d36e0b 100644 --- a/crates/codegen/parser/runtime/src/support/optional_helper.rs +++ b/crates/codegen/parser/runtime/src/support/optional_helper.rs @@ -1,4 +1,4 @@ -use super::parser_result::ParserResult; +use crate::support::parser_result::ParserResult; pub struct OptionalHelper; diff --git a/crates/codegen/parser/runtime/src/support/parser_function.rs b/crates/codegen/parser/runtime/src/support/parser_function.rs index 5c2a72c9bd..dea8ea38f9 100644 --- a/crates/codegen/parser/runtime/src/support/parser_function.rs +++ b/crates/codegen/parser/runtime/src/support/parser_function.rs @@ -1,13 +1,12 @@ use std::rc::Rc; -use super::{ - super::{ - cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput, - text_index::TextIndex, - }, - context::ParserContext, - parser_result::{IncompleteMatch, Match, ParserResult, SkippedUntil}, -}; +use crate::cst; +use crate::kinds::TokenKind; +use crate::parse_error::ParseError; +use crate::parse_output::ParseOutput; +use crate::support::context::ParserContext; +use crate::support::parser_result::{IncompleteMatch, Match, ParserResult, SkippedUntil}; +use crate::text_index::TextIndex; pub trait ParserFunction where diff --git a/crates/codegen/parser/runtime/src/support/parser_result.rs b/crates/codegen/parser/runtime/src/support/parser_result.rs index 0d29c13dd4..e70e3032ce 100644 --- a/crates/codegen/parser/runtime/src/support/parser_result.rs +++ b/crates/codegen/parser/runtime/src/support/parser_result.rs @@ -1,8 +1,6 @@ -use super::super::{ - cst, - kinds::{RuleKind, TokenKind}, - text_index::TextIndex, -}; +use crate::cst; +use crate::kinds::{RuleKind, TokenKind}; +use crate::text_index::TextIndex; #[derive(PartialEq, Eq, Clone, Debug)] pub enum ParserResult { diff --git a/crates/codegen/parser/runtime/src/support/precedence_helper.rs b/crates/codegen/parser/runtime/src/support/precedence_helper.rs index 2ef41b7dcd..75a261751b 100644 --- a/crates/codegen/parser/runtime/src/support/precedence_helper.rs +++ b/crates/codegen/parser/runtime/src/support/precedence_helper.rs @@ -1,10 +1,7 @@ -use super::{ - super::{cst, kinds::RuleKind}, - parser_result::{ - ParserResult, - PrattElement::{self, Binary, Expression, Postfix, Prefix}, - }, -}; +use crate::cst; +use crate::kinds::RuleKind; +use crate::support::parser_result::ParserResult; +use crate::support::parser_result::PrattElement::{self, Binary, Expression, Postfix, Prefix}; pub struct PrecedenceHelper; diff --git a/crates/codegen/parser/runtime/src/support/recovery.rs b/crates/codegen/parser/runtime/src/support/recovery.rs index 96a93ab8a7..4e573c3159 100644 --- a/crates/codegen/parser/runtime/src/support/recovery.rs +++ b/crates/codegen/parser/runtime/src/support/recovery.rs @@ -1,9 +1,9 @@ -use super::parser_result::SkippedUntil; -use super::ParserContext; use crate::cst; use crate::kinds::{IsLexicalContext, TokenKind}; use crate::lexer::Lexer; use crate::parse_error::ParseError; +use crate::support::context::ParserContext; +use crate::support::parser_result::SkippedUntil; use crate::support::ParserResult; use crate::text_index::{TextRange, TextRangeExtensions as _}; diff --git a/crates/codegen/parser/runtime/src/support/repetition_helper.rs b/crates/codegen/parser/runtime/src/support/repetition_helper.rs index b5072e72cd..2fcf23491d 100644 --- a/crates/codegen/parser/runtime/src/support/repetition_helper.rs +++ b/crates/codegen/parser/runtime/src/support/repetition_helper.rs @@ -1,7 +1,5 @@ -use super::{ - context::ParserContext, - parser_result::{IncompleteMatch, NoMatch, ParserResult}, -}; +use crate::support::context::ParserContext; +use crate::support::parser_result::{IncompleteMatch, NoMatch, ParserResult}; pub struct RepetitionHelper; diff --git a/crates/codegen/parser/runtime/src/support/separated_helper.rs b/crates/codegen/parser/runtime/src/support/separated_helper.rs index 14d4d52ed9..07e5702400 100644 --- a/crates/codegen/parser/runtime/src/support/separated_helper.rs +++ b/crates/codegen/parser/runtime/src/support/separated_helper.rs @@ -1,15 +1,11 @@ -use crate::{ - cst, - kinds::{IsLexicalContext, TokenKind}, - lexer::Lexer, - parse_error::ParseError, - support::{ - parser_result::{ParserResult, SkippedUntil}, - recovery::skip_until_with_nested_delims, - ParserContext, - }, - text_index::TextRangeExtensions, -}; +use crate::cst; +use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::lexer::Lexer; +use crate::parse_error::ParseError; +use crate::support::parser_result::{ParserResult, SkippedUntil}; +use crate::support::recovery::skip_until_with_nested_delims; +use crate::support::ParserContext; +use crate::text_index::TextRangeExtensions; pub struct SeparatedHelper; diff --git a/crates/codegen/parser/runtime/src/support/sequence_helper.rs b/crates/codegen/parser/runtime/src/support/sequence_helper.rs index 3fcf451119..08827bf7e1 100644 --- a/crates/codegen/parser/runtime/src/support/sequence_helper.rs +++ b/crates/codegen/parser/runtime/src/support/sequence_helper.rs @@ -1,7 +1,8 @@ use std::ops::ControlFlow; -use super::parser_result::{Match, ParserResult, PrattElement, SkippedUntil}; -use crate::{cst, kinds::TokenKind}; +use crate::cst; +use crate::kinds::TokenKind; +use crate::support::parser_result::{Match, ParserResult, PrattElement, SkippedUntil}; /// Keeps accumulating parses sequentially until it hits an incomplete or no match. #[must_use] diff --git a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 index 712d824051..4dab4db4b1 100644 --- a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 +++ b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 @@ -1,26 +1,27 @@ // 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)] +#![allow( + clippy::if_not_else, + clippy::too_many_lines, + clippy::unused_self, + clippy::struct_excessive_bools, + clippy::similar_names +)] +use semver::Version; #[cfg(feature = "slang_napi_interfaces")] use napi_derive::napi; -use semver::Version; - -use super::{ - cst, - kinds::{RuleKind, TokenKind, IsLexicalContext, LexicalContextType}, - lexer::Lexer, - parse_output::ParseOutput, - support::{ - ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, - PrecedenceHelper, RecoverFromNoMatch, SeparatedHelper, SequenceHelper, ZeroOrMoreHelper, - }, -}; - -pub use super::kinds::LexicalContext; - +use crate::cst; +pub use crate::kinds::LexicalContext; +use crate::kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}; +use crate::lexer::Lexer; #[cfg(feature = "slang_napi_interfaces")] -use super::napi::napi_parse_output::ParseOutput as NAPIParseOutput; +use crate::napi::napi_parse_output::ParseOutput as NAPIParseOutput; +use crate::parse_output::ParseOutput; +use crate::support::{ + ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, + PrecedenceHelper, RecoverFromNoMatch, SeparatedHelper, SequenceHelper, ZeroOrMoreHelper, +}; #[derive(Debug)] #[cfg_attr(feature = "slang_napi_interfaces", napi(namespace = "language"))] diff --git a/crates/codegen/parser/runtime/src/text_index.rs b/crates/codegen/parser/runtime/src/text_index.rs index 2e96f65534..b4c56ada0f 100644 --- a/crates/codegen/parser/runtime/src/text_index.rs +++ b/crates/codegen/parser/runtime/src/text_index.rs @@ -1,7 +1,5 @@ -use std::{ - fmt::Display, - ops::{Add, AddAssign, Range, Sub, SubAssign}, -}; +use std::fmt::Display; +use std::ops::{Add, AddAssign, Range, Sub, SubAssign}; use serde::Serialize; diff --git a/crates/codegen/schema/src/compiler.rs b/crates/codegen/schema/src/compiler.rs index 257e2f28f8..94e081437d 100644 --- a/crates/codegen/schema/src/compiler.rs +++ b/crates/codegen/schema/src/compiler.rs @@ -1,19 +1,15 @@ use std::path::{Path, PathBuf}; use anyhow::Result; -use infra_utils::{ - codegen::{Codegen, CodegenReadWrite}, - errors::{InfraErrors, Position}, -}; +use infra_utils::codegen::{Codegen, CodegenReadWrite}; +use infra_utils::errors::{InfraErrors, Position}; -use crate::{ - types::{ - LanguageDefinition, LanguageDefinitionRef, LanguageSection, LanguageTopic, ManifestFile, - ManifestSection, ManifestTopic, ProductionsFile, - }, - validation::validate_language, - yaml::deserialize_yaml, +use crate::types::{ + LanguageDefinition, LanguageDefinitionRef, LanguageSection, LanguageTopic, ManifestFile, + ManifestSection, ManifestTopic, ProductionsFile, }; +use crate::validation::validate_language; +use crate::yaml::deserialize_yaml; impl LanguageDefinition { pub fn compile(language_dir: PathBuf) -> Result { diff --git a/crates/codegen/schema/src/types/language.rs b/crates/codegen/schema/src/types/language.rs index 7dd10f35c1..2b094abd47 100644 --- a/crates/codegen/schema/src/types/language.rs +++ b/crates/codegen/schema/src/types/language.rs @@ -1,4 +1,5 @@ -use std::{path::PathBuf, rc::Rc}; +use std::path::PathBuf; +use std::rc::Rc; use indexmap::{IndexMap, IndexSet}; use semver::Version; diff --git a/crates/codegen/schema/src/types/production.rs b/crates/codegen/schema/src/types/production.rs index fcdb44e680..3cd1687f48 100644 --- a/crates/codegen/schema/src/types/production.rs +++ b/crates/codegen/schema/src/types/production.rs @@ -5,7 +5,9 @@ use schemars::JsonSchema; use semver::Version; use serde::{Deserialize, Serialize}; -use super::{parser::Parser, precedence_parser::PrecedenceParser, scanner::Scanner}; +use crate::types::parser::Parser; +use crate::types::precedence_parser::PrecedenceParser; +use crate::types::scanner::Scanner; pub type ProductionRef = Rc; 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 2a304e332e..b073aefac9 100644 --- a/crates/codegen/schema/src/validation/rules/definitions/keywords/collector.rs +++ b/crates/codegen/schema/src/validation/rules/definitions/keywords/collector.rs @@ -1,9 +1,7 @@ use std::collections::HashMap; -use crate::{ - types::{LanguageDefinitionRef, ProductionRef, ScannerDefinition, ScannerRef}, - validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}, -}; +use crate::types::{LanguageDefinitionRef, ProductionRef, ScannerDefinition, ScannerRef}; +use crate::validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}; pub struct KeywordsCollector { keywords: HashMap, diff --git a/crates/codegen/schema/src/validation/rules/definitions/keywords/mod.rs b/crates/codegen/schema/src/validation/rules/definitions/keywords/mod.rs index 6c7b12cdc5..d3fff7cd1b 100644 --- a/crates/codegen/schema/src/validation/rules/definitions/keywords/mod.rs +++ b/crates/codegen/schema/src/validation/rules/definitions/keywords/mod.rs @@ -1,15 +1,10 @@ mod collector; mod validator; -use crate::{ - types::LanguageDefinitionRef, - validation::{ - rules::definitions::keywords::{ - collector::KeywordsCollector, validator::KeywordsValidator, - }, - visitors::Reporter, - }, -}; +use crate::types::LanguageDefinitionRef; +use crate::validation::rules::definitions::keywords::collector::KeywordsCollector; +use crate::validation::rules::definitions::keywords::validator::KeywordsValidator; +use crate::validation::visitors::Reporter; pub struct Keywords; diff --git a/crates/codegen/schema/src/validation/rules/definitions/keywords/validator.rs b/crates/codegen/schema/src/validation/rules/definitions/keywords/validator.rs index 2760940c55..c8a42ddb2d 100644 --- a/crates/codegen/schema/src/validation/rules/definitions/keywords/validator.rs +++ b/crates/codegen/schema/src/validation/rules/definitions/keywords/validator.rs @@ -1,12 +1,8 @@ use std::collections::HashMap; -use crate::{ - types::{LanguageDefinitionRef, ProductionRef, ScannerDefinition, ScannerRef}, - validation::{ - rules::utils::is_a_keyword_scanner, - visitors::{run_visitor, LocationRef, Reporter, Visitor}, - }, -}; +use crate::types::{LanguageDefinitionRef, ProductionRef, ScannerDefinition, ScannerRef}; +use crate::validation::rules::utils::is_a_keyword_scanner; +use crate::validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}; pub struct KeywordsValidator { keywords: HashMap, diff --git a/crates/codegen/schema/src/validation/rules/definitions/mod.rs b/crates/codegen/schema/src/validation/rules/definitions/mod.rs index ccf3e709dc..7660a1c7b1 100644 --- a/crates/codegen/schema/src/validation/rules/definitions/mod.rs +++ b/crates/codegen/schema/src/validation/rules/definitions/mod.rs @@ -5,15 +5,12 @@ mod versions; use anyhow::Result; -use crate::{ - types::LanguageDefinitionRef, - validation::{ - rules::definitions::{ - keywords::Keywords, operators::Operators, productions::Productions, versions::Versions, - }, - visitors::Reporter, - }, -}; +use crate::types::LanguageDefinitionRef; +use crate::validation::rules::definitions::keywords::Keywords; +use crate::validation::rules::definitions::operators::Operators; +use crate::validation::rules::definitions::productions::Productions; +use crate::validation::rules::definitions::versions::Versions; +use crate::validation::visitors::Reporter; pub fn run(language: &LanguageDefinitionRef) -> Result<()> { let mut reporter = Reporter::new(); 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 66f784319e..bf95e5686a 100644 --- a/crates/codegen/schema/src/validation/rules/definitions/operators/mod.rs +++ b/crates/codegen/schema/src/validation/rules/definitions/operators/mod.rs @@ -1,9 +1,7 @@ use std::collections::HashMap; -use crate::{ - types::{LanguageDefinitionRef, PrecedenceParserRef, ProductionRef}, - validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}, -}; +use crate::types::{LanguageDefinitionRef, PrecedenceParserRef, ProductionRef}; +use crate::validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}; pub struct Operators { language: LanguageDefinitionRef, diff --git a/crates/codegen/schema/src/validation/rules/definitions/productions/mod.rs b/crates/codegen/schema/src/validation/rules/definitions/productions/mod.rs index 4ccdbab4ed..6d008e772a 100644 --- a/crates/codegen/schema/src/validation/rules/definitions/productions/mod.rs +++ b/crates/codegen/schema/src/validation/rules/definitions/productions/mod.rs @@ -1,9 +1,7 @@ use std::collections::HashSet; -use crate::{ - types::{LanguageDefinitionRef, ProductionRef}, - validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}, -}; +use crate::types::{LanguageDefinitionRef, ProductionRef}; +use crate::validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}; pub struct Productions { language: LanguageDefinitionRef, 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 4e59aa6401..626f95690b 100644 --- a/crates/codegen/schema/src/validation/rules/definitions/versions/mod.rs +++ b/crates/codegen/schema/src/validation/rules/definitions/versions/mod.rs @@ -1,9 +1,7 @@ use semver::Version; -use crate::{ - types::{LanguageDefinitionRef, ProductionRef}, - validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}, -}; +use crate::types::{LanguageDefinitionRef, ProductionRef}; +use crate::validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}; pub struct Versions { language: LanguageDefinitionRef, diff --git a/crates/codegen/schema/src/validation/rules/lints/children_count.rs b/crates/codegen/schema/src/validation/rules/lints/children_count.rs index 4831c3bd06..7fc919c00f 100644 --- a/crates/codegen/schema/src/validation/rules/lints/children_count.rs +++ b/crates/codegen/schema/src/validation/rules/lints/children_count.rs @@ -1,10 +1,8 @@ -use crate::{ - types::{ - LanguageDefinitionRef, ParserDefinition, ParserRef, PrecedenceParserRef, ScannerDefinition, - ScannerRef, - }, - validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}, +use crate::types::{ + LanguageDefinitionRef, ParserDefinition, ParserRef, PrecedenceParserRef, ScannerDefinition, + ScannerRef, }; +use crate::validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}; pub struct ChildrenCount; diff --git a/crates/codegen/schema/src/validation/rules/lints/consistent_shape.rs b/crates/codegen/schema/src/validation/rules/lints/consistent_shape.rs index d1fe54f9f8..2f30888f13 100644 --- a/crates/codegen/schema/src/validation/rules/lints/consistent_shape.rs +++ b/crates/codegen/schema/src/validation/rules/lints/consistent_shape.rs @@ -1,10 +1,8 @@ -use crate::{ - types::{ - LanguageDefinitionRef, ParserDefinition, ParserRef, ProductionDefinition, ProductionRef, - ScannerRef, VersionMap, - }, - validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}, +use crate::types::{ + LanguageDefinitionRef, ParserDefinition, ParserRef, ProductionDefinition, ProductionRef, + ScannerRef, VersionMap, }; +use crate::validation::visitors::{run_visitor, LocationRef, Reporter, Visitor}; pub struct ConsistentShape { language: LanguageDefinitionRef, diff --git a/crates/codegen/schema/src/validation/rules/lints/mod.rs b/crates/codegen/schema/src/validation/rules/lints/mod.rs index 915f22cf86..72c2ca1429 100644 --- a/crates/codegen/schema/src/validation/rules/lints/mod.rs +++ b/crates/codegen/schema/src/validation/rules/lints/mod.rs @@ -3,13 +3,10 @@ mod consistent_shape; use anyhow::Result; -use crate::{ - types::LanguageDefinitionRef, - validation::{ - rules::lints::{children_count::ChildrenCount, consistent_shape::ConsistentShape}, - visitors::Reporter, - }, -}; +use crate::types::LanguageDefinitionRef; +use crate::validation::rules::lints::children_count::ChildrenCount; +use crate::validation::rules::lints::consistent_shape::ConsistentShape; +use crate::validation::visitors::Reporter; pub fn run(language: &LanguageDefinitionRef) -> Result<()> { let mut reporter = Reporter::new(); diff --git a/crates/codegen/schema/src/validation/rules/references/collector.rs b/crates/codegen/schema/src/validation/rules/references/collector.rs index bba63ec40b..3b973f50f8 100644 --- a/crates/codegen/schema/src/validation/rules/references/collector.rs +++ b/crates/codegen/schema/src/validation/rules/references/collector.rs @@ -1,10 +1,6 @@ -use crate::{ - types::{LanguageDefinitionRef, ProductionRef}, - validation::{ - rules::references::metadata::Metadata, - visitors::{run_visitor, LocationRef, Reporter, VersionSet, Visitor}, - }, -}; +use crate::types::{LanguageDefinitionRef, ProductionRef}; +use crate::validation::rules::references::metadata::Metadata; +use crate::validation::visitors::{run_visitor, LocationRef, Reporter, VersionSet, Visitor}; pub struct Collector<'collector> { metadata: &'collector mut Metadata, diff --git a/crates/codegen/schema/src/validation/rules/references/metadata.rs b/crates/codegen/schema/src/validation/rules/references/metadata.rs index 8a88a57cba..7dba35ee7d 100644 --- a/crates/codegen/schema/src/validation/rules/references/metadata.rs +++ b/crates/codegen/schema/src/validation/rules/references/metadata.rs @@ -1,9 +1,7 @@ use indexmap::{IndexMap, IndexSet}; -use crate::{ - types::LanguageDefinitionRef, - validation::visitors::{LocationRef, Reporter, VersionSet}, -}; +use crate::types::LanguageDefinitionRef; +use crate::validation::visitors::{LocationRef, Reporter, VersionSet}; pub struct Entry { location: LocationRef, diff --git a/crates/codegen/schema/src/validation/rules/references/mod.rs b/crates/codegen/schema/src/validation/rules/references/mod.rs index cbce15952a..daff5c539d 100644 --- a/crates/codegen/schema/src/validation/rules/references/mod.rs +++ b/crates/codegen/schema/src/validation/rules/references/mod.rs @@ -4,13 +4,11 @@ mod validator; use anyhow::Result; -use crate::{ - types::LanguageDefinitionRef, - validation::{ - rules::references::{collector::Collector, metadata::Metadata, validator::Validator}, - visitors::Reporter, - }, -}; +use crate::types::LanguageDefinitionRef; +use crate::validation::rules::references::collector::Collector; +use crate::validation::rules::references::metadata::Metadata; +use crate::validation::rules::references::validator::Validator; +use crate::validation::visitors::Reporter; pub fn run(language: &LanguageDefinitionRef) -> Result<()> { let mut metadata = Metadata::new(); diff --git a/crates/codegen/schema/src/validation/rules/references/validator.rs b/crates/codegen/schema/src/validation/rules/references/validator.rs index d03d397e9e..96a9d7ff5b 100644 --- a/crates/codegen/schema/src/validation/rules/references/validator.rs +++ b/crates/codegen/schema/src/validation/rules/references/validator.rs @@ -1,13 +1,10 @@ -use crate::{ - types::{ - LanguageDefinitionRef, ParserDefinition, ParserRef, ProductionDefinition, ProductionRef, - ScannerDefinition, ScannerRef, - }, - validation::{ - rules::{references::metadata::Metadata, utils::is_a_keyword_scanner}, - visitors::{run_visitor, LocationRef, Reporter, VersionSet, Visitor}, - }, +use crate::types::{ + LanguageDefinitionRef, ParserDefinition, ParserRef, ProductionDefinition, ProductionRef, + ScannerDefinition, ScannerRef, }; +use crate::validation::rules::references::metadata::Metadata; +use crate::validation::rules::utils::is_a_keyword_scanner; +use crate::validation::visitors::{run_visitor, LocationRef, Reporter, VersionSet, Visitor}; pub struct Validator<'validator> { language: LanguageDefinitionRef, diff --git a/crates/codegen/schema/src/validation/visitors/location.rs b/crates/codegen/schema/src/validation/visitors/location.rs index 3ea78b0335..26a99643ea 100644 --- a/crates/codegen/schema/src/validation/visitors/location.rs +++ b/crates/codegen/schema/src/validation/visitors/location.rs @@ -1,4 +1,5 @@ -use std::{path::PathBuf, rc::Rc}; +use std::path::PathBuf; +use std::rc::Rc; pub type LocationRef = Rc; diff --git a/crates/codegen/schema/src/validation/visitors/receivers.rs b/crates/codegen/schema/src/validation/visitors/receivers.rs index d7cdef8c60..05d5d2189e 100644 --- a/crates/codegen/schema/src/validation/visitors/receivers.rs +++ b/crates/codegen/schema/src/validation/visitors/receivers.rs @@ -1,14 +1,13 @@ use std::rc::Rc; -use crate::{ - types::{ - LanguageDefinitionRef, ParserDefinition, ParserRef, PrecedenceParserRef, - ProductionDefinition, ProductionRef, ScannerDefinition, ScannerRef, VersionMap, - }, - validation::visitors::{ - location::LocationRef, reporter::Reporter, visitor::Visitor, VersionSet, - }, +use crate::types::{ + LanguageDefinitionRef, ParserDefinition, ParserRef, PrecedenceParserRef, ProductionDefinition, + ProductionRef, ScannerDefinition, ScannerRef, VersionMap, }; +use crate::validation::visitors::location::LocationRef; +use crate::validation::visitors::reporter::Reporter; +use crate::validation::visitors::visitor::Visitor; +use crate::validation::visitors::VersionSet; pub trait Receiver { fn receive( diff --git a/crates/codegen/schema/src/validation/visitors/reporter.rs b/crates/codegen/schema/src/validation/visitors/reporter.rs index 95de93e9ea..e7a59f18bd 100644 --- a/crates/codegen/schema/src/validation/visitors/reporter.rs +++ b/crates/codegen/schema/src/validation/visitors/reporter.rs @@ -1,12 +1,13 @@ -use std::{collections::HashMap, error::Error, path::PathBuf}; +use std::collections::HashMap; +use std::error::Error; +use std::path::PathBuf; use anyhow::Result; -use infra_utils::{errors::InfraErrors, paths::PathExtensions}; +use infra_utils::errors::InfraErrors; +use infra_utils::paths::PathExtensions; -use crate::{ - validation::visitors::location::{Location, LocationRef}, - yaml::{NodeRef, Parser}, -}; +use crate::validation::visitors::location::{Location, LocationRef}; +use crate::yaml::{NodeRef, Parser}; pub struct Reporter { errors: Vec<(LocationRef, String)>, diff --git a/crates/codegen/schema/src/validation/visitors/version_set.rs b/crates/codegen/schema/src/validation/visitors/version_set.rs index 81353fa7a6..7d225fc5e2 100644 --- a/crates/codegen/schema/src/validation/visitors/version_set.rs +++ b/crates/codegen/schema/src/validation/visitors/version_set.rs @@ -1,9 +1,7 @@ -use std::{ - cmp::{max, min}, - fmt::Display, - iter::once, - ops::Range, -}; +use std::cmp::{max, min}; +use std::fmt::Display; +use std::iter::once; +use std::ops::Range; use itertools::Itertools; use semver::Version; diff --git a/crates/codegen/schema/src/validation/visitors/visitor.rs b/crates/codegen/schema/src/validation/visitors/visitor.rs index d32ab714c0..ea29cd062f 100644 --- a/crates/codegen/schema/src/validation/visitors/visitor.rs +++ b/crates/codegen/schema/src/validation/visitors/visitor.rs @@ -1,15 +1,11 @@ -use crate::{ - types::{ - LanguageDefinition, LanguageDefinitionRef, LanguageTopic, ParserRef, PrecedenceParserRef, - ProductionRef, ScannerRef, - }, - validation::visitors::{ - location::{Location, LocationRef}, - receivers::Receiver, - reporter::Reporter, - VersionSet, - }, +use crate::types::{ + LanguageDefinition, LanguageDefinitionRef, LanguageTopic, ParserRef, PrecedenceParserRef, + ProductionRef, ScannerRef, }; +use crate::validation::visitors::location::{Location, LocationRef}; +use crate::validation::visitors::receivers::Receiver; +use crate::validation::visitors::reporter::Reporter; +use crate::validation::visitors::VersionSet; pub trait Visitor { fn visit_manifest(&mut self, _location: &LocationRef, _reporter: &mut Reporter) -> bool { diff --git a/crates/codegen/schema/src/yaml/parser.rs b/crates/codegen/schema/src/yaml/parser.rs index 507d613ded..41c0610153 100644 --- a/crates/codegen/schema/src/yaml/parser.rs +++ b/crates/codegen/schema/src/yaml/parser.rs @@ -1,18 +1,14 @@ -use std::{ - cmp::{max, min}, - path::PathBuf, - str::Chars, - unreachable, -}; +use std::cmp::{max, min}; +use std::path::PathBuf; +use std::str::Chars; +use std::unreachable; use anyhow::Result; use indexmap::IndexMap; use infra_utils::errors::{InfraErrors, Position}; -use yaml_rust::{ - parser::Parser as YamlParser, - scanner::{Marker, TScalarStyle}, - Event, -}; +use yaml_rust::parser::Parser as YamlParser; +use yaml_rust::scanner::{Marker, TScalarStyle}; +use yaml_rust::Event; use crate::yaml::{Node, NodeField, NodeFieldRef, NodeRef}; diff --git a/crates/codegen/schema/src/yaml/serialization.rs b/crates/codegen/schema/src/yaml/serialization.rs index d2ac206b05..7b116dfc24 100644 --- a/crates/codegen/schema/src/yaml/serialization.rs +++ b/crates/codegen/schema/src/yaml/serialization.rs @@ -1,10 +1,8 @@ use std::path::Path; use anyhow::Result; -use infra_utils::{ - codegen::CodegenReadWrite, - errors::{InfraErrors, Position}, -}; +use infra_utils::codegen::CodegenReadWrite; +use infra_utils::errors::{InfraErrors, Position}; use serde::de::DeserializeOwned; pub fn deserialize_yaml( diff --git a/crates/codegen/spec/src/grammar.rs b/crates/codegen/spec/src/grammar.rs index 04b14edba6..c9452f705b 100644 --- a/crates/codegen/spec/src/grammar.rs +++ b/crates/codegen/spec/src/grammar.rs @@ -3,7 +3,9 @@ use std::path::PathBuf; use codegen_schema::types::LanguageDefinition; use semver::Version; -use crate::{markdown::MarkdownWriter, navigation::NavigationEntry, snippets::Snippets}; +use crate::markdown::MarkdownWriter; +use crate::navigation::NavigationEntry; +use crate::snippets::Snippets; pub fn generate_supported_versions_page(language: &LanguageDefinition) -> NavigationEntry { let versions = &language.versions; diff --git a/crates/codegen/spec/src/lib.rs b/crates/codegen/spec/src/lib.rs index 3e9404d9d5..8218dbea76 100644 --- a/crates/codegen/spec/src/lib.rs +++ b/crates/codegen/spec/src/lib.rs @@ -20,12 +20,10 @@ use anyhow::Result; use codegen_schema::types::LanguageDefinitionRef; use infra_utils::codegen::Codegen; -use crate::{ - grammar::{generate_grammar_dir, generate_supported_versions_page}, - navigation::NavigationEntry, - reference::generate_reference_dir, - snippets::Snippets, -}; +use crate::grammar::{generate_grammar_dir, generate_supported_versions_page}; +use crate::navigation::NavigationEntry; +use crate::reference::generate_reference_dir; +use crate::snippets::Snippets; /// Extension trait for [`LanguageDefinitionRef`] that generates the specification files. pub trait SpecGeneratorExtensions { diff --git a/crates/codegen/spec/src/markdown.rs b/crates/codegen/spec/src/markdown.rs index dae9ac5df5..096e0dc521 100644 --- a/crates/codegen/spec/src/markdown.rs +++ b/crates/codegen/spec/src/markdown.rs @@ -1,4 +1,5 @@ -use std::{fmt::Write, path::Path}; +use std::fmt::Write; +use std::path::Path; use infra_utils::paths::PathExtensions; diff --git a/crates/codegen/spec/src/reference.rs b/crates/codegen/spec/src/reference.rs index 8d4593da8e..604c65dfd2 100644 --- a/crates/codegen/spec/src/reference.rs +++ b/crates/codegen/spec/src/reference.rs @@ -1,6 +1,7 @@ use codegen_schema::types::{LanguageDefinition, LanguageSection, LanguageTopic}; -use crate::{markdown::MarkdownWriter, navigation::NavigationEntry}; +use crate::markdown::MarkdownWriter; +use crate::navigation::NavigationEntry; pub fn generate_reference_dir(language: &LanguageDefinition) -> NavigationEntry { let mut sections = Vec::::new(); diff --git a/crates/codegen/testing/src/cst_output.rs b/crates/codegen/testing/src/cst_output.rs index d76e7e30f8..72849d557d 100644 --- a/crates/codegen/testing/src/cst_output.rs +++ b/crates/codegen/testing/src/cst_output.rs @@ -1,14 +1,10 @@ -use std::{ - collections::{BTreeMap, BTreeSet}, - path::Path, -}; +use std::collections::{BTreeMap, BTreeSet}; +use std::path::Path; use anyhow::{bail, Result}; use codegen_language_definition::model::Language; -use infra_utils::{ - codegen::{Codegen, CodegenReadWrite}, - paths::{FileWalker, PathExtensions}, -}; +use infra_utils::codegen::{Codegen, CodegenReadWrite}; +use infra_utils::paths::{FileWalker, PathExtensions}; pub fn generate_cst_output_tests( language: &Language, diff --git a/crates/infra/cli/build.rs b/crates/infra/cli/build.rs index 4b5c35f380..d2f5e9e954 100644 --- a/crates/infra/cli/build.rs +++ b/crates/infra/cli/build.rs @@ -1,7 +1,9 @@ use anyhow::Result; use clap::CommandFactory; -use clap_complete::{generate, shells::Zsh}; -use infra_utils::{cargo::CargoWorkspace, codegen::Codegen}; +use clap_complete::generate; +use clap_complete::shells::Zsh; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::codegen::Codegen; // Need this hack to import the source crate as a module: #[path = "./src/main.rs"] diff --git a/crates/infra/cli/src/commands/check/mod.rs b/crates/infra/cli/src/commands/check/mod.rs index a710ae748f..1803f2269a 100644 --- a/crates/infra/cli/src/commands/check/mod.rs +++ b/crates/infra/cli/src/commands/check/mod.rs @@ -2,13 +2,9 @@ use anyhow::Result; use clap::{Parser, ValueEnum}; use infra_utils::cargo::CargoWorkspace; -use crate::{ - toolchains::{ - mkdocs::Mkdocs, - napi::{NapiCompiler, NapiProfile}, - }, - utils::{ClapExtensions, OrderedCommand, Terminal}, -}; +use crate::toolchains::mkdocs::Mkdocs; +use crate::toolchains::napi::{NapiCompiler, NapiProfile}; +use crate::utils::{ClapExtensions, OrderedCommand, Terminal}; #[derive(Clone, Debug, Default, Parser)] pub struct CheckController { diff --git a/crates/infra/cli/src/commands/ci/mod.rs b/crates/infra/cli/src/commands/ci/mod.rs index 3635c8df47..02a7c9a1f0 100644 --- a/crates/infra/cli/src/commands/ci/mod.rs +++ b/crates/infra/cli/src/commands/ci/mod.rs @@ -1,9 +1,10 @@ use anyhow::Result; use clap::Parser; -use crate::commands::{ - check::CheckController, lint::LintController, setup::SetupController, test::TestController, -}; +use crate::commands::check::CheckController; +use crate::commands::lint::LintController; +use crate::commands::setup::SetupController; +use crate::commands::test::TestController; #[derive(Clone, Debug, Parser)] pub struct CiController; diff --git a/crates/infra/cli/src/commands/lint/mod.rs b/crates/infra/cli/src/commands/lint/mod.rs index 1d11c52395..a60e6e684b 100644 --- a/crates/infra/cli/src/commands/lint/mod.rs +++ b/crates/infra/cli/src/commands/lint/mod.rs @@ -2,12 +2,10 @@ use std::path::Path; use anyhow::Result; use clap::{Parser, ValueEnum}; -use infra_utils::{ - cargo::CargoWorkspace, - commands::Command, - github::GitHub, - paths::{FileWalker, PathExtensions}, -}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::commands::Command; +use infra_utils::github::GitHub; +use infra_utils::paths::{FileWalker, PathExtensions}; use crate::utils::{ClapExtensions, OrderedCommand, Terminal}; diff --git a/crates/infra/cli/src/commands/mod.rs b/crates/infra/cli/src/commands/mod.rs index 4c2a7be0c1..fca0092c7f 100644 --- a/crates/infra/cli/src/commands/mod.rs +++ b/crates/infra/cli/src/commands/mod.rs @@ -10,10 +10,14 @@ mod watch; use anyhow::Result; use clap::{Parser, Subcommand}; -use crate::commands::{ - check::CheckController, ci::CiController, lint::LintController, publish::PublishController, - run::RunController, setup::SetupController, test::TestController, watch::WatchController, -}; +use crate::commands::check::CheckController; +use crate::commands::ci::CiController; +use crate::commands::lint::LintController; +use crate::commands::publish::PublishController; +use crate::commands::run::RunController; +use crate::commands::setup::SetupController; +use crate::commands::test::TestController; +use crate::commands::watch::WatchController; #[derive(Debug, Parser)] pub struct CLI { diff --git a/crates/infra/cli/src/commands/publish/cargo/mod.rs b/crates/infra/cli/src/commands/publish/cargo/mod.rs index cb227670ef..2cd22044ce 100644 --- a/crates/infra/cli/src/commands/publish/cargo/mod.rs +++ b/crates/infra/cli/src/commands/publish/cargo/mod.rs @@ -1,5 +1,7 @@ use anyhow::Result; -use infra_utils::{cargo::CargoWorkspace, commands::Command, github::GitHub}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::commands::Command; +use infra_utils::github::GitHub; const USER_FACING_CRATE: &str = "slang_solidity"; diff --git a/crates/infra/cli/src/commands/publish/changesets/mod.rs b/crates/infra/cli/src/commands/publish/changesets/mod.rs index 1402a93df2..0c60bdc3f8 100644 --- a/crates/infra/cli/src/commands/publish/changesets/mod.rs +++ b/crates/infra/cli/src/commands/publish/changesets/mod.rs @@ -1,9 +1,7 @@ use anyhow::Result; -use infra_utils::{ - cargo::CargoWorkspace, - commands::Command, - paths::{FileWalker, PathExtensions}, -}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::commands::Command; +use infra_utils::paths::{FileWalker, PathExtensions}; use crate::toolchains::napi::{NapiCli, NapiConfig, NapiResolver}; diff --git a/crates/infra/cli/src/commands/publish/github_release/mod.rs b/crates/infra/cli/src/commands/publish/github_release/mod.rs index 298bf68185..8b284e84de 100644 --- a/crates/infra/cli/src/commands/publish/github_release/mod.rs +++ b/crates/infra/cli/src/commands/publish/github_release/mod.rs @@ -1,7 +1,9 @@ use std::path::Path; use anyhow::Result; -use infra_utils::{cargo::CargoWorkspace, github::GitHub, paths::PathExtensions}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::github::GitHub; +use infra_utils::paths::PathExtensions; use itertools::Itertools; use markdown::{Block, Span}; use semver::Version; diff --git a/crates/infra/cli/src/commands/publish/lock_files/mod.rs b/crates/infra/cli/src/commands/publish/lock_files/mod.rs index e925bd7329..6ca49a289e 100644 --- a/crates/infra/cli/src/commands/publish/lock_files/mod.rs +++ b/crates/infra/cli/src/commands/publish/lock_files/mod.rs @@ -1,5 +1,6 @@ use anyhow::{bail, Result}; -use infra_utils::{commands::Command, github::GitHub}; +use infra_utils::commands::Command; +use infra_utils::github::GitHub; pub fn publish_lock_files() -> Result<()> { let local_changes = Command::new("git") diff --git a/crates/infra/cli/src/commands/publish/mod.rs b/crates/infra/cli/src/commands/publish/mod.rs index e7af7a61da..2e5c13d174 100644 --- a/crates/infra/cli/src/commands/publish/mod.rs +++ b/crates/infra/cli/src/commands/publish/mod.rs @@ -7,13 +7,12 @@ mod npm; use anyhow::Result; use clap::{Parser, ValueEnum}; -use crate::{ - commands::publish::{ - cargo::publish_cargo, changesets::publish_changesets, - github_release::publish_github_release, lock_files::publish_lock_files, npm::publish_npm, - }, - utils::{ClapExtensions, Terminal}, -}; +use crate::commands::publish::cargo::publish_cargo; +use crate::commands::publish::changesets::publish_changesets; +use crate::commands::publish::github_release::publish_github_release; +use crate::commands::publish::lock_files::publish_lock_files; +use crate::commands::publish::npm::publish_npm; +use crate::utils::{ClapExtensions, Terminal}; #[derive(Clone, Debug, Parser)] pub struct PublishController { diff --git a/crates/infra/cli/src/commands/publish/npm/mod.rs b/crates/infra/cli/src/commands/publish/npm/mod.rs index 64b01dfca7..9b427bdf1e 100644 --- a/crates/infra/cli/src/commands/publish/npm/mod.rs +++ b/crates/infra/cli/src/commands/publish/npm/mod.rs @@ -1,7 +1,9 @@ use std::path::Path; use anyhow::Result; -use infra_utils::{commands::Command, github::GitHub, paths::PathExtensions}; +use infra_utils::commands::Command; +use infra_utils::github::GitHub; +use infra_utils::paths::PathExtensions; use crate::toolchains::napi::{ NapiCompiler, NapiConfig, NapiPackageKind, NapiProfile, NapiResolver, diff --git a/crates/infra/cli/src/commands/run/mod.rs b/crates/infra/cli/src/commands/run/mod.rs index 4b8291939e..bd20284c0c 100644 --- a/crates/infra/cli/src/commands/run/mod.rs +++ b/crates/infra/cli/src/commands/run/mod.rs @@ -1,6 +1,7 @@ use anyhow::Result; use clap::{Parser, ValueEnum}; -use infra_utils::{cargo::CargoWorkspace, commands::Command}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::commands::Command; use crate::utils::{ClapExtensions, Terminal}; diff --git a/crates/infra/cli/src/commands/setup/cargo/mod.rs b/crates/infra/cli/src/commands/setup/cargo/mod.rs index bddbe726f4..d1cb2f15e9 100644 --- a/crates/infra/cli/src/commands/setup/cargo/mod.rs +++ b/crates/infra/cli/src/commands/setup/cargo/mod.rs @@ -1,5 +1,6 @@ use anyhow::Result; -use infra_utils::{commands::Command, github::GitHub}; +use infra_utils::commands::Command; +use infra_utils::github::GitHub; pub fn setup_cargo() -> Result<()> { // The bootstrap bash script defined in '$REPO_ROOT/scripts/_common.sh' diff --git a/crates/infra/cli/src/commands/setup/mod.rs b/crates/infra/cli/src/commands/setup/mod.rs index 3329735867..ecf7780117 100644 --- a/crates/infra/cli/src/commands/setup/mod.rs +++ b/crates/infra/cli/src/commands/setup/mod.rs @@ -5,10 +5,10 @@ mod pipenv; use anyhow::Result; use clap::{Parser, ValueEnum}; -use crate::{ - commands::setup::{cargo::setup_cargo, npm::setup_npm, pipenv::setup_pipenv}, - utils::{ClapExtensions, OrderedCommand, Terminal}, -}; +use crate::commands::setup::cargo::setup_cargo; +use crate::commands::setup::npm::setup_npm; +use crate::commands::setup::pipenv::setup_pipenv; +use crate::utils::{ClapExtensions, OrderedCommand, Terminal}; #[derive(Clone, Debug, Default, Parser)] pub struct SetupController { diff --git a/crates/infra/cli/src/commands/setup/npm/mod.rs b/crates/infra/cli/src/commands/setup/npm/mod.rs index 2ea17f014f..3433ff3c35 100644 --- a/crates/infra/cli/src/commands/setup/npm/mod.rs +++ b/crates/infra/cli/src/commands/setup/npm/mod.rs @@ -1,5 +1,6 @@ use anyhow::Result; -use infra_utils::{commands::Command, github::GitHub}; +use infra_utils::commands::Command; +use infra_utils::github::GitHub; pub fn setup_npm() -> Result<()> { if GitHub::is_running_in_ci() { diff --git a/crates/infra/cli/src/commands/setup/pipenv/mod.rs b/crates/infra/cli/src/commands/setup/pipenv/mod.rs index e49b71f9a9..af101cc7a6 100644 --- a/crates/infra/cli/src/commands/setup/pipenv/mod.rs +++ b/crates/infra/cli/src/commands/setup/pipenv/mod.rs @@ -1,11 +1,10 @@ -use std::{collections::HashMap, path::Path}; +use std::collections::HashMap; +use std::path::Path; use anyhow::{Context, Result}; -use infra_utils::{ - commands::Command, - github::GitHub, - paths::{FileWalker, PathExtensions}, -}; +use infra_utils::commands::Command; +use infra_utils::github::GitHub; +use infra_utils::paths::{FileWalker, PathExtensions}; use serde::Deserialize; pub fn setup_pipenv() -> Result<()> { diff --git a/crates/infra/cli/src/commands/test/mod.rs b/crates/infra/cli/src/commands/test/mod.rs index fba30c423c..79d0ae69d5 100644 --- a/crates/infra/cli/src/commands/test/mod.rs +++ b/crates/infra/cli/src/commands/test/mod.rs @@ -1,6 +1,8 @@ use anyhow::Result; use clap::{Parser, ValueEnum}; -use infra_utils::{cargo::CargoWorkspace, commands::Command, github::GitHub}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::commands::Command; +use infra_utils::github::GitHub; use crate::utils::{ClapExtensions, OrderedCommand, Terminal}; diff --git a/crates/infra/cli/src/commands/watch/mod.rs b/crates/infra/cli/src/commands/watch/mod.rs index cb220472ee..f0f467e882 100644 --- a/crates/infra/cli/src/commands/watch/mod.rs +++ b/crates/infra/cli/src/commands/watch/mod.rs @@ -1,10 +1,8 @@ use anyhow::Result; use clap::{Parser, ValueEnum}; -use crate::{ - toolchains::mkdocs::Mkdocs, - utils::{ClapExtensions, OrderedCommand, Terminal}, -}; +use crate::toolchains::mkdocs::Mkdocs; +use crate::utils::{ClapExtensions, OrderedCommand, Terminal}; #[derive(Clone, Debug, Parser)] pub struct WatchController { diff --git a/crates/infra/cli/src/main.rs b/crates/infra/cli/src/main.rs index 68c1800421..ff9a21beae 100644 --- a/crates/infra/cli/src/main.rs +++ b/crates/infra/cli/src/main.rs @@ -4,7 +4,8 @@ pub mod utils; use clap::Parser; -use crate::{commands::CLI, utils::Terminal}; +use crate::commands::CLI; +use crate::utils::Terminal; #[allow(dead_code)] // as it is referenced from 'build.rs' of the same crate. fn main() { diff --git a/crates/infra/cli/src/toolchains/mkdocs/mod.rs b/crates/infra/cli/src/toolchains/mkdocs/mod.rs index a56d4e6f5d..f7b9063d6c 100644 --- a/crates/infra/cli/src/toolchains/mkdocs/mod.rs +++ b/crates/infra/cli/src/toolchains/mkdocs/mod.rs @@ -1,7 +1,8 @@ use std::path::Path; use anyhow::Result; -use infra_utils::{commands::Command, paths::PathExtensions}; +use infra_utils::commands::Command; +use infra_utils::paths::PathExtensions; pub struct Mkdocs; diff --git a/crates/infra/cli/src/toolchains/napi/cli.rs b/crates/infra/cli/src/toolchains/napi/cli.rs index 313fc7c9ac..96b5147f32 100644 --- a/crates/infra/cli/src/toolchains/napi/cli.rs +++ b/crates/infra/cli/src/toolchains/napi/cli.rs @@ -1,7 +1,8 @@ use std::path::{Path, PathBuf}; use anyhow::{bail, Context, Result}; -use infra_utils::{commands::Command, paths::PathExtensions}; +use infra_utils::commands::Command; +use infra_utils::paths::PathExtensions; use crate::toolchains::napi::resolver::NapiResolver; diff --git a/crates/infra/cli/src/toolchains/napi/compiler.rs b/crates/infra/cli/src/toolchains/napi/compiler.rs index 2a37a77dd2..87d301a59f 100644 --- a/crates/infra/cli/src/toolchains/napi/compiler.rs +++ b/crates/infra/cli/src/toolchains/napi/compiler.rs @@ -1,16 +1,15 @@ use std::path::{Path, PathBuf}; use anyhow::Result; -use infra_utils::{ - cargo::CargoWorkspace, codegen::Codegen, commands::Command, paths::PathExtensions, -}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::codegen::Codegen; +use infra_utils::commands::Command; +use infra_utils::paths::PathExtensions; use serde::Serialize; -use crate::toolchains::napi::{ - cli::{BuildTarget, NapiCli, NapiCliOutput}, - config::NapiConfig, - resolver::{NapiPackageKind, NapiResolver}, -}; +use crate::toolchains::napi::cli::{BuildTarget, NapiCli, NapiCliOutput}; +use crate::toolchains::napi::config::NapiConfig; +use crate::toolchains::napi::resolver::{NapiPackageKind, NapiResolver}; #[derive(Clone, Copy)] pub enum NapiProfile { diff --git a/crates/infra/cli/src/toolchains/napi/config.rs b/crates/infra/cli/src/toolchains/napi/config.rs index b2a9f3bd69..61daf31283 100644 --- a/crates/infra/cli/src/toolchains/napi/config.rs +++ b/crates/infra/cli/src/toolchains/napi/config.rs @@ -1,7 +1,8 @@ use std::path::Path; use anyhow::{Context, Result}; -use infra_utils::{commands::Command, paths::PathExtensions}; +use infra_utils::commands::Command; +use infra_utils::paths::PathExtensions; use semver::Version; use serde::Deserialize; diff --git a/crates/infra/cli/src/utils.rs b/crates/infra/cli/src/utils.rs index b5192eb77a..11da237105 100644 --- a/crates/infra/cli/src/utils.rs +++ b/crates/infra/cli/src/utils.rs @@ -1,9 +1,7 @@ use anyhow::{Ok, Result}; use clap::ValueEnum; -use owo_colors::{ - colors::{BrightBlue, BrightGreen, BrightRed}, - Color, OwoColorize, -}; +use owo_colors::colors::{BrightBlue, BrightGreen, BrightRed}; +use owo_colors::{Color, OwoColorize}; use terminal_size::terminal_size; pub trait OrderedCommand: Clone + Ord + PartialEq + ValueEnum { diff --git a/crates/infra/utils/src/cargo/manifest.rs b/crates/infra/utils/src/cargo/manifest.rs index 564a662d3d..1f393fcdc3 100644 --- a/crates/infra/utils/src/cargo/manifest.rs +++ b/crates/infra/utils/src/cargo/manifest.rs @@ -1,7 +1,5 @@ -use std::{ - collections::HashMap, - path::{Path, PathBuf}, -}; +use std::collections::HashMap; +use std::path::{Path, PathBuf}; use anyhow::{Context, Result}; use semver::Version; diff --git a/crates/infra/utils/src/cargo/workspace.rs b/crates/infra/utils/src/cargo/workspace.rs index 32875c4b41..8d94a52335 100644 --- a/crates/infra/utils/src/cargo/workspace.rs +++ b/crates/infra/utils/src/cargo/workspace.rs @@ -1,15 +1,14 @@ -use std::{ - env::var, - path::{Path, PathBuf}, -}; +use std::env::var; +use std::path::{Path, PathBuf}; use anyhow::{ensure, Context, Result}; use regex::Regex; use semver::Version; -use crate::{ - cargo::manifest::WorkspaceManifest, commands::Command, github::GitHub, paths::PathExtensions, -}; +use crate::cargo::manifest::WorkspaceManifest; +use crate::commands::Command; +use crate::github::GitHub; +use crate::paths::PathExtensions; pub struct CargoWorkspace; diff --git a/crates/infra/utils/src/codegen/common/file_system.rs b/crates/infra/utils/src/codegen/common/file_system.rs index b985c36cb4..cc8d020dd9 100644 --- a/crates/infra/utils/src/codegen/common/file_system.rs +++ b/crates/infra/utils/src/codegen/common/file_system.rs @@ -3,9 +3,9 @@ use std::path::Path; use anyhow::{bail, Context, Result}; use cargo_emit::warning; -use crate::{ - cargo::CargoWorkspace, codegen::common::formatting::format_source_file, paths::PathExtensions, -}; +use crate::cargo::CargoWorkspace; +use crate::codegen::common::formatting::format_source_file; +use crate::paths::PathExtensions; pub fn delete_file(file_path: &Path) -> Result<()> { std::fs::remove_file(file_path) diff --git a/crates/infra/utils/src/codegen/common/formatting.rs b/crates/infra/utils/src/codegen/common/formatting.rs index 85811a5dc2..f3d35ef0fe 100644 --- a/crates/infra/utils/src/codegen/common/formatting.rs +++ b/crates/infra/utils/src/codegen/common/formatting.rs @@ -1,12 +1,12 @@ -use std::{ - collections::hash_map::DefaultHasher, - hash::{Hash, Hasher}, - path::{Path, PathBuf}, -}; +use std::collections::hash_map::DefaultHasher; +use std::hash::{Hash, Hasher}; +use std::path::{Path, PathBuf}; use anyhow::{anyhow, Context, Result}; -use crate::{cargo::CargoWorkspace, commands::Command, paths::PathExtensions}; +use crate::cargo::CargoWorkspace; +use crate::commands::Command; +use crate::paths::PathExtensions; pub fn format_source_file(file_path: &Path, contents: &str) -> Result { let header = generate_header(file_path); diff --git a/crates/infra/utils/src/codegen/read_write.rs b/crates/infra/utils/src/codegen/read_write.rs index 2f6ecbcaf8..99b888d62f 100644 --- a/crates/infra/utils/src/codegen/read_write.rs +++ b/crates/infra/utils/src/codegen/read_write.rs @@ -6,7 +6,9 @@ use inflector::Inflector; use serde::Serialize; use tera::{Tera, Value}; -use crate::{cargo::CargoWorkspace, codegen::write_only::CodegenWriteOnly, paths::PathExtensions}; +use crate::cargo::CargoWorkspace; +use crate::codegen::write_only::CodegenWriteOnly; +use crate::paths::PathExtensions; pub struct CodegenReadWrite { writer: CodegenWriteOnly, diff --git a/crates/infra/utils/src/codegen/write_only.rs b/crates/infra/utils/src/codegen/write_only.rs index 3c6ef118cc..c8d052b2ad 100644 --- a/crates/infra/utils/src/codegen/write_only.rs +++ b/crates/infra/utils/src/codegen/write_only.rs @@ -1,17 +1,13 @@ -use std::{ - collections::HashSet, - path::{Path, PathBuf}, -}; +use std::collections::HashSet; +use std::path::{Path, PathBuf}; use anyhow::{bail, Result}; use cargo_emit::rerun_if_changed; -use crate::{ - cargo::CargoWorkspace, - codegen::common::file_system::{delete_file, verify_file, write_file}, - github::GitHub, - paths::{FileWalker, PathExtensions}, -}; +use crate::cargo::CargoWorkspace; +use crate::codegen::common::file_system::{delete_file, verify_file, write_file}; +use crate::github::GitHub; +use crate::paths::{FileWalker, PathExtensions}; pub struct CodegenWriteOnly { generated_dirs: HashSet, diff --git a/crates/infra/utils/src/commands/mod.rs b/crates/infra/utils/src/commands/mod.rs index 46a9f79929..edd0cdf47b 100644 --- a/crates/infra/utils/src/commands/mod.rs +++ b/crates/infra/utils/src/commands/mod.rs @@ -1,21 +1,17 @@ -use std::{ - collections::HashMap, - env::vars, - fmt::{Display, Formatter}, - io::Write, - os::unix::process::ExitStatusExt, - path::{Path, PathBuf}, - process::{Child, Command as StdCommand, ExitStatus, Output, Stdio}, -}; +use std::collections::HashMap; +use std::env::vars; +use std::fmt::{Display, Formatter}; +use std::io::Write; +use std::os::unix::process::ExitStatusExt; +use std::path::{Path, PathBuf}; +use std::process::{Child, Command as StdCommand, ExitStatus, Output, Stdio}; use anyhow::{bail, Context, Result}; use itertools::Itertools; use rayon::prelude::{IntoParallelIterator, ParallelIterator}; -use crate::{ - github::GitHub, - paths::{PathExtensions, PrivatePathExtensions}, -}; +use crate::github::GitHub; +use crate::paths::{PathExtensions, PrivatePathExtensions}; #[derive(Clone, Debug)] pub struct Command { diff --git a/crates/infra/utils/src/errors/mod.rs b/crates/infra/utils/src/errors/mod.rs index 2c24aeb89d..6c5a5b2517 100644 --- a/crates/infra/utils/src/errors/mod.rs +++ b/crates/infra/utils/src/errors/mod.rs @@ -1,4 +1,5 @@ -use std::{env::var, path::PathBuf}; +use std::env::var; +use std::path::PathBuf; use anyhow::{bail, Result}; use ariadne::{Color, Label, Report, ReportKind, Source}; diff --git a/crates/infra/utils/src/github/mod.rs b/crates/infra/utils/src/github/mod.rs index 070a45c2c2..9d1a324356 100644 --- a/crates/infra/utils/src/github/mod.rs +++ b/crates/infra/utils/src/github/mod.rs @@ -1,10 +1,12 @@ -use std::{env::var, path::Path}; +use std::env::var; +use std::path::Path; use anyhow::{Context, Result}; use semver::Version; use serde::Deserialize; -use crate::{commands::Command, paths::PathExtensions}; +use crate::commands::Command; +use crate::paths::PathExtensions; pub struct GitHub; diff --git a/crates/infra/utils/src/paths/extensions.rs b/crates/infra/utils/src/paths/extensions.rs index 3b550a4090..b264775a71 100644 --- a/crates/infra/utils/src/paths/extensions.rs +++ b/crates/infra/utils/src/paths/extensions.rs @@ -1,7 +1,5 @@ -use std::{ - env::var, - path::{Path, PathBuf}, -}; +use std::env::var; +use std::path::{Path, PathBuf}; use anyhow::{bail, Context, Result}; diff --git a/crates/infra/utils/src/paths/walker.rs b/crates/infra/utils/src/paths/walker.rs index 08f31ec63b..b1f6a8411d 100644 --- a/crates/infra/utils/src/paths/walker.rs +++ b/crates/infra/utils/src/paths/walker.rs @@ -1,7 +1,8 @@ use std::path::{Path, PathBuf}; use anyhow::Result; -use ignore::{overrides::OverrideBuilder, WalkBuilder}; +use ignore::overrides::OverrideBuilder; +use ignore::WalkBuilder; use crate::paths::PrivatePathExtensions; diff --git a/crates/solidity/inputs/language/build.rs b/crates/solidity/inputs/language/build.rs index 5cdd970287..1c6ea92e46 100644 --- a/crates/solidity/inputs/language/build.rs +++ b/crates/solidity/inputs/language/build.rs @@ -3,7 +3,8 @@ use std::path::Path; use anyhow::Result; use cargo_emit::{rerun_if_changed, rustc_env}; use codegen_schema::types::{LanguageDefinition, LanguageDefinitionRef}; -use infra_utils::{cargo::CargoWorkspace, paths::PathExtensions}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::paths::PathExtensions; fn main() -> Result<()> { let crate_dir = CargoWorkspace::locate_source_crate("solidity_language")?; diff --git a/crates/solidity/inputs/language/src/grammar.rs b/crates/solidity/inputs/language/src/grammar.rs index 17e9c83638..a41696fa30 100644 --- a/crates/solidity/inputs/language/src/grammar.rs +++ b/crates/solidity/inputs/language/src/grammar.rs @@ -5,22 +5,13 @@ use std::cell::OnceCell; use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::rc::Rc; -use codegen_grammar::Grammar; -use codegen_grammar::GrammarElement; -use codegen_grammar::ParserDefinition; -use codegen_grammar::ParserDefinitionNode; -use codegen_grammar::PrecedenceOperatorModel; -use codegen_grammar::PrecedenceParserDefinition; -use codegen_grammar::PrecedenceParserDefinitionNode; -use codegen_grammar::ScannerDefinition; -use codegen_grammar::ScannerDefinitionNode; -use codegen_grammar::TriviaParserDefinition; -use codegen_grammar::VersionQuality; -use codegen_grammar::VersionQualityRange; +use codegen_grammar::{ + Grammar, GrammarElement, ParserDefinition, ParserDefinitionNode, PrecedenceOperatorModel, + PrecedenceParserDefinition, PrecedenceParserDefinitionNode, ScannerDefinition, + ScannerDefinitionNode, TriviaParserDefinition, VersionQuality, VersionQualityRange, +}; use codegen_language_definition::model; -use codegen_language_definition::model::FieldsErrorRecovery; -use codegen_language_definition::model::Identifier; -use codegen_language_definition::model::Item; +use codegen_language_definition::model::{FieldsErrorRecovery, Identifier, Item}; use indexmap::IndexMap; /// Materializes the DSL v2 model ([`model::Language`]) into [`Grammar`]. diff --git a/crates/solidity/outputs/cargo/build/src/main.rs b/crates/solidity/outputs/cargo/build/src/main.rs index 28aecf7417..48d78cd672 100644 --- a/crates/solidity/outputs/cargo/build/src/main.rs +++ b/crates/solidity/outputs/cargo/build/src/main.rs @@ -2,7 +2,8 @@ use anyhow::Result; use cargo_emit::rerun_if_changed; use codegen_grammar::Grammar; use codegen_parser_generator::code_generator::CodeGenerator; -use infra_utils::{cargo::CargoWorkspace, paths::PathExtensions}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::paths::PathExtensions; use solidity_language::{GrammarConstructorDslV2, SolidityDefinition}; // Instead of the soure crate calling codegen APIs directly in the build script, it invokes this binary, which in turn diff --git a/crates/solidity/outputs/cargo/crate/build.rs b/crates/solidity/outputs/cargo/crate/build.rs index 26dcea64a9..6dd44e6956 100644 --- a/crates/solidity/outputs/cargo/crate/build.rs +++ b/crates/solidity/outputs/cargo/crate/build.rs @@ -1,4 +1,5 @@ -use std::{env::var, process::Command}; +use std::env::var; +use std::process::Command; fn main() { // Codegen does not need to run in production (when users install the crate). diff --git a/crates/solidity/outputs/cargo/crate/src/generated/cst.rs b/crates/solidity/outputs/cargo/crate/src/generated/cst.rs index a85816fc3a..da4f30be7b 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/cst.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/cst.rs @@ -4,11 +4,9 @@ use std::rc::Rc; use serde::Serialize; -use super::{ - cursor::Cursor, - kinds::{RuleKind, TokenKind}, - text_index::TextIndex, -}; +use crate::cursor::Cursor; +use crate::kinds::{RuleKind, TokenKind}; +use crate::text_index::TextIndex; #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct RuleNode { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/cursor.rs b/crates/solidity/outputs/cargo/crate/src/generated/cursor.rs index 2b64bdada7..dddbed96d8 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/cursor.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/cursor.rs @@ -4,11 +4,9 @@ use std::rc::Rc; -use super::{ - cst::{Node, RuleNode}, - kinds::{RuleKind, TokenKind}, - text_index::{TextIndex, TextRange}, -}; +use crate::cst::{Node, RuleNode}; +use crate::kinds::{RuleKind, TokenKind}; +use crate::text_index::{TextIndex, TextRange}; /// A [`PathNode`] that points to a [`RuleNode`]. #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index 9dc64aa95a..3c3daa3223 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -13,18 +13,16 @@ use napi_derive::napi; use semver::Version; -pub use super::kinds::LexicalContext; +use crate::cst; +pub use crate::kinds::LexicalContext; +use crate::kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}; +use crate::lexer::Lexer; #[cfg(feature = "slang_napi_interfaces")] -use super::napi::napi_parse_output::ParseOutput as NAPIParseOutput; -use super::{ - cst, - kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}, - lexer::Lexer, - parse_output::ParseOutput, - support::{ - ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, - PrecedenceHelper, RecoverFromNoMatch, SeparatedHelper, SequenceHelper, ZeroOrMoreHelper, - }, +use crate::napi::napi_parse_output::ParseOutput as NAPIParseOutput; +use crate::parse_output::ParseOutput; +use crate::support::{ + ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, + PrecedenceHelper, RecoverFromNoMatch, SeparatedHelper, SequenceHelper, ZeroOrMoreHelper, }; #[derive(Debug)] diff --git a/crates/solidity/outputs/cargo/crate/src/generated/lexer.rs b/crates/solidity/outputs/cargo/crate/src/generated/lexer.rs index 0457cfdc70..6f7323a4da 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/lexer.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/lexer.rs @@ -1,10 +1,8 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::{ - cst, - kinds::{IsLexicalContext, TokenKind}, - support::{ParserContext, ParserResult}, -}; +use crate::cst; +use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::support::{ParserContext, ParserResult}; pub trait Lexer { // Generated by the templating engine diff --git a/crates/solidity/outputs/cargo/crate/src/generated/napi/mod.rs b/crates/solidity/outputs/cargo/crate/src/generated/napi/mod.rs index 59f4932065..aa0748330c 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/napi/mod.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/napi/mod.rs @@ -6,13 +6,13 @@ pub mod napi_parse_error; pub mod napi_parse_output; pub mod napi_text_index; -pub type RustCursor = super::cursor::Cursor; -pub type RustNode = super::cst::Node; -pub type RustParseOutput = super::parse_output::ParseOutput; -pub type RustParseError = super::parse_error::ParseError; -pub type RustRuleNode = super::cst::RuleNode; -pub type RustTokenNode = super::cst::TokenNode; -pub type RustTextIndex = super::text_index::TextIndex; -pub type RustTextRange = super::text_index::TextRange; +pub type RustCursor = crate::cursor::Cursor; +pub type RustNode = crate::cst::Node; +pub type RustParseOutput = crate::parse_output::ParseOutput; +pub type RustParseError = crate::parse_error::ParseError; +pub type RustRuleNode = crate::cst::RuleNode; +pub type RustTokenNode = crate::cst::TokenNode; +pub type RustTextIndex = crate::text_index::TextIndex; +pub type RustTextRange = crate::text_index::TextRange; -pub use super::kinds::*; +pub use crate::kinds::*; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cst.rs b/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cst.rs index 092002b0fa..a1a848cc32 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cst.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cst.rs @@ -2,20 +2,13 @@ use std::rc::Rc; -use napi_cursor::Cursor; -use napi_text_index::TextIndex; -use { - napi::{ - bindgen_prelude::{Env, ToNapiValue}, - JsObject, NapiValue, - }, - napi_derive::napi, -}; - -use super::{ - napi_cursor, napi_text_index, RuleKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, - TokenKind, -}; +use napi::bindgen_prelude::{Env, ToNapiValue}; +use napi::{JsObject, NapiValue}; +use napi_derive::napi; + +use crate::napi::napi_cursor::Cursor; +use crate::napi::napi_text_index::TextIndex; +use crate::napi::{RuleKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, TokenKind}; #[napi(object, namespace = "cst")] pub enum NodeType { 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 232a0f5746..ae10a5f831 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 @@ -5,14 +5,13 @@ // 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; +use napi::JsObject; use napi_cst::ToJS; +use napi_derive::napi; use napi_text_index::{TextIndex, TextRange}; -use { - napi::{bindgen_prelude::Env, JsObject}, - napi_derive::napi, -}; -use super::{napi_cst, napi_text_index, RuleKind, RustCursor, TokenKind}; +use crate::napi::{napi_cst, napi_text_index, RuleKind, RustCursor, TokenKind}; #[napi(namespace = "cursor")] pub struct Cursor(Box); 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 fe9fbed569..bf6f7e7e34 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 @@ -6,7 +6,7 @@ use napi_derive::napi; use napi_text_index::TextRange; -use super::{napi_text_index, RustParseError}; +use crate::napi::{napi_text_index, RustParseError}; #[napi(namespace = "parse_error")] #[derive(PartialEq, Clone)] diff --git a/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_parse_output.rs b/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_parse_output.rs index 0838193fe4..95c3c5fadb 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_parse_output.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/napi/napi_parse_output.rs @@ -1,9 +1,10 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +use napi::bindgen_prelude::Env; use napi_cst::ToJS; -use {napi::bindgen_prelude::Env, napi_derive::napi}; +use napi_derive::napi; -use super::{napi_cst, napi_cursor, napi_parse_error, RustParseOutput}; +use crate::napi::{napi_cst, napi_cursor, napi_parse_error, RustParseOutput}; #[napi(namespace = "parse_output")] pub struct ParseOutput(RustParseOutput); 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 e95cad36f2..b88350c8ed 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 @@ -2,7 +2,7 @@ use napi_derive::napi; -use super::{RustTextIndex, RustTextRange}; +use crate::napi::{RustTextIndex, RustTextRange}; #[napi(object, namespace = "text_index")] #[derive(Copy, Clone)] 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 7a7282b328..18f49a82e2 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/parse_error.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/parse_error.rs @@ -2,10 +2,8 @@ use std::collections::BTreeSet; -use super::{ - kinds::TokenKind, - text_index::{TextIndex, TextRange}, -}; +use crate::kinds::TokenKind; +use crate::text_index::{TextIndex, TextRange}; #[derive(Debug, PartialEq, Eq, Clone)] pub struct ParseError { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/parse_output.rs b/crates/solidity/outputs/cargo/crate/src/generated/parse_output.rs index e4cdde6a6a..7989309d0c 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/parse_output.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/parse_output.rs @@ -1,6 +1,9 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::{cst, cursor::Cursor, parse_error::ParseError, text_index::TextIndex}; +use crate::cst; +use crate::cursor::Cursor; +use crate::parse_error::ParseError; +use crate::text_index::TextIndex; #[derive(Debug, PartialEq)] pub struct ParseOutput { 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 fb00b71bf0..9a119fe83e 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 @@ -3,8 +3,12 @@ use std::mem; use std::ops::ControlFlow; -use super::{context::Marker, ParserContext, ParserResult}; -use crate::{cst, kinds::TokenKind, parse_error::ParseError, text_index::TextIndex}; +use crate::cst; +use crate::kinds::TokenKind; +use crate::parse_error::ParseError; +use crate::support::context::{Marker, ParserContext}; +use crate::support::ParserResult; +use crate::text_index::TextIndex; /// Starting from a given position in the input, this helper will try to pick (and remember) a best match. Settles on /// a first full match if possible, otherwise on the best incomplete match. 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 779f73e767..aa7cd687f7 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/context.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/context.rs @@ -3,9 +3,9 @@ use std::mem; use std::ops::Range; -use super::super::text_index::TextIndex; use crate::kinds::TokenKind; use crate::parse_error::ParseError; +use crate::text_index::TextIndex; pub struct ParserContext<'s> { source: &'s str, diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/optional_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/optional_helper.rs index e7a723ae6c..66649e0ac5 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/optional_helper.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/optional_helper.rs @@ -1,6 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use super::parser_result::ParserResult; +use crate::support::parser_result::ParserResult; pub struct OptionalHelper; 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 08b1f69d8f..852e625579 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 @@ -2,14 +2,13 @@ use std::rc::Rc; -use super::{ - super::{ - cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput, - text_index::TextIndex, - }, - context::ParserContext, - parser_result::{IncompleteMatch, Match, ParserResult, SkippedUntil}, -}; +use crate::cst; +use crate::kinds::TokenKind; +use crate::parse_error::ParseError; +use crate::parse_output::ParseOutput; +use crate::support::context::ParserContext; +use crate::support::parser_result::{IncompleteMatch, Match, ParserResult, SkippedUntil}; +use crate::text_index::TextIndex; pub trait ParserFunction where 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 49e7f51785..9859daa1de 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 @@ -1,10 +1,8 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use super::super::{ - cst, - kinds::{RuleKind, TokenKind}, - text_index::TextIndex, -}; +use crate::cst; +use crate::kinds::{RuleKind, TokenKind}; +use crate::text_index::TextIndex; #[derive(PartialEq, Eq, Clone, Debug)] pub enum ParserResult { 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 4da2c25f10..b4f2f8281c 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 @@ -1,12 +1,9 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use super::{ - super::{cst, kinds::RuleKind}, - parser_result::{ - ParserResult, - PrattElement::{self, Binary, Expression, Postfix, Prefix}, - }, -}; +use crate::cst; +use crate::kinds::RuleKind; +use crate::support::parser_result::ParserResult; +use crate::support::parser_result::PrattElement::{self, Binary, Expression, Postfix, Prefix}; pub struct PrecedenceHelper; 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 11b39556a3..d220c27f87 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/recovery.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/recovery.rs @@ -1,11 +1,11 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use super::parser_result::SkippedUntil; -use super::ParserContext; use crate::cst; use crate::kinds::{IsLexicalContext, TokenKind}; use crate::lexer::Lexer; use crate::parse_error::ParseError; +use crate::support::context::ParserContext; +use crate::support::parser_result::SkippedUntil; use crate::support::ParserResult; use crate::text_index::{TextRange, TextRangeExtensions as _}; 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 a60b04bb80..07a7a666a9 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 @@ -1,9 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use super::{ - context::ParserContext, - parser_result::{IncompleteMatch, NoMatch, ParserResult}, -}; +use crate::support::context::ParserContext; +use crate::support::parser_result::{IncompleteMatch, NoMatch, ParserResult}; pub struct RepetitionHelper; 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 5e5efa5f0a..23c2cfeba3 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 @@ -1,17 +1,13 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::{ - cst, - kinds::{IsLexicalContext, TokenKind}, - lexer::Lexer, - parse_error::ParseError, - support::{ - parser_result::{ParserResult, SkippedUntil}, - recovery::skip_until_with_nested_delims, - ParserContext, - }, - text_index::TextRangeExtensions, -}; +use crate::cst; +use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::lexer::Lexer; +use crate::parse_error::ParseError; +use crate::support::parser_result::{ParserResult, SkippedUntil}; +use crate::support::recovery::skip_until_with_nested_delims; +use crate::support::ParserContext; +use crate::text_index::TextRangeExtensions; pub struct SeparatedHelper; 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 5a0183692c..66b336ac03 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 @@ -2,8 +2,9 @@ use std::ops::ControlFlow; -use super::parser_result::{Match, ParserResult, PrattElement, SkippedUntil}; -use crate::{cst, kinds::TokenKind}; +use crate::cst; +use crate::kinds::TokenKind; +use crate::support::parser_result::{Match, ParserResult, PrattElement, SkippedUntil}; /// Keeps accumulating parses sequentially until it hits an incomplete or no match. #[must_use] diff --git a/crates/solidity/outputs/cargo/crate/src/generated/text_index.rs b/crates/solidity/outputs/cargo/crate/src/generated/text_index.rs index 839a104ac2..78e839cc57 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/text_index.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/text_index.rs @@ -1,9 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use std::{ - fmt::Display, - ops::{Add, AddAssign, Range, Sub, SubAssign}, -}; +use std::fmt::Display; +use std::ops::{Add, AddAssign, Range, Sub, SubAssign}; use serde::Serialize; diff --git a/crates/solidity/outputs/cargo/crate/src/lib.rs b/crates/solidity/outputs/cargo/crate/src/lib.rs index 3a7821cb6a..864b9cc405 100644 --- a/crates/solidity/outputs/cargo/crate/src/lib.rs +++ b/crates/solidity/outputs/cargo/crate/src/lib.rs @@ -7,7 +7,5 @@ pub use generated::*; // https://github.com/rust-lang/cargo/issues/1982 #[cfg(feature = "cli")] mod supress_cli_dependencies { - use anyhow as _; - use clap as _; - use serde_json as _; + use {anyhow as _, clap as _, serde_json as _}; } diff --git a/crates/solidity/outputs/cargo/crate/src/main.rs b/crates/solidity/outputs/cargo/crate/src/main.rs index 1b6f94a5c7..6b3097f084 100644 --- a/crates/solidity/outputs/cargo/crate/src/main.rs +++ b/crates/solidity/outputs/cargo/crate/src/main.rs @@ -1,20 +1,19 @@ -use std::{fs, path::PathBuf, process::ExitCode}; +use std::fs; +use std::path::PathBuf; +use std::process::ExitCode; use anyhow::{Context, Result}; use clap::{Parser as ClapParser, Subcommand}; use semver::Version; -use slang_solidity::{kinds::RuleKind, language::Language}; +use slang_solidity::kinds::RuleKind; +use slang_solidity::language::Language; // Below are dependencies used by the API `lib.rs`, but not the CLI "main.rs". // However, we need to add a fake usage to suppress Cargo warnings about unused dependencies. // This is a known issue, and we should remove this hack once there is a better solution from Cargo. // https://github.com/rust-lang/cargo/issues/1982 mod supress_api_dependencies { - use ariadne as _; - use serde as _; - use strum as _; - use strum_macros as _; - use thiserror as _; + use {ariadne as _, serde as _, strum as _, strum_macros as _, thiserror as _}; } #[derive(ClapParser, Debug)] diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs index dc1c2ed6d2..61eba7de39 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs @@ -1,8 +1,11 @@ use std::str::FromStr; use anyhow::Result; -use infra_utils::{cargo::CargoWorkspace, codegen::Codegen, paths::PathExtensions}; -use slang_solidity::{kinds::RuleKind, language::Language}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::codegen::Codegen; +use infra_utils::paths::PathExtensions; +use slang_solidity::kinds::RuleKind; +use slang_solidity::language::Language; use solidity_testing_utils::cst_snapshots::CstSnapshots; use strum_macros::Display; diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs index 4937c037cf..650fc3d6a9 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs @@ -1,9 +1,7 @@ use anyhow::Result; use semver::Version; -use slang_solidity::{ - kinds::{RuleKind, TokenKind}, - language::Language, -}; +use slang_solidity::kinds::{RuleKind, TokenKind}; +use slang_solidity::language::Language; const SOURCE: &str = " contract Foo {} diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs index 6a64416caf..5ced12092e 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs @@ -1,10 +1,8 @@ use anyhow::Result; use semver::Version; -use slang_solidity::{ - cst::Node, - kinds::{RuleKind, TokenKind}, - language::Language, -}; +use slang_solidity::cst::Node; +use slang_solidity::kinds::{RuleKind, TokenKind}; +use slang_solidity::language::Language; #[test] fn simple_contract() -> Result<()> { diff --git a/crates/solidity/outputs/cargo/tests/src/scanner/mod.rs b/crates/solidity/outputs/cargo/tests/src/scanner/mod.rs index 632b1977d4..6793286473 100644 --- a/crates/solidity/outputs/cargo/tests/src/scanner/mod.rs +++ b/crates/solidity/outputs/cargo/tests/src/scanner/mod.rs @@ -1,8 +1,6 @@ use semver::Version; -use slang_solidity::{ - kinds::TokenKind::*, - language::{Language, LexicalContext}, -}; +use slang_solidity::kinds::TokenKind::*; +use slang_solidity::language::{Language, LexicalContext}; #[test] fn test_next_token() { diff --git a/crates/solidity/outputs/npm/build/src/main.rs b/crates/solidity/outputs/npm/build/src/main.rs index 61979ba38c..470a4d1df0 100644 --- a/crates/solidity/outputs/npm/build/src/main.rs +++ b/crates/solidity/outputs/npm/build/src/main.rs @@ -2,7 +2,8 @@ use anyhow::Result; use cargo_emit::rerun_if_changed; use codegen_grammar::Grammar; use codegen_parser_generator::code_generator::CodeGenerator; -use infra_utils::{cargo::CargoWorkspace, paths::PathExtensions}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::paths::PathExtensions; use solidity_language::{GrammarConstructorDslV2, SolidityDefinition}; // Instead of the soure crate calling codegen APIs directly in the build script, it invokes this binary, which in turn diff --git a/crates/solidity/outputs/npm/crate/build.rs b/crates/solidity/outputs/npm/crate/build.rs index 872a7ba0a0..7378e099ca 100644 --- a/crates/solidity/outputs/npm/crate/build.rs +++ b/crates/solidity/outputs/npm/crate/build.rs @@ -1,4 +1,5 @@ -use std::{env::var, process::Command}; +use std::env::var; +use std::process::Command; fn main() { // Codegen does not need to run during 'napi build' (when cross-compiling). diff --git a/crates/solidity/outputs/npm/crate/src/generated/cst.rs b/crates/solidity/outputs/npm/crate/src/generated/cst.rs index a85816fc3a..da4f30be7b 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/cst.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/cst.rs @@ -4,11 +4,9 @@ use std::rc::Rc; use serde::Serialize; -use super::{ - cursor::Cursor, - kinds::{RuleKind, TokenKind}, - text_index::TextIndex, -}; +use crate::cursor::Cursor; +use crate::kinds::{RuleKind, TokenKind}; +use crate::text_index::TextIndex; #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct RuleNode { diff --git a/crates/solidity/outputs/npm/crate/src/generated/cursor.rs b/crates/solidity/outputs/npm/crate/src/generated/cursor.rs index 2b64bdada7..dddbed96d8 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/cursor.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/cursor.rs @@ -4,11 +4,9 @@ use std::rc::Rc; -use super::{ - cst::{Node, RuleNode}, - kinds::{RuleKind, TokenKind}, - text_index::{TextIndex, TextRange}, -}; +use crate::cst::{Node, RuleNode}; +use crate::kinds::{RuleKind, TokenKind}; +use crate::text_index::{TextIndex, TextRange}; /// A [`PathNode`] that points to a [`RuleNode`]. #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index 9dc64aa95a..3c3daa3223 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -13,18 +13,16 @@ use napi_derive::napi; use semver::Version; -pub use super::kinds::LexicalContext; +use crate::cst; +pub use crate::kinds::LexicalContext; +use crate::kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}; +use crate::lexer::Lexer; #[cfg(feature = "slang_napi_interfaces")] -use super::napi::napi_parse_output::ParseOutput as NAPIParseOutput; -use super::{ - cst, - kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}, - lexer::Lexer, - parse_output::ParseOutput, - support::{ - ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, - PrecedenceHelper, RecoverFromNoMatch, SeparatedHelper, SequenceHelper, ZeroOrMoreHelper, - }, +use crate::napi::napi_parse_output::ParseOutput as NAPIParseOutput; +use crate::parse_output::ParseOutput; +use crate::support::{ + ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, + PrecedenceHelper, RecoverFromNoMatch, SeparatedHelper, SequenceHelper, ZeroOrMoreHelper, }; #[derive(Debug)] diff --git a/crates/solidity/outputs/npm/crate/src/generated/lexer.rs b/crates/solidity/outputs/npm/crate/src/generated/lexer.rs index 0457cfdc70..6f7323a4da 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/lexer.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/lexer.rs @@ -1,10 +1,8 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::{ - cst, - kinds::{IsLexicalContext, TokenKind}, - support::{ParserContext, ParserResult}, -}; +use crate::cst; +use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::support::{ParserContext, ParserResult}; pub trait Lexer { // Generated by the templating engine diff --git a/crates/solidity/outputs/npm/crate/src/generated/napi/mod.rs b/crates/solidity/outputs/npm/crate/src/generated/napi/mod.rs index 59f4932065..aa0748330c 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/napi/mod.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/napi/mod.rs @@ -6,13 +6,13 @@ pub mod napi_parse_error; pub mod napi_parse_output; pub mod napi_text_index; -pub type RustCursor = super::cursor::Cursor; -pub type RustNode = super::cst::Node; -pub type RustParseOutput = super::parse_output::ParseOutput; -pub type RustParseError = super::parse_error::ParseError; -pub type RustRuleNode = super::cst::RuleNode; -pub type RustTokenNode = super::cst::TokenNode; -pub type RustTextIndex = super::text_index::TextIndex; -pub type RustTextRange = super::text_index::TextRange; +pub type RustCursor = crate::cursor::Cursor; +pub type RustNode = crate::cst::Node; +pub type RustParseOutput = crate::parse_output::ParseOutput; +pub type RustParseError = crate::parse_error::ParseError; +pub type RustRuleNode = crate::cst::RuleNode; +pub type RustTokenNode = crate::cst::TokenNode; +pub type RustTextIndex = crate::text_index::TextIndex; +pub type RustTextRange = crate::text_index::TextRange; -pub use super::kinds::*; +pub use crate::kinds::*; diff --git a/crates/solidity/outputs/npm/crate/src/generated/napi/napi_cst.rs b/crates/solidity/outputs/npm/crate/src/generated/napi/napi_cst.rs index 092002b0fa..a1a848cc32 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/napi/napi_cst.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/napi/napi_cst.rs @@ -2,20 +2,13 @@ use std::rc::Rc; -use napi_cursor::Cursor; -use napi_text_index::TextIndex; -use { - napi::{ - bindgen_prelude::{Env, ToNapiValue}, - JsObject, NapiValue, - }, - napi_derive::napi, -}; - -use super::{ - napi_cursor, napi_text_index, RuleKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, - TokenKind, -}; +use napi::bindgen_prelude::{Env, ToNapiValue}; +use napi::{JsObject, NapiValue}; +use napi_derive::napi; + +use crate::napi::napi_cursor::Cursor; +use crate::napi::napi_text_index::TextIndex; +use crate::napi::{RuleKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode, TokenKind}; #[napi(object, namespace = "cst")] pub enum NodeType { 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 232a0f5746..ae10a5f831 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 @@ -5,14 +5,13 @@ // 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; +use napi::JsObject; use napi_cst::ToJS; +use napi_derive::napi; use napi_text_index::{TextIndex, TextRange}; -use { - napi::{bindgen_prelude::Env, JsObject}, - napi_derive::napi, -}; -use super::{napi_cst, napi_text_index, RuleKind, RustCursor, TokenKind}; +use crate::napi::{napi_cst, napi_text_index, RuleKind, RustCursor, TokenKind}; #[napi(namespace = "cursor")] pub struct Cursor(Box); 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 fe9fbed569..bf6f7e7e34 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 @@ -6,7 +6,7 @@ use napi_derive::napi; use napi_text_index::TextRange; -use super::{napi_text_index, RustParseError}; +use crate::napi::{napi_text_index, RustParseError}; #[napi(namespace = "parse_error")] #[derive(PartialEq, Clone)] diff --git a/crates/solidity/outputs/npm/crate/src/generated/napi/napi_parse_output.rs b/crates/solidity/outputs/npm/crate/src/generated/napi/napi_parse_output.rs index 0838193fe4..95c3c5fadb 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/napi/napi_parse_output.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/napi/napi_parse_output.rs @@ -1,9 +1,10 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +use napi::bindgen_prelude::Env; use napi_cst::ToJS; -use {napi::bindgen_prelude::Env, napi_derive::napi}; +use napi_derive::napi; -use super::{napi_cst, napi_cursor, napi_parse_error, RustParseOutput}; +use crate::napi::{napi_cst, napi_cursor, napi_parse_error, RustParseOutput}; #[napi(namespace = "parse_output")] pub struct ParseOutput(RustParseOutput); 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 e95cad36f2..b88350c8ed 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 @@ -2,7 +2,7 @@ use napi_derive::napi; -use super::{RustTextIndex, RustTextRange}; +use crate::napi::{RustTextIndex, RustTextRange}; #[napi(object, namespace = "text_index")] #[derive(Copy, Clone)] 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 7a7282b328..18f49a82e2 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/parse_error.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/parse_error.rs @@ -2,10 +2,8 @@ use std::collections::BTreeSet; -use super::{ - kinds::TokenKind, - text_index::{TextIndex, TextRange}, -}; +use crate::kinds::TokenKind; +use crate::text_index::{TextIndex, TextRange}; #[derive(Debug, PartialEq, Eq, Clone)] pub struct ParseError { diff --git a/crates/solidity/outputs/npm/crate/src/generated/parse_output.rs b/crates/solidity/outputs/npm/crate/src/generated/parse_output.rs index e4cdde6a6a..7989309d0c 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/parse_output.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/parse_output.rs @@ -1,6 +1,9 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::{cst, cursor::Cursor, parse_error::ParseError, text_index::TextIndex}; +use crate::cst; +use crate::cursor::Cursor; +use crate::parse_error::ParseError; +use crate::text_index::TextIndex; #[derive(Debug, PartialEq)] pub struct ParseOutput { 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 fb00b71bf0..9a119fe83e 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 @@ -3,8 +3,12 @@ use std::mem; use std::ops::ControlFlow; -use super::{context::Marker, ParserContext, ParserResult}; -use crate::{cst, kinds::TokenKind, parse_error::ParseError, text_index::TextIndex}; +use crate::cst; +use crate::kinds::TokenKind; +use crate::parse_error::ParseError; +use crate::support::context::{Marker, ParserContext}; +use crate::support::ParserResult; +use crate::text_index::TextIndex; /// Starting from a given position in the input, this helper will try to pick (and remember) a best match. Settles on /// a first full match if possible, otherwise on the best incomplete match. 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 779f73e767..aa7cd687f7 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/context.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/context.rs @@ -3,9 +3,9 @@ use std::mem; use std::ops::Range; -use super::super::text_index::TextIndex; use crate::kinds::TokenKind; use crate::parse_error::ParseError; +use crate::text_index::TextIndex; pub struct ParserContext<'s> { source: &'s str, diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/optional_helper.rs b/crates/solidity/outputs/npm/crate/src/generated/support/optional_helper.rs index e7a723ae6c..66649e0ac5 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/optional_helper.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/optional_helper.rs @@ -1,6 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use super::parser_result::ParserResult; +use crate::support::parser_result::ParserResult; pub struct OptionalHelper; 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 08b1f69d8f..852e625579 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 @@ -2,14 +2,13 @@ use std::rc::Rc; -use super::{ - super::{ - cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput, - text_index::TextIndex, - }, - context::ParserContext, - parser_result::{IncompleteMatch, Match, ParserResult, SkippedUntil}, -}; +use crate::cst; +use crate::kinds::TokenKind; +use crate::parse_error::ParseError; +use crate::parse_output::ParseOutput; +use crate::support::context::ParserContext; +use crate::support::parser_result::{IncompleteMatch, Match, ParserResult, SkippedUntil}; +use crate::text_index::TextIndex; pub trait ParserFunction where 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 49e7f51785..9859daa1de 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 @@ -1,10 +1,8 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use super::super::{ - cst, - kinds::{RuleKind, TokenKind}, - text_index::TextIndex, -}; +use crate::cst; +use crate::kinds::{RuleKind, TokenKind}; +use crate::text_index::TextIndex; #[derive(PartialEq, Eq, Clone, Debug)] pub enum ParserResult { 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 4da2c25f10..b4f2f8281c 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 @@ -1,12 +1,9 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use super::{ - super::{cst, kinds::RuleKind}, - parser_result::{ - ParserResult, - PrattElement::{self, Binary, Expression, Postfix, Prefix}, - }, -}; +use crate::cst; +use crate::kinds::RuleKind; +use crate::support::parser_result::ParserResult; +use crate::support::parser_result::PrattElement::{self, Binary, Expression, Postfix, Prefix}; pub struct PrecedenceHelper; 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 11b39556a3..d220c27f87 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/recovery.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/recovery.rs @@ -1,11 +1,11 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use super::parser_result::SkippedUntil; -use super::ParserContext; use crate::cst; use crate::kinds::{IsLexicalContext, TokenKind}; use crate::lexer::Lexer; use crate::parse_error::ParseError; +use crate::support::context::ParserContext; +use crate::support::parser_result::SkippedUntil; use crate::support::ParserResult; use crate::text_index::{TextRange, TextRangeExtensions as _}; 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 a60b04bb80..07a7a666a9 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 @@ -1,9 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use super::{ - context::ParserContext, - parser_result::{IncompleteMatch, NoMatch, ParserResult}, -}; +use crate::support::context::ParserContext; +use crate::support::parser_result::{IncompleteMatch, NoMatch, ParserResult}; pub struct RepetitionHelper; 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 5e5efa5f0a..23c2cfeba3 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 @@ -1,17 +1,13 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::{ - cst, - kinds::{IsLexicalContext, TokenKind}, - lexer::Lexer, - parse_error::ParseError, - support::{ - parser_result::{ParserResult, SkippedUntil}, - recovery::skip_until_with_nested_delims, - ParserContext, - }, - text_index::TextRangeExtensions, -}; +use crate::cst; +use crate::kinds::{IsLexicalContext, TokenKind}; +use crate::lexer::Lexer; +use crate::parse_error::ParseError; +use crate::support::parser_result::{ParserResult, SkippedUntil}; +use crate::support::recovery::skip_until_with_nested_delims; +use crate::support::ParserContext; +use crate::text_index::TextRangeExtensions; pub struct SeparatedHelper; 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 5a0183692c..66b336ac03 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 @@ -2,8 +2,9 @@ use std::ops::ControlFlow; -use super::parser_result::{Match, ParserResult, PrattElement, SkippedUntil}; -use crate::{cst, kinds::TokenKind}; +use crate::cst; +use crate::kinds::TokenKind; +use crate::support::parser_result::{Match, ParserResult, PrattElement, SkippedUntil}; /// Keeps accumulating parses sequentially until it hits an incomplete or no match. #[must_use] diff --git a/crates/solidity/outputs/npm/crate/src/generated/text_index.rs b/crates/solidity/outputs/npm/crate/src/generated/text_index.rs index 839a104ac2..78e839cc57 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/text_index.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/text_index.rs @@ -1,9 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use std::{ - fmt::Display, - ops::{Add, AddAssign, Range, Sub, SubAssign}, -}; +use std::fmt::Display; +use std::ops::{Add, AddAssign, Range, Sub, SubAssign}; use serde::Serialize; diff --git a/crates/solidity/testing/sanctuary/src/datasets/git.rs b/crates/solidity/testing/sanctuary/src/datasets/git.rs index e83c9ddf69..abf263809b 100644 --- a/crates/solidity/testing/sanctuary/src/datasets/git.rs +++ b/crates/solidity/testing/sanctuary/src/datasets/git.rs @@ -1,14 +1,10 @@ -use std::{ - path::{Path, PathBuf}, - time::{Duration, SystemTime}, -}; +use std::path::{Path, PathBuf}; +use std::time::{Duration, SystemTime}; use anyhow::Result; -use infra_utils::{ - cargo::CargoWorkspace, - commands::Command, - paths::{FileWalker, PathExtensions}, -}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::commands::Command; +use infra_utils::paths::{FileWalker, PathExtensions}; use url::Url; use crate::datasets::Dataset; diff --git a/crates/solidity/testing/sanctuary/src/main.rs b/crates/solidity/testing/sanctuary/src/main.rs index c190e089ee..d84db5f194 100644 --- a/crates/solidity/testing/sanctuary/src/main.rs +++ b/crates/solidity/testing/sanctuary/src/main.rs @@ -1,20 +1,22 @@ mod datasets; mod reporting; -use std::{collections::BTreeSet, ops::ControlFlow, path::Path, process::ExitCode}; +use std::collections::BTreeSet; +use std::ops::ControlFlow; +use std::path::Path; +use std::process::ExitCode; use anyhow::Result; use infra_utils::paths::PathExtensions; use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; use semver::Version; -use slang_solidity::{kinds::RuleKind, language::Language}; +use slang_solidity::kinds::RuleKind; +use slang_solidity::language::Language; use solidity_language::SolidityDefinition; use solidity_testing_utils::version_pragmas::extract_version_pragmas; -use crate::{ - datasets::{get_all_datasets, Dataset}, - reporting::Reporter, -}; +use crate::datasets::{get_all_datasets, Dataset}; +use crate::reporting::Reporter; fn main() -> Result { let versions = SolidityDefinition::create().collect_breaking_versions(); diff --git a/crates/solidity/testing/sanctuary/src/reporting.rs b/crates/solidity/testing/sanctuary/src/reporting.rs index 15921f9d14..10e6255d0e 100644 --- a/crates/solidity/testing/sanctuary/src/reporting.rs +++ b/crates/solidity/testing/sanctuary/src/reporting.rs @@ -1,7 +1,5 @@ -use std::{ - sync::atomic::{AtomicUsize, Ordering}, - time::Duration, -}; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::time::Duration; use anyhow::Result; use indicatif::ProgressBar; diff --git a/crates/solidity/testing/solc/src/utils/binaries.rs b/crates/solidity/testing/solc/src/utils/binaries.rs index 81567bf81a..6d216025a0 100644 --- a/crates/solidity/testing/solc/src/utils/binaries.rs +++ b/crates/solidity/testing/solc/src/utils/binaries.rs @@ -1,12 +1,14 @@ -use std::{ - collections::HashMap, os::unix::prelude::PermissionsExt, path::Path, path::PathBuf, - time::Duration, -}; +use std::collections::HashMap; +use std::os::unix::prelude::PermissionsExt; +use std::path::{Path, PathBuf}; +use std::time::Duration; use anyhow::Result; use codegen_language_definition::model::Language; use indicatif::{ProgressBar, ProgressStyle}; -use infra_utils::{cargo::CargoWorkspace, commands::Command, paths::PathExtensions}; +use infra_utils::cargo::CargoWorkspace; +use infra_utils::commands::Command; +use infra_utils::paths::PathExtensions; use rayon::prelude::{ParallelBridge, ParallelIterator}; use semver::Version; use serde::Deserialize; diff --git a/crates/solidity/testing/utils/src/cst_snapshots/mod.rs b/crates/solidity/testing/utils/src/cst_snapshots/mod.rs index 49ce0fc50b..dfe8bc0ceb 100644 --- a/crates/solidity/testing/utils/src/cst_snapshots/mod.rs +++ b/crates/solidity/testing/utils/src/cst_snapshots/mod.rs @@ -1,12 +1,11 @@ -use std::{cmp::max, fmt::Write}; +use std::cmp::max; +use std::fmt::Write; use anyhow::Result; -use slang_solidity::{ - cst, - cursor::Cursor, - kinds::TokenKind, - text_index::{TextRange, TextRangeExtensions}, -}; +use slang_solidity::cst; +use slang_solidity::cursor::Cursor; +use slang_solidity::kinds::TokenKind; +use slang_solidity::text_index::{TextRange, TextRangeExtensions}; use crate::node_extensions::NodeExtensions; diff --git a/crates/solidity/testing/utils/src/node_extensions/mod.rs b/crates/solidity/testing/utils/src/node_extensions/mod.rs index 1379803660..49ef71869d 100644 --- a/crates/solidity/testing/utils/src/node_extensions/mod.rs +++ b/crates/solidity/testing/utils/src/node_extensions/mod.rs @@ -1,10 +1,8 @@ #[cfg(test)] mod tests; -use slang_solidity::{ - cst::{Node, RuleNode, TokenNode}, - kinds::RuleKind, -}; +use slang_solidity::cst::{Node, RuleNode, TokenNode}; +use slang_solidity::kinds::RuleKind; pub trait NodeExtensions { fn is_trivia(&self) -> bool; diff --git a/crates/solidity/testing/utils/src/node_extensions/tests.rs b/crates/solidity/testing/utils/src/node_extensions/tests.rs index c4dc6072f2..0141f990ff 100644 --- a/crates/solidity/testing/utils/src/node_extensions/tests.rs +++ b/crates/solidity/testing/utils/src/node_extensions/tests.rs @@ -1,6 +1,7 @@ use anyhow::Result; use semver::Version; -use slang_solidity::{kinds::RuleKind, language::Language}; +use slang_solidity::kinds::RuleKind; +use slang_solidity::language::Language; use crate::node_extensions::NodeExtensions; diff --git a/crates/solidity/testing/utils/src/version_pragmas/mod.rs b/crates/solidity/testing/utils/src/version_pragmas/mod.rs index f37e619c99..548f57f543 100644 --- a/crates/solidity/testing/utils/src/version_pragmas/mod.rs +++ b/crates/solidity/testing/utils/src/version_pragmas/mod.rs @@ -5,7 +5,9 @@ use std::str::FromStr; use anyhow::{bail, ensure, Context, Result}; use semver::{Comparator, Op, Version}; -use slang_solidity::{cst::Node, kinds::RuleKind, language::Language}; +use slang_solidity::cst::Node; +use slang_solidity::kinds::RuleKind; +use slang_solidity::language::Language; use crate::node_extensions::NodeExtensions;