Skip to content

Commit

Permalink
Update tl-proto-proc to syn2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Aug 12, 2023
1 parent d929673 commit a02dbaf
Show file tree
Hide file tree
Showing 6 changed files with 417 additions and 296 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "tl-proto"
description = "A collection of traits for working with TL serialization/deserialization"
authors = ["Ivan Kalinin <i.kalinin@dexpa.io>"]
repository = "https://github.com/broxus/tl-proto"
version = "0.4.2"
version = "0.4.3"
edition = "2021"
include = ["src/**/*.rs", "README.md"]
license = "MIT"
Expand All @@ -18,7 +18,7 @@ sha2 = { version = "0.10", optional = true }
smallvec = { version = "1.7", features = ["union", "const_generics"] }
thiserror = "1.0"

tl-proto-proc = { version = "=0.4.1", path = "proc", optional = true }
tl-proto-proc = { version = "=0.4.3", path = "proc", optional = true }

[features]
default = ["derive", "bytes", "hash"]
Expand Down
4 changes: 2 additions & 2 deletions proc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "tl-proto-proc"
description = "A collection of traits for working with TL serialization/deserialization"
authors = ["Ivan Kalinin <i.kalinin@dexpa.io>"]
repository = "https://github.com/broxus/tl-proto"
version = "0.4.1"
version = "0.4.3"
edition = "2021"
include = ["src/**/*.rs", "../README.md"]
license = "MIT"
Expand All @@ -15,5 +15,5 @@ proc-macro = true
proc-macro2 = "1.0"
quote = "1.0"
rustc-hash = "1.1.0"
syn = { version = "1.0", features = ["visit"] }
syn = { version = "2.0", features = ["visit"] }
tl-scheme = { version = "0.2.0", path = "../scheme" }
19 changes: 14 additions & 5 deletions proc/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ use proc_macro2::TokenStream;
use super::internals::{attr, ctxt};
use super::scheme_loader;

pub fn impl_id(
input: &TokenStream,
meta: &[syn::NestedMeta],
) -> Result<TokenStream, Vec<syn::Error>> {
pub struct IdMacroInput(Vec<attr::LegacyMeta>);

impl syn::parse::Parse for IdMacroInput {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
let items =
syn::punctuated::Punctuated::<attr::LegacyMeta, syn::Token!(,)>::parse_terminated(
input,
)?;
Ok(Self(items.into_iter().collect()))
}
}

pub fn impl_id(input: &TokenStream, meta: &IdMacroInput) -> Result<TokenStream, Vec<syn::Error>> {
let cx = ctxt::Ctxt::new();
let id = match attr::IdMacro::from_ast(&cx, input, meta)
let id = match attr::IdMacro::from_ast(&cx, input, &meta.0)
.and_then(|attrs| scheme_loader::compute_tl_id(&cx, attrs.id, &attrs.scheme))
{
Some(attrs) => attrs,
Expand Down
Loading

0 comments on commit a02dbaf

Please sign in to comment.