refactor(es/dep_graph): Use dyn instead of impl (#2119)

swc_ecma_dep_graph:
 - Use `dyn` instead of `impl` in `analyze_dependencies`.
This commit is contained in:
David Sherret 2021-08-27 00:08:48 -04:00 committed by GitHub
parent d975a197c9
commit 3d58457027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 13 deletions

6
Cargo.lock generated
View File

@ -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",

View File

@ -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"}

View File

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

View File

@ -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"}

View File

@ -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<DependencyDescriptor> {
let mut v = DependencyCollector {
comments,
@ -48,21 +48,21 @@ pub struct DependencyDescriptor {
pub import_assertions: HashMap<String, String>,
}
struct DependencyCollector<'a, TComments: Comments> {
comments: &'a TComments,
struct DependencyCollector<'a> {
comments: &'a dyn Comments,
pub items: Vec<DependencyDescriptor>,
// 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<Comment> {
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);