Skip to content

Commit

Permalink
refactor: update to proc_macro_error2 (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen authored Sep 6, 2024
1 parent 3310ff2 commit 00e2367
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
26 changes: 9 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tskit-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ proc-macro = true
[dependencies]
syn = { version = "1.0", features = ["derive"] }
quote = "1.0"
proc-macro-error = "1.0.4"
proc-macro-error2 = "2.0"
10 changes: 5 additions & 5 deletions tskit-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,25 @@ fn impl_metadata_roundtrip_macro(ast: &syn::DeriveInput) -> Result<TokenStream,
} else if &serializer == "bincode" {
return Ok(impl_serde_bincode_roundtrip(name));
} else {
proc_macro_error::abort!(serializer, "is not a supported protocol.");
proc_macro_error2::abort!(serializer, "is not a supported protocol.");
}
} else {
proc_macro_error::abort!(attr.path, "is not a supported attribute.");
proc_macro_error2::abort!(attr.path, "is not a supported attribute.");
}
}

proc_macro_error::abort_call_site!("missing [serializer(...)] attribute")
proc_macro_error2::abort_call_site!("missing [serializer(...)] attribute")
}

macro_rules! make_derive_metadata_tag {
($function: ident, $metadatatag: ident) => {
#[proc_macro_error::proc_macro_error]
#[proc_macro_error2::proc_macro_error]
#[proc_macro_derive($metadatatag, attributes(serializer))]
/// Register a type as metadata.
pub fn $function(input: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = match syn::parse(input) {
Ok(ast) => ast,
Err(err) => proc_macro_error::abort!(err),
Err(err) => proc_macro_error2::abort_call_site!(err),
};
let mut roundtrip = impl_metadata_roundtrip_macro(&ast).unwrap();
let name = &ast.ident;
Expand Down

0 comments on commit 00e2367

Please sign in to comment.