Skip to content

Commit

Permalink
update syn 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
getong authored and tikue committed Feb 4, 2024
1 parent 1428cdc commit 1d98501
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion plugins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ travis-ci = { repository = "google/tarpc" }
[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", features = ["full"] }
syn = { version = "2.0", features = ["full"] }

[lib]
proc-macro = true
Expand Down
19 changes: 13 additions & 6 deletions plugins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use syn::{
parse_macro_input, parse_quote,
spanned::Spanned,
token::Comma,
Attribute, FnArg, Ident, Lit, LitBool, MetaNameValue, Pat, PatType, ReturnType, Token, Type,
Visibility,
Attribute, Expr, FnArg, Ident, Lit, LitBool, MetaNameValue, Pat, PatType, ReturnType, Token,
Type, Visibility,
};

/// Accumulates multiple errors into a result.
Expand Down Expand Up @@ -109,7 +109,7 @@ impl Parse for RpcMethod {
parenthesized!(content in input);
let mut args = Vec::new();
let mut errors = Ok(());
for arg in content.parse_terminated::<FnArg, Comma>(FnArg::parse)? {
for arg in content.parse_terminated(FnArg::parse, Comma)? {
match arg {
FnArg::Typed(captured) if matches!(&*captured.pat, Pat::Ident(_)) => {
args.push(captured);
Expand Down Expand Up @@ -149,7 +149,7 @@ impl Parse for DeriveSerde {
fn parse(input: ParseStream) -> syn::Result<Self> {
let mut result = Ok(None);
let mut derive_serde = Vec::new();
let meta_items = input.parse_terminated::<MetaNameValue, Comma>(MetaNameValue::parse)?;
let meta_items = input.parse_terminated(MetaNameValue::parse, Comma)?;
for meta in meta_items {
if meta.path.segments.len() != 1 {
extend_errors!(
Expand All @@ -172,7 +172,14 @@ impl Parse for DeriveSerde {
);
continue;
}
match meta.lit {
let Expr::Lit(expr_lit) = &meta.value else {
extend_errors!(
result,
syn::Error::new(meta.value.span(), "expected literal")
);
continue;
};
match expr_lit.lit {
Lit::Bool(LitBool { value: true, .. }) if cfg!(feature = "serde1") => {
result = result.and(Ok(Some(true)))
}
Expand All @@ -189,7 +196,7 @@ impl Parse for DeriveSerde {
_ => extend_errors!(
result,
syn::Error::new(
meta.lit.span(),
expr_lit.lit.span(),
"`derive_serde` expects a value of type `bool`"
)
),
Expand Down
4 changes: 2 additions & 2 deletions tarpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ tarpc-plugins = { path = "../plugins", version = "0.13" }
thiserror = "1.0"
tokio = { version = "1", features = ["time"] }
tokio-util = { version = "0.7.3", features = ["time"] }
tokio-serde = { optional = true, version = "0.8" }
tokio-serde = { optional = true, version = "0.9" }
tracing = { version = "0.1", default-features = false, features = [
"attributes",
"log",
Expand All @@ -77,7 +77,7 @@ serde_bytes = "0.11"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tokio = { version = "1", features = ["full", "test-util", "tracing"] }
console-subscriber = "0.2"
tokio-serde = { version = "0.8", features = ["json", "bincode"] }
tokio-serde = { version = "0.9", features = ["json", "bincode"] }
trybuild = "1.0"
tokio-rustls = "0.25"
rustls-pemfile = "2.0"
Expand Down

0 comments on commit 1d98501

Please sign in to comment.