refactor(ast_codegen): remove unnecessary imports from generated files (#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.
This commit is contained in:
overlookmotel 2024-08-09 07:48:09 +00:00
parent daa0b2e66e
commit dbb5f4c75e
14 changed files with 21 additions and 27 deletions

View file

@ -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")]

View file

@ -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::*;

View file

@ -3,6 +3,7 @@
use oxc_span::{GetSpan, Span};
#[allow(clippy::wildcard_imports)]
use crate::ast::*;
#[derive(Debug, Clone, Copy)]

View file

@ -3,6 +3,7 @@
use oxc_allocator::{Allocator, CloneIn};
#[allow(clippy::wildcard_imports)]
use crate::ast::*;
impl<'alloc> CloneIn<'alloc> for BooleanLiteral {

View file

@ -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 {

View file

@ -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 {

View file

@ -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::*;

View file

@ -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::*;

View file

@ -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!();

View file

@ -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)]

View file

@ -170,6 +170,7 @@ impl Generator for AstKindGenerator {
use oxc_span::{GetSpan, Span};
endl!();
#[allow(clippy::wildcard_imports)]
use crate::ast::*;
endl!();

View file

@ -38,6 +38,7 @@ impl Generator for DeriveCloneIn {
use oxc_allocator::{Allocator, CloneIn};
endl!();
#[allow(clippy::wildcard_imports)]
use crate::ast::*;
endl!();

View file

@ -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!();

View file

@ -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::*;