From 3d5845702707f4d668a099ac81f2eae85d2343e6 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 27 Aug 2021 00:08:48 -0400 Subject: [PATCH] refactor(es/dep_graph): Use `dyn` instead of `impl` (#2119) swc_ecma_dep_graph: - Use `dyn` instead of `impl` in `analyze_dependencies`. --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- ecmascript/Cargo.toml | 4 ++-- ecmascript/dep-graph/Cargo.toml | 2 +- ecmascript/dep-graph/src/lib.rs | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b27df13672..d00011d7756 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2287,7 +2287,7 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "swc" -version = "0.45.0" +version = "0.46.0" dependencies = [ "ahash", "anyhow", @@ -2582,7 +2582,7 @@ dependencies = [ [[package]] name = "swc_ecma_dep_graph" -version = "0.35.0" +version = "0.36.0" dependencies = [ "swc_atoms 0.2.7", "swc_common", @@ -2968,7 +2968,7 @@ dependencies = [ [[package]] name = "swc_ecmascript" -version = "0.57.1" +version = "0.58.0" dependencies = [ "swc_ecma_ast", "swc_ecma_codegen", diff --git a/Cargo.toml b/Cargo.toml index 13602b36df9..f52bcb350a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc" repository = "https://github.com/swc-project/swc.git" -version = "0.45.0" +version = "0.46.0" [lib] name = "swc" @@ -66,7 +66,7 @@ swc_ecma_transforms = {version = "0.67.0", path = "./ecmascript/transforms", fea swc_ecma_transforms_base = {version = "0.27.0", path = "./ecmascript/transforms/base"} swc_ecma_utils = {version = "0.41.2", path = "./ecmascript/utils"} swc_ecma_visit = {version = "0.35.2", path = "./ecmascript/visit"} -swc_ecmascript = {version = "0.57.0", path = "./ecmascript"} +swc_ecmascript = {version = "0.58.0", path = "./ecmascript"} swc_node_base = {version = "0.2.2", path = "./node/base"} swc_visit = {version = "0.2.3", path = "./visit"} diff --git a/ecmascript/Cargo.toml b/ecmascript/Cargo.toml index 972c658c54d..9a88b704813 100644 --- a/ecmascript/Cargo.toml +++ b/ecmascript/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecmascript" repository = "https://github.com/swc-project/swc.git" -version = "0.57.1" +version = "0.58.0" [package.metadata.docs.rs] all-features = true @@ -34,7 +34,7 @@ typescript = ["typescript-parser", "swc_ecma_transforms/typescript"] [dependencies] swc_ecma_ast = {version = "0.49.4", path = "./ast"} swc_ecma_codegen = {version = "0.67.0", path = "./codegen", optional = true} -swc_ecma_dep_graph = {version = "0.35.0", path = "./dep-graph", optional = true} +swc_ecma_dep_graph = {version = "0.36.0", path = "./dep-graph", optional = true} swc_ecma_minifier = {version = "0.22.0", path = "./minifier", optional = true} swc_ecma_parser = {version = "0.67.0", path = "./parser", optional = true, default-features = false} swc_ecma_preset_env = {version = "0.38.0", path = "./preset-env", optional = true} diff --git a/ecmascript/dep-graph/Cargo.toml b/ecmascript/dep-graph/Cargo.toml index 4739773764f..0b67855d794 100644 --- a/ecmascript/dep-graph/Cargo.toml +++ b/ecmascript/dep-graph/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_dep_graph" repository = "https://github.com/swc-project/swc.git" -version = "0.35.0" +version = "0.36.0" [dependencies] swc_atoms = {version = "0.2", path = "../../atoms"} diff --git a/ecmascript/dep-graph/src/lib.rs b/ecmascript/dep-graph/src/lib.rs index 32ff56291a8..685e29ba4c1 100644 --- a/ecmascript/dep-graph/src/lib.rs +++ b/ecmascript/dep-graph/src/lib.rs @@ -9,7 +9,7 @@ use swc_ecma_visit::{self, Node, Visit, VisitWith}; pub fn analyze_dependencies( module: &ast::Module, - comments: &impl Comments, + comments: &dyn Comments, ) -> Vec { let mut v = DependencyCollector { comments, @@ -48,21 +48,21 @@ pub struct DependencyDescriptor { pub import_assertions: HashMap, } -struct DependencyCollector<'a, TComments: Comments> { - comments: &'a TComments, +struct DependencyCollector<'a> { + comments: &'a dyn Comments, pub items: Vec, // This field is used to determine if currently visited "require" // is top level and "static", or inside module body and "dynamic". is_top_level: bool, } -impl<'a, TComments: Comments> DependencyCollector<'a, TComments> { +impl<'a> DependencyCollector<'a> { fn get_leading_comments(&self, span: Span) -> Vec { self.comments.get_leading(span.lo).unwrap_or_else(Vec::new) } } -impl<'a, TComments: Comments> Visit for DependencyCollector<'a, TComments> { +impl<'a> Visit for DependencyCollector<'a> { fn visit_import_decl(&mut self, node: &ast::ImportDecl, _parent: &dyn Node) { let specifier = node.src.value.clone(); let leading_comments = self.get_leading_comments(node.span);