Skip to content

Commit

Permalink
refactor(ast_codegen): remove unnecessary imports from generated files (
Browse files Browse the repository at this point in the history
#4774)

#4773 makes types like `Span` importable from `oxc_ast::ast`, so remove the imports from other crates in generated code.

I'm not sure why clippy's `wildcard_imports` rule was not being triggered for `use crate::ast::*;`, but add `#[allow(clippy::wildcard_imports)]` on these statements just to make sure.
  • Loading branch information
overlookmotel committed Aug 9, 2024
1 parent daa0b2e commit dbb5f4c
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 27 deletions.
4 changes: 1 addition & 3 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

use std::mem::{align_of, offset_of, size_of};

use oxc_span::*;
use oxc_syntax::{number::*, operator::*};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;

#[cfg(target_pointer_width = "64")]
Expand Down
7 changes: 0 additions & 7 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
)]

use oxc_allocator::{Allocator, Box, IntoIn, Vec};
use oxc_span::{Atom, SourceType, Span};
use oxc_syntax::{
number::{BigintBase, NumberBase},
operator::{
AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator,
},
};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_ast/src/generated/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use oxc_span::{GetSpan, Span};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;

#[derive(Debug, Clone, Copy)]
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_ast/src/generated/derive_clone_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use oxc_allocator::{Allocator, CloneIn};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;

impl<'alloc> CloneIn<'alloc> for BooleanLiteral {
Expand Down
3 changes: 2 additions & 1 deletion crates/oxc_ast/src/generated/derive_get_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

#![allow(clippy::match_same_arms)]

use oxc_span::{GetSpan, Span};
use oxc_span::GetSpan;

#[allow(clippy::wildcard_imports)]
use crate::ast::*;

impl GetSpan for BooleanLiteral {
Expand Down
3 changes: 2 additions & 1 deletion crates/oxc_ast/src/generated/derive_get_span_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

#![allow(clippy::match_same_arms)]

use oxc_span::{GetSpanMut, Span};
use oxc_span::GetSpanMut;

#[allow(clippy::wildcard_imports)]
use crate::ast::*;

impl GetSpanMut for BooleanLiteral {
Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_ast/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ use std::cell::Cell;
use oxc_allocator::Vec;
use oxc_syntax::scope::{ScopeFlags, ScopeId};

use crate::{ast::*, ast_kind::AstKind};
#[allow(clippy::wildcard_imports)]
use crate::ast::*;
use crate::ast_kind::AstKind;

use walk::*;

Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_ast/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ use std::cell::Cell;
use oxc_allocator::Vec;
use oxc_syntax::scope::{ScopeFlags, ScopeId};

use crate::{ast::*, ast_kind::AstType};
#[allow(clippy::wildcard_imports)]
use crate::ast::*;
use crate::ast_kind::AstType;

use walk_mut::*;

Expand Down
5 changes: 1 addition & 4 deletions tasks/ast_codegen/src/generators/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ impl Generator for AssertLayouts {
use std::mem::{align_of, offset_of, size_of};
endl!();

use oxc_span::*;
use oxc_syntax::{number::*, operator::*};
endl!();

#[allow(clippy::wildcard_imports)]
use crate::ast::*;
endl!();

Expand Down
7 changes: 0 additions & 7 deletions tasks/ast_codegen/src/generators/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ impl Generator for AstBuilderGenerator {
endl!();

use oxc_allocator::{Allocator, Box, IntoIn, Vec};
use oxc_span::{Atom, SourceType, Span};
use oxc_syntax::{
number::{BigintBase, NumberBase},
operator::{
AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator,
},
};
endl!();

#[allow(clippy::wildcard_imports)]
Expand Down
1 change: 1 addition & 0 deletions tasks/ast_codegen/src/generators/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ impl Generator for AstKindGenerator {
use oxc_span::{GetSpan, Span};
endl!();

#[allow(clippy::wildcard_imports)]
use crate::ast::*;
endl!();

Expand Down
1 change: 1 addition & 0 deletions tasks/ast_codegen/src/generators/derive_clone_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl Generator for DeriveCloneIn {
use oxc_allocator::{Allocator, CloneIn};
endl!();

#[allow(clippy::wildcard_imports)]
use crate::ast::*;
endl!();

Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_codegen/src/generators/derive_get_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ fn derive(
insert!("#![allow(clippy::match_same_arms)]");
endl!();

use oxc_span::{#trait_ident, Span};
use oxc_span::#trait_ident;
endl!();

#[allow(clippy::wildcard_imports)]
use crate::ast::*;
endl!();

Expand Down
4 changes: 3 additions & 1 deletion tasks/ast_codegen/src/generators/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ fn generate_visit<const MUT: bool>(ctx: &LateCtx) -> TokenStream {
use oxc_syntax::scope::{ScopeFlags, ScopeId};
endl!();

use crate::{ast::*, ast_kind::#ast_kind_type};
#[allow(clippy::wildcard_imports)]
use crate::ast::*;
use crate::ast_kind::#ast_kind_type;
endl!();

use #walk_mod::*;
Expand Down

0 comments on commit dbb5f4c

Please sign in to comment.