Skip to content

Commit

Permalink
Update to syn 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasKalbertodt committed Oct 18, 2024
1 parent 9469f26 commit 04cf132
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = "MIT/Apache-2.0"
proc-macro = true

[dependencies]
syn = "1.0"
syn = "2.0"
quote = "1.0"
proc-macro2 = "1.0"
heck = "0.5.0"
5 changes: 4 additions & 1 deletion macro/src/gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ fn default_value_to_deserializable_expr(expr: &ir::Expr) -> TokenStream {
fn inner_visibility(outer: &syn::Visibility, span: Span) -> TokenStream {
match outer {
// These visibilities can be used as they are. No adjustment needed.
syn::Visibility::Public(_) | syn::Visibility::Crate(_) => quote_spanned! {span=> #outer },
syn::Visibility::Public(_) => quote_spanned! {span=> #outer },
syn::Visibility::Restricted(r) if r.path.is_ident("crate") && r.in_token.is_none() => {
quote_spanned! {span=> #outer }
},

// The inherited one is relative to the parent module.
syn::Visibility::Inherited => quote_spanned! {span=> pub(super) },
Expand Down
10 changes: 5 additions & 5 deletions macro/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl StructAttrs {
($cond:expr) => {
if $cond {
let msg = format!("duplicate '{keyword}' confique attribute");
return Err(Error::new(attr.tokens.span(), msg));
return Err(Error::new(attr.path().span(), msg));
}
};
}
Expand Down Expand Up @@ -214,7 +214,7 @@ impl FieldAttrs {
($cond:expr) => {
if $cond {
let msg = format!("duplicate '{keyword}' confique attribute");
return Err(Error::new(attr.tokens.span(), msg));
return Err(Error::new(attr.path().span(), msg));
}
};
}
Expand Down Expand Up @@ -433,9 +433,9 @@ fn parse_eq_value<T: syn::parse::Parse>(input: ParseStream) -> Result<T, Error>
/// strings (in order).
fn extract_doc(attrs: &mut Vec<syn::Attribute>) -> Vec<String> {
extract_attrs(attrs, |attr| {
match attr.parse_meta().ok()? {
match &attr.meta {
syn::Meta::NameValue(syn::MetaNameValue {
lit: syn::Lit::Str(s),
value: syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(s), .. }),
path,
..
}) if path.is_ident("doc") => Some(s.value()),
Expand All @@ -447,7 +447,7 @@ fn extract_doc(attrs: &mut Vec<syn::Attribute>) -> Vec<String> {

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

0 comments on commit 04cf132

Please sign in to comment.