From 6e68c9398b35a95a8f3ba39cf0267126aed5486d Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Fri, 25 Oct 2024 21:23:28 +0000 Subject: [PATCH] style(ast_tools): reorder imports (#6904) Pure refactor. Re-order imports for clarity. --- tasks/ast_tools/src/derives/clone_in.rs | 3 ++- tasks/ast_tools/src/derives/content_eq.rs | 3 ++- tasks/ast_tools/src/derives/content_hash.rs | 3 ++- tasks/ast_tools/src/derives/estree.rs | 3 ++- tasks/ast_tools/src/derives/get_span.rs | 3 ++- tasks/ast_tools/src/generators/assert_layouts.rs | 3 ++- tasks/ast_tools/src/generators/ast_builder.rs | 3 ++- tasks/ast_tools/src/generators/ast_kind.rs | 3 ++- tasks/ast_tools/src/generators/typescript.rs | 3 ++- tasks/ast_tools/src/generators/visit.rs | 3 ++- tasks/ast_tools/src/main.rs | 1 + tasks/ast_tools/src/passes/calc_layout.rs | 3 ++- tasks/ast_tools/src/passes/linker.rs | 3 ++- tasks/ast_tools/src/rust_ast.rs | 3 ++- tasks/ast_tools/src/schema/defs.rs | 3 ++- tasks/ast_tools/src/schema/get_ident.rs | 3 ++- tasks/ast_tools/src/schema/serialize.rs | 6 ++++-- 17 files changed, 35 insertions(+), 17 deletions(-) diff --git a/tasks/ast_tools/src/derives/clone_in.rs b/tasks/ast_tools/src/derives/clone_in.rs index bd43d5b328859..8247fd5c8b3b8 100644 --- a/tasks/ast_tools/src/derives/clone_in.rs +++ b/tasks/ast_tools/src/derives/clone_in.rs @@ -3,13 +3,14 @@ use proc_macro2::TokenStream; use quote::{format_ident, quote}; use syn::Ident; -use super::{define_derive, Derive}; use crate::{ codegen::LateCtx, markers::CloneInAttribute, schema::{EnumDef, GetIdent, StructDef, TypeDef}, }; +use super::{define_derive, Derive}; + pub struct DeriveCloneIn; define_derive!(DeriveCloneIn); diff --git a/tasks/ast_tools/src/derives/content_eq.rs b/tasks/ast_tools/src/derives/content_eq.rs index 546d4913896b5..a36b68434bf78 100644 --- a/tasks/ast_tools/src/derives/content_eq.rs +++ b/tasks/ast_tools/src/derives/content_eq.rs @@ -2,13 +2,14 @@ use itertools::Itertools; use proc_macro2::TokenStream; use quote::quote; -use super::{define_derive, Derive}; use crate::{ codegen::LateCtx, schema::{EnumDef, GetGenerics, StructDef, ToType, TypeDef}, util::ToIdent, }; +use super::{define_derive, Derive}; + pub struct DeriveContentEq; define_derive!(DeriveContentEq); diff --git a/tasks/ast_tools/src/derives/content_hash.rs b/tasks/ast_tools/src/derives/content_hash.rs index d80f15d8e3af4..3bd267a97bd28 100644 --- a/tasks/ast_tools/src/derives/content_hash.rs +++ b/tasks/ast_tools/src/derives/content_hash.rs @@ -2,13 +2,14 @@ use itertools::Itertools; use proc_macro2::TokenStream; use quote::quote; -use super::{define_derive, Derive}; use crate::{ codegen::LateCtx, schema::{EnumDef, GetGenerics, StructDef, ToType, TypeDef}, util::ToIdent, }; +use super::{define_derive, Derive}; + pub struct DeriveContentHash; define_derive!(DeriveContentHash); diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index f3720507ad1e0..3d9588f23bf21 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -2,7 +2,6 @@ use convert_case::{Case, Casing}; use proc_macro2::TokenStream; use quote::quote; -use super::{define_derive, Derive}; use crate::{ codegen::LateCtx, markers::ESTreeStructAttribute, @@ -12,6 +11,8 @@ use crate::{ }, }; +use super::{define_derive, Derive}; + pub struct DeriveESTree; define_derive!(DeriveESTree); diff --git a/tasks/ast_tools/src/derives/get_span.rs b/tasks/ast_tools/src/derives/get_span.rs index 06b3ea676d890..77f9e9a20efcd 100644 --- a/tasks/ast_tools/src/derives/get_span.rs +++ b/tasks/ast_tools/src/derives/get_span.rs @@ -2,13 +2,14 @@ use proc_macro2::TokenStream; use quote::quote; use syn::Ident; -use super::{define_derive, Derive}; use crate::{ codegen::LateCtx, schema::{EnumDef, GetGenerics, StructDef, ToType, TypeDef}, util::{ToIdent, TypeWrapper}, }; +use super::{define_derive, Derive}; + pub struct DeriveGetSpan; define_derive!(DeriveGetSpan); diff --git a/tasks/ast_tools/src/generators/assert_layouts.rs b/tasks/ast_tools/src/generators/assert_layouts.rs index a1166d742a92e..a006095aa90ac 100644 --- a/tasks/ast_tools/src/generators/assert_layouts.rs +++ b/tasks/ast_tools/src/generators/assert_layouts.rs @@ -2,7 +2,6 @@ use proc_macro2::TokenStream; use quote::quote; use syn::Type; -use super::define_generator; use crate::{ codegen::LateCtx, output::{output_path, Output}, @@ -11,6 +10,8 @@ use crate::{ Generator, }; +use super::define_generator; + pub struct AssertLayouts; define_generator!(AssertLayouts); diff --git a/tasks/ast_tools/src/generators/ast_builder.rs b/tasks/ast_tools/src/generators/ast_builder.rs index 50267cf444189..b2e2d2116a6a2 100644 --- a/tasks/ast_tools/src/generators/ast_builder.rs +++ b/tasks/ast_tools/src/generators/ast_builder.rs @@ -8,7 +8,6 @@ use quote::{format_ident, quote, ToTokens}; use rustc_hash::FxHashMap; use syn::{parse_quote, Ident, Type}; -use super::define_generator; use crate::{ codegen::LateCtx, output::{output_path, Output}, @@ -19,6 +18,8 @@ use crate::{ Generator, }; +use super::define_generator; + pub struct AstBuilderGenerator; define_generator!(AstBuilderGenerator); diff --git a/tasks/ast_tools/src/generators/ast_kind.rs b/tasks/ast_tools/src/generators/ast_kind.rs index c177077890c14..5c99d980dde14 100644 --- a/tasks/ast_tools/src/generators/ast_kind.rs +++ b/tasks/ast_tools/src/generators/ast_kind.rs @@ -3,7 +3,6 @@ use itertools::Itertools; use quote::{format_ident, quote}; use syn::{parse_quote, Arm, ImplItemFn, Variant}; -use super::define_generator; use crate::{ codegen::LateCtx, output::{output_path, Output}, @@ -11,6 +10,8 @@ use crate::{ Generator, }; +use super::define_generator; + pub struct AstKindGenerator; define_generator!(AstKindGenerator); diff --git a/tasks/ast_tools/src/generators/typescript.rs b/tasks/ast_tools/src/generators/typescript.rs index bd9107e3c1653..2d1f5e4072725 100644 --- a/tasks/ast_tools/src/generators/typescript.rs +++ b/tasks/ast_tools/src/generators/typescript.rs @@ -1,7 +1,6 @@ use convert_case::{Case, Casing}; use itertools::Itertools; -use super::define_generator; use crate::{ codegen::LateCtx, output::{output_path, Output}, @@ -12,6 +11,8 @@ use crate::{ Generator, }; +use super::define_generator; + const CUSTOM_TYPESCRIPT: &str = include_str!("../../../../crates/oxc_ast/src/ast/types.d.ts"); pub struct TypescriptGenerator; diff --git a/tasks/ast_tools/src/generators/visit.rs b/tasks/ast_tools/src/generators/visit.rs index 270ce96f27d40..af969e018a62c 100644 --- a/tasks/ast_tools/src/generators/visit.rs +++ b/tasks/ast_tools/src/generators/visit.rs @@ -7,7 +7,6 @@ use quote::{format_ident, quote, ToTokens}; use rustc_hash::FxHashMap; use syn::{parse_quote, Ident}; -use super::define_generator; use crate::{ codegen::LateCtx, generators::ast_kind::BLACK_LIST as KIND_BLACK_LIST, @@ -18,6 +17,8 @@ use crate::{ Generator, }; +use super::define_generator; + pub struct VisitGenerator; define_generator!(VisitGenerator); diff --git a/tasks/ast_tools/src/main.rs b/tasks/ast_tools/src/main.rs index ba04f0575ad18..b3fd779908781 100644 --- a/tasks/ast_tools/src/main.rs +++ b/tasks/ast_tools/src/main.rs @@ -1,4 +1,5 @@ #![allow(clippy::disallowed_methods)] + use std::{cell::RefCell, io::Read, path::PathBuf, rc::Rc}; use bpaf::{Bpaf, Parser}; diff --git a/tasks/ast_tools/src/passes/calc_layout.rs b/tasks/ast_tools/src/passes/calc_layout.rs index 8afe0d0ed75d0..fe07eee529785 100644 --- a/tasks/ast_tools/src/passes/calc_layout.rs +++ b/tasks/ast_tools/src/passes/calc_layout.rs @@ -6,7 +6,6 @@ use quote::ToTokens; use rustc_hash::FxHashMap; use syn::Type; -use super::{define_pass, Pass}; use crate::{ codegen::EarlyCtx, layout::{KnownLayout, Layout}, @@ -15,6 +14,8 @@ use crate::{ Result, }; +use super::{define_pass, Pass}; + /// We use compiler to infer 64bit type layouts. #[cfg(not(target_pointer_width = "64"))] compile_error!("This module only supports 64bit architectures."); diff --git a/tasks/ast_tools/src/passes/linker.rs b/tasks/ast_tools/src/passes/linker.rs index 0be7ad08606f2..247c52cfa1124 100644 --- a/tasks/ast_tools/src/passes/linker.rs +++ b/tasks/ast_tools/src/passes/linker.rs @@ -2,9 +2,10 @@ use std::borrow::Cow; use syn::parse_quote; -use super::{define_pass, AstType, Pass, Result}; use crate::{codegen::EarlyCtx, rust_ast::Inherit, util::NormalizeError}; +use super::{define_pass, AstType, Pass, Result}; + pub trait Unresolved { fn unresolved(&self) -> bool; diff --git a/tasks/ast_tools/src/rust_ast.rs b/tasks/ast_tools/src/rust_ast.rs index 36c007d3ee56d..d097968f73052 100644 --- a/tasks/ast_tools/src/rust_ast.rs +++ b/tasks/ast_tools/src/rust_ast.rs @@ -9,10 +9,11 @@ use syn::{ Variant, Visibility, }; -use super::{parse_file, Itertools, PathBuf, Rc, Read, RefCell, Result}; use crate::{ layout::Layout, + parse_file, util::{unexpanded_macro_err, NormalizeError}, + Itertools, PathBuf, Rc, Read, RefCell, Result, }; pub type AstRef = Rc>; diff --git a/tasks/ast_tools/src/schema/defs.rs b/tasks/ast_tools/src/schema/defs.rs index 45a77dac7f120..5688a1b9d7b9e 100644 --- a/tasks/ast_tools/src/schema/defs.rs +++ b/tasks/ast_tools/src/schema/defs.rs @@ -1,7 +1,6 @@ use serde::Serialize; use syn::Ident; -use super::{with_either, TypeName}; use crate::{ markers::{ DeriveAttributes, ESTreeEnumAttribute, ESTreeStructAttribute, ScopeAttribute, ScopeMarkers, @@ -11,6 +10,8 @@ use crate::{ TypeId, }; +use super::{with_either, TypeName}; + #[derive(Debug, Serialize)] #[serde(untagged)] pub enum TypeDef { diff --git a/tasks/ast_tools/src/schema/get_ident.rs b/tasks/ast_tools/src/schema/get_ident.rs index 6022d4cfd77fa..a0dde5f300868 100644 --- a/tasks/ast_tools/src/schema/get_ident.rs +++ b/tasks/ast_tools/src/schema/get_ident.rs @@ -1,10 +1,11 @@ use syn::Ident; +use crate::util::ToIdent; + use super::{ defs::{EnumDef, StructDef, TypeDef}, with_either, }; -use crate::util::ToIdent; pub trait GetIdent { fn ident(&self) -> Ident; diff --git a/tasks/ast_tools/src/schema/serialize.rs b/tasks/ast_tools/src/schema/serialize.rs index 623402fdf04c8..3386d75318d5e 100644 --- a/tasks/ast_tools/src/schema/serialize.rs +++ b/tasks/ast_tools/src/schema/serialize.rs @@ -1,7 +1,9 @@ -use super::{EnumDef, StructDef, VariantDef}; -use crate::{markers::ESTreeStructAttribute, schema::GetIdent}; use convert_case::{Case, Casing}; +use crate::{markers::ESTreeStructAttribute, schema::GetIdent}; + +use super::{EnumDef, StructDef, VariantDef}; + pub fn enum_variant_name(var: &VariantDef, enm: &EnumDef) -> String { match var.markers.derive_attributes.estree.rename.as_ref() { Some(rename) => rename.to_string(),