Skip to content

Commit 04cf132

Browse files
Update to syn 2.0
1 parent 9469f26 commit 04cf132

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

macro/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = "MIT/Apache-2.0"
1212
proc-macro = true
1313

1414
[dependencies]
15-
syn = "1.0"
15+
syn = "2.0"
1616
quote = "1.0"
1717
proc-macro2 = "1.0"
1818
heck = "0.5.0"

macro/src/gen/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,10 @@ fn default_value_to_deserializable_expr(expr: &ir::Expr) -> TokenStream {
419419
fn inner_visibility(outer: &syn::Visibility, span: Span) -> TokenStream {
420420
match outer {
421421
// These visibilities can be used as they are. No adjustment needed.
422-
syn::Visibility::Public(_) | syn::Visibility::Crate(_) => quote_spanned! {span=> #outer },
422+
syn::Visibility::Public(_) => quote_spanned! {span=> #outer },
423+
syn::Visibility::Restricted(r) if r.path.is_ident("crate") && r.in_token.is_none() => {
424+
quote_spanned! {span=> #outer }
425+
},
423426

424427
// The inherited one is relative to the parent module.
425428
syn::Visibility::Inherited => quote_spanned! {span=> pub(super) },

macro/src/parse.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl StructAttrs {
6464
($cond:expr) => {
6565
if $cond {
6666
let msg = format!("duplicate '{keyword}' confique attribute");
67-
return Err(Error::new(attr.tokens.span(), msg));
67+
return Err(Error::new(attr.path().span(), msg));
6868
}
6969
};
7070
}
@@ -214,7 +214,7 @@ impl FieldAttrs {
214214
($cond:expr) => {
215215
if $cond {
216216
let msg = format!("duplicate '{keyword}' confique attribute");
217-
return Err(Error::new(attr.tokens.span(), msg));
217+
return Err(Error::new(attr.path().span(), msg));
218218
}
219219
};
220220
}
@@ -433,9 +433,9 @@ fn parse_eq_value<T: syn::parse::Parse>(input: ParseStream) -> Result<T, Error>
433433
/// strings (in order).
434434
fn extract_doc(attrs: &mut Vec<syn::Attribute>) -> Vec<String> {
435435
extract_attrs(attrs, |attr| {
436-
match attr.parse_meta().ok()? {
436+
match &attr.meta {
437437
syn::Meta::NameValue(syn::MetaNameValue {
438-
lit: syn::Lit::Str(s),
438+
value: syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(s), .. }),
439439
path,
440440
..
441441
}) if path.is_ident("doc") => Some(s.value()),
@@ -447,7 +447,7 @@ fn extract_doc(attrs: &mut Vec<syn::Attribute>) -> Vec<String> {
447447

448448
fn extract_config_attrs(attrs: &mut Vec<syn::Attribute>) -> Vec<syn::Attribute> {
449449
extract_attrs(attrs, |attr| {
450-
if attr.path.is_ident("config") {
450+
if attr.path().is_ident("config") {
451451
// TODO: clone not necessary once we use drain_filter
452452
Some(attr.clone())
453453
} else {

0 commit comments

Comments
 (0)