Repository: zhiburt/tabled (language: rust)

Issue:
Update syn requirement from 1 to 2
Updates the requirements on [syn](https://github.com/dtolnay/syn) to permit the latest version.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/dtolnay/syn/commit/25def51081b68538547f34a3494744a807be4203"><code>25def51</code></a> Release 2.0.3</li>
<li><a href="https://github.com/dtolnay/syn/commit/4f3803d2a936d42a3277e7bcd53efc777a4b13d5"><code>4f3803d</code></a> Merge pull request <a href="https://redirect.github.com/dtolnay/syn/issues/1412">#1412</a> from dtolnay/exprgroup</li>
<li><a href="https://github.com/dtolnay/syn/commit/516a5b5fbce8bb5679e1e38dcc4480aaba3aa8db"><code>516a5b5</code></a> Provide Expr::Group even with features=&quot;full&quot; off</li>
<li><a href="https://github.com/dtolnay/syn/commit/cac5cc640700ace3af3eac52c672b04e49e390cf"><code>cac5cc6</code></a> Release 2.0.2</li>
<li><a href="https://github.com/dtolnay/syn/commit/8f826ef67b583dae63150fff970c0f8c24939cb7"><code>8f826ef</code></a> Touch up spacing in example for parse_multi_with_leading_vert</li>
<li><a href="https://github.com/dtolnay/syn/commit/fc58fcf9ed026d5a587d6938c2ef5c980735b1c2"><code>fc58fcf</code></a> Fix typo in Stmt::Macro documentation</li>
<li><a href="https://github.com/dtolnay/syn/commit/e29815224c5e738607503db2ed2dedab37b3f9e3"><code>e298152</code></a> Release 2.0.1</li>
<li><a href="https://github.com/dtolnay/syn/commit/b87a0a1d02984df4ccb2d2e725cde3134ef369a8"><code>b87a0a1</code></a> Merge pull request <a href="https://redirect.github.com/dtolnay/syn/issues/1409">#1409</a> from dtolnay/requiremeta</li>
<li><a href="https://github.com/dtolnay/syn/commit/59dd7ccbf2a78809f95061952146af9ed7244b31"><code>59dd7cc</code></a> Add methods on Meta for error reporting an incorrect kind of attribute</li>
<li><a href="https://github.com/dtolnay/syn/commit/11c0b6c7add560d0b7a97ef0d95ab6005ff1d01b"><code>11c0b6c</code></a> Build attribute parse errors using std::fmt system</li>
<li>Additional commits viewable in <a href="https://github.com/dtolnay/syn/compare/1.0.0...2.0.3">compare view</a></li>
</ul>
</details>
<br />


You can trigger a rebase of this PR by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>> **Note**
> Automatic rebases have been disabled on this pull request as it has been open for over 30 days.



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dff35a83..fab53f76 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ## Unreleased
-
+- Migrated syn to 2.0 (By [@wyatt-herkamp](https://github.com/wyatt-herkamp))
 ## [0.17.0] - 2024-23-11
 
 ### Added
diff --git a/static_table/Cargo.toml b/static_table/Cargo.toml
index 5e964058..314be7dc 100644
--- a/static_table/Cargo.toml
+++ b/static_table/Cargo.toml
@@ -21,7 +21,7 @@ macros = ["tabled/macros"]
 
 [dependencies]
 tabled = { version = "0.17", features = ["std"], default-features = false }
-syn = { version = "1", features = ["parsing"] }
+syn = { version = "2", features = ["parsing"] }
 quote = "1"
 proc-macro2 = "1"
 proc-macro-error2 = "2.0.1"
diff --git a/static_table/src/pool_table.rs b/static_table/src/pool_table.rs
index 18af9b31..a9fbc1b4 100644
--- a/static_table/src/pool_table.rs
+++ b/static_table/src/pool_table.rs
@@ -3,6 +3,7 @@ use syn::{
     bracketed,
     parse::{Parse, ParseStream},
     punctuated::Punctuated,
+    spanned::Spanned,
     token::{self},
     ExprLit, Ident, Lit, LitInt, LitStr, Result, Token,
 };
@@ -202,16 +203,17 @@ impl<T: Parse> Parse for Pad<T> {
     }
 }
 
-fn expr_lit_to_string(expr_lit: &ExprLit) -> String {
+fn expr_lit_to_string(expr_lit: &ExprLit) -> Result<String> {
     match &expr_lit.lit {
-        Lit::Str(val) => val.value(),
-        Lit::ByteStr(val) => format!("{:?}", val.value()),
-        Lit::Int(val) => val.base10_digits().to_string(),
-        Lit::Float(val) => val.base10_digits().to_string(),
-        Lit::Char(val) => val.value().to_string(),
-        Lit::Byte(val) => val.value().to_string(),
-        Lit::Bool(val) => val.value().to_string(),
-        Lit::Verbatim(val) => val.to_token_stream().to_string(),
+        Lit::Str(val) => Ok(val.value()),
+        Lit::ByteStr(val) => Ok(format!("{:?}", val.value())),
+        Lit::Int(val) => Ok(val.base10_digits().to_string()),
+        Lit::Float(val) => Ok(val.base10_digits().to_string()),
+        Lit::Char(val) => Ok(val.value().to_string()),
+        Lit::Byte(val) => Ok(val.value().to_string()),
+        Lit::Bool(val) => Ok(val.value().to_string()),
+        Lit::Verbatim(val) => Ok(val.to_token_stream().to_string()),
+        _ => Err(syn::Error::new(expr_lit.span(), "unsupported literal type")),
     }
 }
 
@@ -240,7 +242,7 @@ fn collect_row(elems: &MatrixRowElements) -> Result<Vec<String>> {
         MatrixRowElements::List(list) => {
             let mut row = Vec::with_capacity(list.len());
             for val in list {
-                let val = expr_lit_to_string(val);
+                let val = expr_lit_to_string(val)?;
                 row.push(val);
             }
 
@@ -248,7 +250,7 @@ fn collect_row(elems: &MatrixRowElements) -> Result<Vec<String>> {
         }
         MatrixRowElements::Static { elem, len, .. } => {
             let len = len.base10_parse::<usize>()?;
-            let elem = expr_lit_to_string(elem);
+            let elem = expr_lit_to_string(elem)?;
             let row = vec![elem; len];
 
             Ok(row)
diff --git a/static_table/src/static_table.rs b/static_table/src/static_table.rs
index 0fe6afdd..ec769715 100644
--- a/static_table/src/static_table.rs
+++ b/static_table/src/static_table.rs
@@ -287,31 +287,42 @@ impl<T: Parse> Parse for Pad<T> {
     }
 }
 
-fn expr_lit_to_string(expr_lit: &ExprLit) -> String {
+fn expr_lit_to_string(expr_lit: &ExprLit) -> Result<String> {
     match &expr_lit.lit {
-        Lit::Str(val) => val.value(),
-        Lit::ByteStr(val) => format!("{:?}", val.value()),
-        Lit::Int(val) => val.base10_digits().to_string(),
-        Lit::Float(val) => val.base10_digits().to_string(),
-        Lit::Char(val) => val.value().to_string(),
-        Lit::Byte(val) => val.value().to_string(),
-        Lit::Bool(val) => val.value().to_string(),
-        Lit::Verbatim(val) => val.to_token_stream().to_string(),
+        Lit::Str(val) => Ok(val.value()),
+        Lit::ByteStr(val) => Ok(format!("{:?}", val.value())),
+        Lit::Int(val) => Ok(val.base10_digits().to_string()),
+        Lit::Float(val) => Ok(val.base10_digits().to_string()),
+        Lit::Char(val) => Ok(val.value().to_string()),
+        Lit::Byte(val) => Ok(val.value().to_string()),
+        Lit::Bool(val) => Ok(val.value().to_string()),
+        Lit::Verbatim(val) => Ok(val.to_token_stream().to_string()),
+        _ => Err(syn::Error::new_spanned(
+            expr_lit,
+            "Unsupported literal type",
+        )),
     }
 }
 
 fn expr_val_to_list(expr_val: &ExprVal) -> Result<Vec<String>> {
     match expr_val {
-        ExprVal::Lit(lit) => Ok(vec![expr_lit_to_string(lit)]),
+        ExprVal::Lit(lit) => Ok(vec![expr_lit_to_string(lit)?]),
         ExprVal::Scope { expr, .. } => match expr {
             Some(val) => match val {
-                ScopeVal::Expr(lit) => Ok(vec![expr_lit_to_string(lit)]),
-                ScopeVal::List(list) => Ok(list.into_iter().map(expr_lit_to_string).collect()),
+                ScopeVal::Expr(lit) => Ok(vec![expr_lit_to_string(lit)?]),
+                ScopeVal::List(list) => {
+                    let mut data = Vec::with_capacity(list.len());
+                    for val in list {
+                        data.push(expr_lit_to_string(val)?);
+                    }
+
+                    Ok(data)
+                }
                 ScopeVal::Sized { elem, len, .. } => {
                     let len = len.base10_parse::<usize>()?;
                     let mut data = vec![String::new(); len];
                     if len > 0 {
-                        data[0] = expr_lit_to_string(elem);
+                        data[0] = expr_lit_to_string(elem)?;
                     }
 
                     Ok(data)
diff --git a/tabled_derive/Cargo.toml b/tabled_derive/Cargo.toml
index 32c6df39..2c45bdb8 100644
--- a/tabled_derive/Cargo.toml
+++ b/tabled_derive/Cargo.toml
@@ -11,8 +11,8 @@ license = "MIT"
 proc-macro = true
 
 [dependencies]
-syn = { version = "1", features = ["full", "visit-mut"] }
+syn = { version = "2", features = ["full", "visit-mut"] }
 quote = "1"
 proc-macro2 = "1"
-heck = "0.4"
+heck = "0.5"
 proc-macro-error2 = "2.0.1"
diff --git a/tabled_derive/src/lib.rs b/tabled_derive/src/lib.rs
index fea02019..e8f90a69 100644
--- a/tabled_derive/src/lib.rs
+++ b/tabled_derive/src/lib.rs
@@ -110,7 +110,7 @@ fn get_fields_length(fields: &Fields, tabled_trait: &ExprPath) -> Result<TokenSt
     let size_components = std::iter::once(quote!(0)).chain(size_components);
 
     let mut stream = TokenStream::new();
-    stream.append_separated(size_components, syn::token::Add::default());
+    stream.append_separated(size_components, syn::token::Plus::default());
 
     Ok(stream)
 }
@@ -123,7 +123,7 @@ fn get_enum_length(enum_ast: &DataEnum, trait_path: &ExprPath) -> Result<TokenSt
         let size = size?;
 
         if i != 0 {
-            stream.append_all(syn::token::Add::default().into_token_stream());
+            stream.append_all(syn::token::Plus::default().into_token_stream());
         }
 
         stream.append_all(size);
diff --git a/tabled_derive/src/parse/field_attr.rs b/tabled_derive/src/parse/field_attr.rs
index 56bb98c6..1ef5e0b8 100644
--- a/tabled_derive/src/parse/field_attr.rs
+++ b/tabled_derive/src/parse/field_attr.rs
@@ -1,7 +1,7 @@
 use proc_macro2::{Ident, Span};
 use syn::{
-    parenthesized, parse::Parse, punctuated::Punctuated, token, Attribute, LitBool, LitInt, LitStr,
-    Token,
+    parenthesized, parse::Parse, punctuated::Punctuated, spanned::Spanned, token, Attribute,
+    LitBool, LitInt, LitStr, Token,
 };
 
 pub fn parse_field_attributes(
@@ -9,7 +9,7 @@ pub fn parse_field_attributes(
 ) -> impl Iterator<Item = syn::Result<impl Iterator<Item = FieldAttr>>> + '_ {
     attributes
         .iter()
-        .filter(|attr| attr.path.is_ident("tabled"))
+        .filter(|attr| attr.path().is_ident("tabled"))
         .map(|attr| attr.parse_args_with(Punctuated::<FieldAttr, Token![,]>::parse_terminated))
         .map(|result| result.map(IntoIterator::into_iter))
 }
@@ -124,7 +124,7 @@ impl Parse for FieldAttr {
             }
 
             return Err(syn::Error::new(
-                _paren.span,
+                _paren.span.span(),
                 "expected a `string literal` in parenthesis",
             ));
         }
diff --git a/tabled_derive/src/parse/type_attr.rs b/tabled_derive/src/parse/type_attr.rs
index 2ce6978e..6abe2220 100644
--- a/tabled_derive/src/parse/type_attr.rs
+++ b/tabled_derive/src/parse/type_attr.rs
@@ -1,6 +1,7 @@
 use proc_macro2::{Ident, Span};
 use syn::{
-    parenthesized, parse::Parse, punctuated::Punctuated, token, Attribute, LitBool, LitStr, Token,
+    parenthesized, parse::Parse, punctuated::Punctuated, spanned::Spanned, token, Attribute,
+    LitBool, LitStr, Token,
 };
 
 pub fn parse_type_attributes(
@@ -8,7 +9,7 @@ pub fn parse_type_attributes(
 ) -> impl Iterator<Item = syn::Result<impl Iterator<Item = TypeAttr>>> + '_ {
     attributes
         .iter()
-        .filter(|attr| attr.path.is_ident("tabled"))
+        .filter(|attr| attr.path().is_ident("tabled"))
         .map(|attr| attr.parse_args_with(Punctuated::<TypeAttr, Token![,]>::parse_terminated))
         .map(|result| result.map(IntoIterator::into_iter))
 }
@@ -86,7 +87,7 @@ impl Parse for TypeAttr {
             }
 
             return Err(syn::Error::new(
-                _paren.span,
+                _paren.span.span(),
                 "expected a `string literal` in parenthesis",
             ));
         }


Test patch: