diff --git a/Cargo.toml b/Cargo.toml index 97d2757..5323b5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,11 +29,7 @@ quote = "1.0" enum-utils-from-str = { path = "from-str", version = "0.1.2" } serde_derive_internals = "0.25" syn = { version = "1.0", features = ["extra-traits"] } - -[dependencies.failure] -version = "0.1" -default-features = false -features = ["std"] +anyhow = "1.0" [dev-dependencies] version-sync = "0.8" diff --git a/src/attr.rs b/src/attr.rs index 3ade193..422cfdd 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -2,7 +2,7 @@ use std::collections::{BTreeSet, LinkedList}; use std::convert::{TryFrom, TryInto}; use std::fmt; -use failure::{bail, format_err, Fallible}; +use anyhow::{bail, format_err, Result}; #[derive(Debug, Clone, Copy)] pub enum Primitive { @@ -68,7 +68,7 @@ impl Primitive { } pub fn parse_primitive_repr<'a>(attrs: impl 'a + Iterator) - -> Fallible> + -> Result> { let mut repr = None; for attr in attrs { @@ -117,13 +117,13 @@ impl fmt::Debug for RenameRule { } } -pub type ErrorList = LinkedList; +pub type ErrorList = LinkedList; macro_rules! bail_list { ($msg:literal $( , $args:expr )* $(,)?) => { { let mut list = ErrorList::new(); - list.push_back(failure::format_err!($msg, $($args),*)); + list.push_back(anyhow::format_err!($msg, $($args),*)); return Err(list); } } @@ -139,7 +139,7 @@ pub enum Attr { } impl Attr { - pub fn parse_attrs(attr: &syn::Attribute) -> impl Iterator> { + pub fn parse_attrs(attr: &syn::Attribute) -> impl Iterator> { use syn::NestedMeta; Self::get_args(attr) @@ -167,7 +167,7 @@ impl Attr { /// Parse an attr from the `syn::Meta` inside parens after "enumeration". impl TryFrom<&'_ syn::Meta> for Attr { - type Error = failure::Error; + type Error = anyhow::Error; fn try_from(meta: &syn::Meta) -> Result { use syn::{Lit, Meta, MetaNameValue}; @@ -217,7 +217,7 @@ pub struct VariantAttrs { impl VariantAttrs { pub fn from_attrs(attrs: T) -> Result - where T: IntoIterator>, + where T: IntoIterator>, { let mut ret = VariantAttrs::default(); let mut errors = ErrorList::default(); @@ -258,7 +258,7 @@ pub struct EnumAttrs { impl EnumAttrs { pub fn from_attrs(attrs: T) -> Result - where T: IntoIterator>, + where T: IntoIterator>, { let mut ret = EnumAttrs::default(); let mut errors = ErrorList::default(); @@ -295,7 +295,7 @@ pub struct Enum<'a> { /// This will be `None` if no `#[repr]` was specified, or an error if parsing failed or /// multiple `#[repr]`s were specified. - pub primitive_repr: Fallible>, + pub primitive_repr: Result>, pub variants: Vec<(&'a syn::Variant, VariantAttrs)>, diff --git a/src/conv.rs b/src/conv.rs index 86467cd..d4e3020 100644 --- a/src/conv.rs +++ b/src/conv.rs @@ -1,4 +1,4 @@ -use failure::format_err; +use anyhow::format_err; use proc_macro2::{TokenStream, Span}; use quote::quote; diff --git a/src/from_str.rs b/src/from_str.rs index 38f3b15..f010801 100644 --- a/src/from_str.rs +++ b/src/from_str.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use failure::format_err; +use anyhow::format_err; use proc_macro2::TokenStream; use quote::quote; diff --git a/src/iter.rs b/src/iter.rs index 2e03230..f5f5852 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -1,6 +1,6 @@ use std::ops::{Range, RangeInclusive}; -use failure::format_err; +use anyhow::format_err; use proc_macro2::{Literal, TokenStream}; use quote::quote;