Skip to content

Commit

Permalink
chore: use proc-macro-error2
Browse files Browse the repository at this point in the history
The `proc-macro-error` crate is deprecated, hence use `proc-macro-error2`
instead.

Closes #370.
  • Loading branch information
vmx committed Sep 30, 2024
1 parent b321afc commit b83603e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion derive-impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ proc-macro = true
[dependencies]
proc-macro2 = { version = "1.0.24", features = ["span-locations"] }
proc-macro-crate = "3.1.0"
proc-macro-error = "1.0.4"
proc-macro-error2 = "2.0.1"
quote = "1.0.7"
syn = "2.0.66"
synstructure = "0.13.1"
4 changes: 1 addition & 3 deletions derive-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
//! For example, the actual trait that we are deriving `MultihashDigest`, as well as the `Hasher` trait and
//! the `UnsupportedCode` error type.
extern crate proc_macro;

mod multihash;
mod utils;

use proc_macro::TokenStream;
use proc_macro_error::proc_macro_error;
use proc_macro_error2::proc_macro_error;
use synstructure::macros::{parse, DeriveInput};
use synstructure::{MacroResult, Structure};

Expand Down
8 changes: 4 additions & 4 deletions derive-impl/src/multihash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ impl<'a> From<&'a VariantInfo<'a>> for Hash {
#[cfg(test)]
panic!("{}", msg);
#[cfg(not(test))]
proc_macro_error::abort!(ident, msg);
proc_macro_error2::abort!(ident, msg);
});
let hasher = hasher.unwrap_or_else(|| {
let msg = "Missing hasher attribute: e.g. #[mh(hasher = multihash::Sha2_256)]";
#[cfg(test)]
panic!("{}", msg);
#[cfg(not(test))]
proc_macro_error::abort!(ident, msg);
proc_macro_error2::abort!(ident, msg);
});
Self {
ident,
Expand Down Expand Up @@ -156,7 +156,7 @@ fn parse_code_enum_attrs(ast: &syn::DeriveInput) -> syn::LitInt {
#[cfg(test)]
panic!("{}", msg);
#[cfg(not(test))]
proc_macro_error::abort!(&ast.ident, msg);
proc_macro_error2::abort!(&ast.ident, msg);
}
}
}
Expand Down Expand Up @@ -184,7 +184,7 @@ fn error_code_duplicates(hashes: &[Hash]) {
{
let already_defined = uniq.get(code).unwrap();
let line = already_defined.to_token_stream().span().start().line;
proc_macro_error::emit_error!(
proc_macro_error2::emit_error!(
&hash.code, msg;
note = "previous definition of `{}` at line {}", quote!(#code), line;
);
Expand Down

0 comments on commit b83603e

Please sign in to comment.