From 2ce213674477216def4fd647a36f1e7d509da753 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 24 Nov 2021 09:16:01 +0100 Subject: [PATCH] sortable-macro: drop anyhow dependency Signed-off-by: Wolfgang Bumiller --- proxmox-sortable-macro/Cargo.toml | 1 - proxmox-sortable-macro/src/lib.rs | 18 +++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/proxmox-sortable-macro/Cargo.toml b/proxmox-sortable-macro/Cargo.toml index 1ee42faf..80926464 100644 --- a/proxmox-sortable-macro/Cargo.toml +++ b/proxmox-sortable-macro/Cargo.toml @@ -12,7 +12,6 @@ exclude = [ "debian" ] proc-macro = true [dependencies] -anyhow = "1.0" proc-macro2 = "1.0" quote = "1.0" syn = { version = "1.0", features = [ "full", "visit-mut" ] } diff --git a/proxmox-sortable-macro/src/lib.rs b/proxmox-sortable-macro/src/lib.rs index edf28125..7a5ae45e 100644 --- a/proxmox-sortable-macro/src/lib.rs +++ b/proxmox-sortable-macro/src/lib.rs @@ -4,18 +4,17 @@ extern crate proc_macro2; use std::iter::FromIterator; use std::mem; -use anyhow::Error; - use proc_macro::TokenStream as TokenStream_1; use proc_macro2::TokenStream; use quote::quote; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::visit_mut::VisitMut; +use syn::Error; macro_rules! format_err { - ($span:expr => $($msg:tt)*) => { syn::Error::new_spanned($span, format!($($msg)*)) }; - ($span:expr, $($msg:tt)*) => { syn::Error::new($span, format!($($msg)*)) }; + ($span:expr => $($msg:tt)*) => { Error::new_spanned($span, format!($($msg)*)) }; + ($span:expr, $($msg:tt)*) => { Error::new($span, format!($($msg)*)) }; } //macro_rules! bail { @@ -26,13 +25,10 @@ macro_rules! format_err { fn handle_error(mut item: TokenStream, data: Result) -> TokenStream { match data { Ok(output) => output, - Err(err) => match err.downcast::() { - Ok(err) => { - item.extend(err.to_compile_error()); - item - } - Err(err) => panic!("error in sortable macro: {}", err), - }, + Err(err) => { + item.extend(err.to_compile_error()); + item + } } }