mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore(deps): upgrade syn 2.0 (#1910)
This commit is contained in:
481
Cargo.lock
generated
481
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@ proc-macro = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
syn = { version = "1.0", features = ["extra-traits"] }
|
syn = { version = "2.0", features = ["extra-traits"] }
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
regex = "1.6.0"
|
regex = "1.6.0"
|
||||||
once_cell = "1.17.0"
|
once_cell = "1.17.0"
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use once_cell::sync::Lazy;
|
|||||||
use quote::{quote, ToTokens};
|
use quote::{quote, ToTokens};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use syn::{
|
use syn::{
|
||||||
punctuated::Punctuated, Attribute, Data, DeriveInput, Error, Lit, LitBool, LitStr,
|
punctuated::Punctuated, Attribute, Data, DeriveInput, Error, Expr, Lit, LitBool, LitStr,
|
||||||
MetaNameValue, Result, Token,
|
MetaNameValue, Result, Token,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ pub(crate) struct MetricsAttr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MetricsAttr {
|
impl MetricsAttr {
|
||||||
const DEFAULT_SEPARATOR: &str = ".";
|
const DEFAULT_SEPARATOR: &'static str = ".";
|
||||||
|
|
||||||
fn separator(&self) -> String {
|
fn separator(&self) -> String {
|
||||||
match &self.separator {
|
match &self.separator {
|
||||||
@ -189,18 +189,22 @@ fn parse_metrics_attr(node: &DeriveInput) -> Result<MetricsAttr> {
|
|||||||
metrics_attr.parse_args_with(Punctuated::<MetaNameValue, Token![,]>::parse_terminated)?;
|
metrics_attr.parse_args_with(Punctuated::<MetaNameValue, Token![,]>::parse_terminated)?;
|
||||||
let (mut scope, mut separator, mut dynamic) = (None, None, None);
|
let (mut scope, mut separator, mut dynamic) = (None, None, None);
|
||||||
for kv in parsed {
|
for kv in parsed {
|
||||||
|
let lit = match kv.value {
|
||||||
|
Expr::Lit(ref expr) => &expr.lit,
|
||||||
|
_ => continue,
|
||||||
|
};
|
||||||
if kv.path.is_ident("scope") {
|
if kv.path.is_ident("scope") {
|
||||||
if scope.is_some() {
|
if scope.is_some() {
|
||||||
return Err(Error::new_spanned(kv, "Duplicate `scope` value provided."))
|
return Err(Error::new_spanned(kv, "Duplicate `scope` value provided."))
|
||||||
}
|
}
|
||||||
let scope_lit = parse_str_lit(&kv.lit)?;
|
let scope_lit = parse_str_lit(lit)?;
|
||||||
validate_metric_name(&scope_lit)?;
|
validate_metric_name(&scope_lit)?;
|
||||||
scope = Some(scope_lit);
|
scope = Some(scope_lit);
|
||||||
} else if kv.path.is_ident("separator") {
|
} else if kv.path.is_ident("separator") {
|
||||||
if separator.is_some() {
|
if separator.is_some() {
|
||||||
return Err(Error::new_spanned(kv, "Duplicate `separator` value provided."))
|
return Err(Error::new_spanned(kv, "Duplicate `separator` value provided."))
|
||||||
}
|
}
|
||||||
let separator_lit = parse_str_lit(&kv.lit)?;
|
let separator_lit = parse_str_lit(lit)?;
|
||||||
if !SUPPORTED_SEPARATORS.contains(&&*separator_lit.value()) {
|
if !SUPPORTED_SEPARATORS.contains(&&*separator_lit.value()) {
|
||||||
return Err(Error::new_spanned(
|
return Err(Error::new_spanned(
|
||||||
kv,
|
kv,
|
||||||
@ -219,7 +223,7 @@ fn parse_metrics_attr(node: &DeriveInput) -> Result<MetricsAttr> {
|
|||||||
if dynamic.is_some() {
|
if dynamic.is_some() {
|
||||||
return Err(Error::new_spanned(kv, "Duplicate `dynamic` flag provided."))
|
return Err(Error::new_spanned(kv, "Duplicate `dynamic` flag provided."))
|
||||||
}
|
}
|
||||||
dynamic = Some(parse_bool_lit(&kv.lit)?.value);
|
dynamic = Some(parse_bool_lit(lit)?.value);
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::new_spanned(kv, "Unsupported attribute entry."))
|
return Err(Error::new_spanned(kv, "Unsupported attribute entry."))
|
||||||
}
|
}
|
||||||
@ -254,16 +258,20 @@ fn parse_metric_fields(node: &DeriveInput) -> Result<Vec<Metric<'_>>> {
|
|||||||
let parsed = metric_attr
|
let parsed = metric_attr
|
||||||
.parse_args_with(Punctuated::<MetaNameValue, Token![,]>::parse_terminated)?;
|
.parse_args_with(Punctuated::<MetaNameValue, Token![,]>::parse_terminated)?;
|
||||||
for kv in parsed {
|
for kv in parsed {
|
||||||
|
let lit = match kv.value {
|
||||||
|
Expr::Lit(ref expr) => &expr.lit,
|
||||||
|
_ => continue,
|
||||||
|
};
|
||||||
if kv.path.is_ident("describe") {
|
if kv.path.is_ident("describe") {
|
||||||
if describe.is_some() {
|
if describe.is_some() {
|
||||||
return Err(Error::new_spanned(kv, "Duplicate `describe` value provided."))
|
return Err(Error::new_spanned(kv, "Duplicate `describe` value provided."))
|
||||||
}
|
}
|
||||||
describe = Some(parse_str_lit(&kv.lit)?);
|
describe = Some(parse_str_lit(lit)?);
|
||||||
} else if kv.path.is_ident("rename") {
|
} else if kv.path.is_ident("rename") {
|
||||||
if rename.is_some() {
|
if rename.is_some() {
|
||||||
return Err(Error::new_spanned(kv, "Duplicate `rename` value provided."))
|
return Err(Error::new_spanned(kv, "Duplicate `rename` value provided."))
|
||||||
}
|
}
|
||||||
let rename_lit = parse_str_lit(&kv.lit)?;
|
let rename_lit = parse_str_lit(lit)?;
|
||||||
validate_metric_name(&rename_lit)?;
|
validate_metric_name(&rename_lit)?;
|
||||||
rename = Some(rename_lit)
|
rename = Some(rename_lit)
|
||||||
} else {
|
} else {
|
||||||
@ -304,7 +312,7 @@ fn parse_single_attr<'a, T: WithAttrs + ToTokens>(
|
|||||||
token: &'a T,
|
token: &'a T,
|
||||||
ident: &str,
|
ident: &str,
|
||||||
) -> Result<Option<&'a Attribute>> {
|
) -> Result<Option<&'a Attribute>> {
|
||||||
let mut attr_iter = token.attrs().iter().filter(|a| a.path.is_ident(ident));
|
let mut attr_iter = token.attrs().iter().filter(|a| a.path().is_ident(ident));
|
||||||
if let Some(attr) = attr_iter.next() {
|
if let Some(attr) = attr_iter.next() {
|
||||||
if let Some(next_attr) = attr_iter.next() {
|
if let Some(next_attr) = attr_iter.next() {
|
||||||
Err(Error::new_spanned(
|
Err(Error::new_spanned(
|
||||||
@ -333,15 +341,16 @@ fn parse_single_required_attr<'a, T: WithAttrs + ToTokens>(
|
|||||||
fn parse_docs_to_string<T: WithAttrs>(token: &T) -> Result<Option<String>> {
|
fn parse_docs_to_string<T: WithAttrs>(token: &T) -> Result<Option<String>> {
|
||||||
let mut doc_str = None;
|
let mut doc_str = None;
|
||||||
for attr in token.attrs().iter() {
|
for attr in token.attrs().iter() {
|
||||||
let meta = attr.parse_meta()?;
|
if let syn::Meta::NameValue(ref meta) = attr.meta {
|
||||||
if let syn::Meta::NameValue(meta) = meta {
|
if let Expr::Lit(ref lit) = meta.value {
|
||||||
if let syn::Lit::Str(doc) = meta.lit {
|
if let Lit::Str(ref doc) = lit.lit {
|
||||||
let doc_value = doc.value().trim().to_string();
|
let doc_value = doc.value().trim().to_string();
|
||||||
doc_str = Some(
|
doc_str = Some(
|
||||||
doc_str
|
doc_str
|
||||||
.map(|prev_doc_value| format!("{prev_doc_value} {doc_value}"))
|
.map(|prev_doc_value| format!("{prev_doc_value} {doc_value}"))
|
||||||
.unwrap_or(doc_value),
|
.unwrap_or(doc_value),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,11 +17,12 @@ error: Either `scope = ..` or `dynamic = true` must be set.
|
|||||||
16 | | struct CustomMetrics3;
|
16 | | struct CustomMetrics3;
|
||||||
| |______________________^
|
| |______________________^
|
||||||
|
|
||||||
error: expected literal
|
error: Either `scope = ..` or `dynamic = true` must be set.
|
||||||
--> tests/compile-fail/metrics_attr.rs:19:19
|
--> tests/compile-fail/metrics_attr.rs:19:1
|
||||||
|
|
|
|
||||||
19 | #[metrics(scope = value)]
|
19 | / #[metrics(scope = value)]
|
||||||
| ^^^^^
|
20 | | struct CustomMetrics4;
|
||||||
|
| |______________________^
|
||||||
|
|
||||||
error: Value **must** be a string literal.
|
error: Value **must** be a string literal.
|
||||||
--> tests/compile-fail/metrics_attr.rs:23:19
|
--> tests/compile-fail/metrics_attr.rs:23:19
|
||||||
@ -41,11 +42,12 @@ error: Duplicate `scope` value provided.
|
|||||||
31 | #[metrics(scope = "some_scope", scope = "another_scope")]
|
31 | #[metrics(scope = "some_scope", scope = "another_scope")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: expected literal
|
error: Either `scope = ..` or `dynamic = true` must be set.
|
||||||
--> tests/compile-fail/metrics_attr.rs:35:23
|
--> tests/compile-fail/metrics_attr.rs:35:1
|
||||||
|
|
|
|
||||||
35 | #[metrics(separator = value)]
|
35 | / #[metrics(separator = value)]
|
||||||
| ^^^^^
|
36 | | struct CustomMetrics8;
|
||||||
|
| |______________________^
|
||||||
|
|
||||||
error: Value **must** be a string literal.
|
error: Value **must** be a string literal.
|
||||||
--> tests/compile-fail/metrics_attr.rs:39:23
|
--> tests/compile-fail/metrics_attr.rs:39:23
|
||||||
|
|||||||
@ -10,6 +10,6 @@ repository = "https://github.com/paradigmxyz/reth"
|
|||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
syn = "1"
|
syn = "2"
|
||||||
quote = "1"
|
quote = "1"
|
||||||
proc-macro2 = "1"
|
proc-macro2 = "1"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use syn::{Attribute, DataStruct, Error, Field, Meta, NestedMeta, Result, Type, TypePath};
|
use syn::{Attribute, DataStruct, Error, Field, Meta, Result, Type, TypePath};
|
||||||
|
|
||||||
pub(crate) const EMPTY_STRING_CODE: u8 = 0x80;
|
pub(crate) const EMPTY_STRING_CODE: u8 = 0x80;
|
||||||
|
|
||||||
@ -19,18 +19,21 @@ pub(crate) fn parse_struct<'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn attributes_include(attrs: &[Attribute], attr_name: &str) -> bool {
|
pub(crate) fn attributes_include(attrs: &[Attribute], attr_name: &str) -> bool {
|
||||||
attrs.iter().any(|attr| {
|
for attr in attrs.iter() {
|
||||||
if attr.path.is_ident("rlp") {
|
if attr.path().is_ident("rlp") {
|
||||||
if let Ok(Meta::List(meta)) = attr.parse_meta() {
|
if let Meta::List(meta) = &attr.meta {
|
||||||
if let Some(NestedMeta::Meta(meta)) = meta.nested.first() {
|
let mut is_attr = false;
|
||||||
return meta.path().is_ident(attr_name)
|
let _ = meta.parse_nested_meta(|meta| {
|
||||||
|
is_attr = meta.path.is_ident(attr_name);
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
|
if is_attr {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false
|
}
|
||||||
})
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn is_optional(field: &Field) -> bool {
|
pub(crate) fn is_optional(field: &Field) -> bool {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ proc-macro = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0.47"
|
proc-macro2 = "1.0.47"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = { version = "1.0", features = ["full"] }
|
syn = { version = "2.0", features = ["full"] }
|
||||||
convert_case = "0.6.0"
|
convert_case = "0.6.0"
|
||||||
|
|
||||||
# codecs
|
# codecs
|
||||||
|
|||||||
@ -119,7 +119,7 @@ fn load_field(field: &syn::Field, fields: &mut FieldList, is_enum: bool) {
|
|||||||
} else {
|
} else {
|
||||||
let should_compact = is_flag_type(&ftype) ||
|
let should_compact = is_flag_type(&ftype) ||
|
||||||
field.attrs.iter().any(|attr| {
|
field.attrs.iter().any(|attr| {
|
||||||
attr.path.segments.iter().any(|path| path.ident == "maybe_zero")
|
attr.path().segments.iter().any(|path| path.ident == "maybe_zero")
|
||||||
});
|
});
|
||||||
|
|
||||||
fields.push(FieldTypes::StructField((
|
fields.push(FieldTypes::StructField((
|
||||||
|
|||||||
Reference in New Issue
Block a user