From bd56d514431274ace4ce25479212194ca62f221a Mon Sep 17 00:00:00 2001 From: Boshen Date: Sat, 13 Apr 2024 13:37:59 +0800 Subject: [PATCH] chore(macros): only select required features from `syn` to reduce compile time (#2955) --- Cargo.toml | 2 +- crates/oxc_macros/Cargo.toml | 2 +- crates/oxc_macros/src/declare_oxc_lint.rs | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 74168c48ba9a0..c9c26b2569f0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,7 +121,7 @@ ropey = "1.6.1" seq-macro = "0.3.5" serde = "1.0.197" serde_json = "1.0.115" -syn = "2.0.57" +syn = { version = "2.0.58", default-features = false } tempfile = "3.10.1" thiserror = "1.0.58" tokio = "1" diff --git a/crates/oxc_macros/Cargo.toml b/crates/oxc_macros/Cargo.toml index aa9c0186a81d8..b1ccf33331108 100644 --- a/crates/oxc_macros/Cargo.toml +++ b/crates/oxc_macros/Cargo.toml @@ -20,7 +20,7 @@ proc-macro = true doctest = false [dependencies] -syn = { workspace = true } +syn = { workspace = true, features = ["derive", "parsing", "proc-macro", "printing"]} quote = { workspace = true } proc-macro2 = { workspace = true } itertools = { workspace = true } diff --git a/crates/oxc_macros/src/declare_oxc_lint.rs b/crates/oxc_macros/src/declare_oxc_lint.rs index ea8345f139ba8..e0c735ba6926e 100644 --- a/crates/oxc_macros/src/declare_oxc_lint.rs +++ b/crates/oxc_macros/src/declare_oxc_lint.rs @@ -76,13 +76,16 @@ pub fn declare_oxc_lint(metadata: LintRuleMeta) -> TokenStream { TokenStream::from(output) } -fn parse_attr(path: [&'static str; LEN], attr: &Attribute) -> Option { +fn parse_attr<'a, const LEN: usize>( + path: [&'static str; LEN], + attr: &'a Attribute, +) -> Option<&'a LitStr> { if let Meta::NameValue(name_value) = &attr.meta { let path_idents = name_value.path.segments.iter().map(|segment| &segment.ident); if itertools::equal(path_idents, path) { if let Expr::Lit(expr_lit) = &name_value.value { if let Lit::Str(s) = &expr_lit.lit { - return Some(s.clone()); + return Some(s); } } }