Skip to content

Commit

Permalink
0.3.0: syn2
Browse files Browse the repository at this point in the history
  • Loading branch information
vi committed Jul 12, 2023
1 parent 80c59d9 commit 7ba3589
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 170 deletions.
37 changes: 24 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 5 additions & 13 deletions Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "syn-file-expand"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
readme = "README.md"
license = "MIT/Apache-2.0"
Expand All @@ -14,21 +14,13 @@ include = ["src","Cargo.toml","tests", "examples", "resources", "README.md"]
im-rc = "15.0.0"
itertools = "0.10.3"
proc-macro2 = "1.0.36"
quote = "1.0.15" # almost not needed, just for one tricky case
syn = { version = "1.0.88", features = ["full","extra-traits","printing"] }
quote = "1.0.15"
syn = { version = "2", features = ["full","extra-traits","printing"] }
thiserror = "1.0.30"

[dev-dependencies]
#pretty_assertions = "1.2.1"
prettyplease = "0.1.10"
#pretty_assertions = "1.4"
prettyplease = "0.2"

[workspace]
members = [".", "crates/*"]

[profile.release]
opt-level = "s"
debug = 1
lto = true
codegen-units = 1
incremental = false
panic = 'abort'
8 changes: 4 additions & 4 deletions crates/syn-file-expand-cli/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "syn-file-expand-cli"
version = "0.2.0"
version = "0.3.0"
edition = "2021"

readme = "README.md"
Expand All @@ -14,12 +14,12 @@ include = ["src","Cargo.toml","README.md"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
syn-file-expand = {version = "0.2.0", path = "../.."}
syn-file-expand = {version = "0.3.0", path = "../.."}
quote = "1.0.15"
syn = { version = "1.0.88", features = ["full"] }
syn = { version = "2", features = ["full"] }
proc-macro2 = "1.0.36"
gumdrop = "0.8.1"
prettyplease = { version = "0.1.10", optional = true }
prettyplease = { version = "0.2", optional = true }

[features]
default = ["prettyplease"]
2 changes: 2 additions & 0 deletions crates/syn-file-expand-cli/src/getcfgname.rs
Expand Up @@ -28,6 +28,7 @@ pub(crate) fn get_env_name(input: proc_macro2::TokenStream) -> String {
syn::Lit::Float(_) => "".to_owned(),
syn::Lit::Bool(x) => format!("{}", x.value),
syn::Lit::Verbatim(_) => "".to_owned(),
_ => "".to_owned(),
}
} else {
eprintln!("Failed to parse a literal in a cfg `{}`", x);
Expand Down Expand Up @@ -75,6 +76,7 @@ pub(crate) fn get_cli_name(input: proc_macro2::TokenStream) -> String {
syn::Lit::Float(_) => "".to_owned(),
syn::Lit::Bool(x) => format!("{}", x.value),
syn::Lit::Verbatim(_) => "".to_owned(),
_ => "".to_owned(),
}
} else {
eprintln!("Failed to parse a literal in a cfg `{}`", x);
Expand Down
6 changes: 3 additions & 3 deletions crates/syn-file-expand-cli/src/loopify.rs
Expand Up @@ -12,7 +12,7 @@ fn loopify_block(block: &mut syn::Block) {
brace_token: syn::token::Brace::default(),
stmts: vec![],
},
})));
}), None));
}

fn loopify_expr(expr: &mut syn::Expr) {
Expand Down Expand Up @@ -42,7 +42,7 @@ fn loopify_item(item: &mut syn::Item) {
loopify_expr(&mut z.1);
}
}
syn::TraitItem::Method(y) => {
syn::TraitItem::Fn(y) => {
if let Some(z) = &mut y.default {
loopify_block(z);
}
Expand All @@ -69,7 +69,7 @@ fn loopify_item(item: &mut syn::Item) {
syn::ImplItem::Const(y) => {
loopify_expr(&mut y.expr);
}
syn::ImplItem::Method(y) => {
syn::ImplItem::Fn(y) => {
loopify_block(&mut y.block);
}
syn::ImplItem::Macro(y) => {
Expand Down
8 changes: 4 additions & 4 deletions crates/syn-file-expand-cli/src/undoc.rs
@@ -1,8 +1,8 @@

fn undoc_attrs(attrs: &mut Vec<syn::Attribute>) {
attrs.retain(|attr| {
match attr.path.get_ident().map(|x|x.to_string()).as_deref() {
Some("doc") => false,
match &attr.meta {
syn::Meta::NameValue(x) => !x.path.is_ident("doc"),
_ => true,
}
});
Expand All @@ -17,7 +17,7 @@ fn undoc_item(item: &mut syn::Item) {
syn::TraitItem::Const(y) => {
undoc_attrs(&mut y.attrs)
}
syn::TraitItem::Method(y) => {
syn::TraitItem::Fn(y) => {
undoc_attrs(&mut y.attrs)
}
syn::TraitItem::Type(y) => undoc_attrs(&mut y.attrs),
Expand All @@ -42,7 +42,7 @@ fn undoc_item(item: &mut syn::Item) {
for subitem in &mut x.items {
match subitem {
syn::ImplItem::Const(y) => undoc_attrs(&mut y.attrs),
syn::ImplItem::Method(y) =>undoc_attrs(&mut y.attrs),
syn::ImplItem::Fn(y) =>undoc_attrs(&mut y.attrs),
syn::ImplItem::Macro(y) =>undoc_attrs(&mut y.attrs),
syn::ImplItem::Type(y) =>undoc_attrs(&mut y.attrs),
syn::ImplItem::Verbatim(_) => (),
Expand Down

0 comments on commit 7ba3589

Please sign in to comment.