Skip to content

Commit

Permalink
chore(macros): only select required features from syn to reduce com…
Browse files Browse the repository at this point in the history
…pile time (#2955)
  • Loading branch information
Boshen authored Apr 13, 2024
1 parent f366d9b commit bd56d51
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
7 changes: 5 additions & 2 deletions crates/oxc_macros/src/declare_oxc_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ pub fn declare_oxc_lint(metadata: LintRuleMeta) -> TokenStream {
TokenStream::from(output)
}

fn parse_attr<const LEN: usize>(path: [&'static str; LEN], attr: &Attribute) -> Option<LitStr> {
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);
}
}
}
Expand Down

0 comments on commit bd56d51

Please sign in to comment.