Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): update syn requirement from 1.0.109 to 2.0.37 #426

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ scoped_threadpool = "0.1.9"
serde = "1.0"
serde_json = "1.0.82"
smallvec = "1.8.0"
syn = "1.0.109"
syn = "2.0.38"
tiny-skia-path = {version = "0.11.0"}
unicode-bidi = "0.3.7"
unicode-script = "0.5.4"
Expand Down
5 changes: 1 addition & 4 deletions macros/builtin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,4 @@ proc-macro = true
proc-macro2.workspace = true
quote.workspace = true
smallvec.workspace = true

[dependencies.syn]
features = ["full"]
version = "1.0.109"
syn ={ workspace=true, features = ["full"]}
8 changes: 4 additions & 4 deletions macros/builtin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ impl ToTokens for Item {
Item::Field { doc_attr, mem, _colon, ty } => {
let ty = quote! { #ty }.to_string();
let name = mem.to_string();
let doc = match &doc_attr.lit {
syn::Lit::Str(str) => str,
let doc = match &doc_attr.value {
syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(str), .. }) => str,
_ => unreachable!(),
};
tokens.extend(quote! {
Expand All @@ -96,8 +96,8 @@ impl ToTokens for Item {
Item::Method { doc_attr, sign } => {
let name = sign.ident.to_string();
let sign = sign.to_token_stream().to_string();
let doc = match &doc_attr.lit {
syn::Lit::Str(str) => str,
let doc = match &doc_attr.value {
syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(str), .. }) => str,
_ => unreachable!(),
};
tokens.extend(quote! {
Expand Down
7 changes: 3 additions & 4 deletions macros/src/declare_derive2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,9 @@ fn collect_filed_and_attrs(stt: &mut DataStruct) -> Result<Punctuated<DeclareFie
.pairs_mut()
.try_for_each::<_, syn::Result<()>>(|pair| {
let (field, comma) = pair.into_tuple();
let idx = field
.attrs
.iter()
.position(|attr| attr.path.is_ident(DECLARE_ATTR));
let idx = field.attrs.iter().position(
|attr| matches!(&attr.meta, syn::Meta::List(l) if l.path.is_ident(DECLARE_ATTR)),
);
let builder_attr = if let Some(idx) = idx {
let attr = field.attrs.remove(idx);
let args: DeclareAttr = attr.parse_args()?;
Expand Down
6 changes: 3 additions & 3 deletions macros/src/rdl_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use syn::{
parse_macro_input, parse_quote,
punctuated::Punctuated,
spanned::Spanned,
token::{Bang, Brace, Colon, Comma, Dollar},
token::{Brace, Colon, Comma, Dollar, Not},
Expr, Ident, Macro, Path, Result as SynResult, Stmt,
};

Expand Down Expand Up @@ -115,7 +115,7 @@ impl Parse for StructLiteral {
break;
}

if content.peek(kw::rdl) && content.peek2(Bang) {
if content.peek(kw::rdl) && content.peek2(Not) {
children.push(content.parse()?);
} else if content.peek(Ident) {
let f: DeclareField = content.parse()?;
Expand All @@ -142,7 +142,7 @@ impl Parse for StructLiteral {

impl Parse for RdlParent {
fn parse(input: ParseStream) -> SynResult<Self> {
if input.peek(kw::_dollar_ಠ_ಠ) && input.peek2(Bang) {
if input.peek(kw::_dollar_ಠ_ಠ) && input.peek2(Not) {
let mac: Macro = input.parse()?;

Ok(RdlParent::Var(mac.parse_body_with(
Expand Down
15 changes: 9 additions & 6 deletions macros/src/symbol_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ mod tokens_pre_process {
if at.as_char() == '@' && !matches!(tokens.last(), Some(TokenTree::Ident(_))) =>
{
tokens.push(TokenTree::Ident(Ident::new(KW_RDL, at.span())));
tokens.push(TokenTree::Punct(Punct::new('!', Spacing::Alone)));
tokens.push(not_token(at.span()));

let body = match iter.next() {
// declare a new widget: `@ SizedBox { ... }`
Expand Down Expand Up @@ -147,7 +147,7 @@ mod tokens_pre_process {
match iter.next() {
Some(TokenTree::Ident(name)) => {
tokens.push(TokenTree::Ident(Ident::new(KW_DOLLAR_STR, p.span())));
tokens.push(TokenTree::Punct(Punct::new('!', Spacing::Alone)));
tokens.push(not_token(p.span()));
let span = name.span();
let mut g = Group::new(
Delimiter::Parenthesis,
Expand Down Expand Up @@ -183,6 +183,12 @@ mod tokens_pre_process {
};
p.as_char() == '!'
}

fn not_token(span: Span) -> TokenTree {
let mut t = Punct::new('!', Spacing::Alone);
t.set_span(span);
TokenTree::Punct(t)
}
}

impl Fold for DollarRefsCtx {
Expand All @@ -204,11 +210,8 @@ impl Fold for DollarRefsCtx {
fn fold_local(&mut self, mut i: syn::Local) -> syn::Local {
// we fold right expression first, then fold pattern, because the `=` is a
// right operator.
i.init = i
.init
.map(|(assign, e)| (assign, Box::new(self.fold_expr(*e))));
i.init = i.init.map(|init| self.fold_local_init(init));
i.pat = self.fold_pat(i.pat);

i
}

Expand Down