diff --git a/Cargo.toml b/Cargo.toml index fcf560a..b62409e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ implementing custom derives. """ license = "MIT" readme = "README.md" +edition = "2018" exclude = ["/.travis.yml", "/publish.sh", "/.github/**"] [badges] @@ -20,9 +21,9 @@ darling_core = { version = "=0.12.4", path = "core" } darling_macro = { version = "=0.12.4", path = "macro" } [dev-dependencies] -proc-macro2 = "1" -quote = "1" -syn = "1" +proc-macro2 = "1.0.26" +quote = "1.0.9" +syn = "1.0.69" [features] default = ["suggestions"] diff --git a/core/Cargo.toml b/core/Cargo.toml index 047dac3..84be1f9 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -8,15 +8,16 @@ Helper crate for proc-macro library for reading attributes into structs when implementing custom derives. Use https://crates.io/crates/darling in your code. """ license = "MIT" +edition = "2018" [features] diagnostics = [] suggestions = ["strsim"] [dependencies] -ident_case = "1.0.0" -proc-macro2 = "1" -quote = "1" -syn = { version = "1.0.1", features = ["full", "extra-traits"] } -fnv = "1.0.6" +ident_case = "1.0.1" +proc-macro2 = "1.0.26" +quote = "1.0.9" +syn = { version = "1.0.69", features = ["full", "extra-traits"] } +fnv = "1.0.7" strsim = { version = "0.10.0", optional = true } diff --git a/core/src/ast/data.rs b/core/src/ast/data.rs index c31fe14..c2b4f7c 100644 --- a/core/src/ast/data.rs +++ b/core/src/ast/data.rs @@ -4,10 +4,10 @@ use proc_macro2::{Span, TokenStream}; use quote::ToTokens; use syn::spanned::Spanned; -use usage::{ +use crate::usage::{ self, IdentRefSet, IdentSet, LifetimeRefSet, LifetimeSet, UsesLifetimes, UsesTypeParams, }; -use {Error, FromField, FromVariant, Result}; +use crate::{Error, FromField, FromVariant, Result}; /// A struct or enum body. /// diff --git a/core/src/ast/generics.rs b/core/src/ast/generics.rs index 2619993..ea2fc72 100644 --- a/core/src/ast/generics.rs +++ b/core/src/ast/generics.rs @@ -3,9 +3,7 @@ use std::iter::Iterator; use std::slice::Iter; -use syn; - -use {FromGenericParam, FromGenerics, FromTypeParam, Result}; +use crate::{FromGenericParam, FromGenerics, FromTypeParam, Result}; /// Extension trait for `GenericParam` to support getting values by variant. /// @@ -179,10 +177,8 @@ impl<'a, P: GenericParamExt> Iterator for TypeParams<'a, P> { #[cfg(test)] mod tests { - use syn; - use super::{GenericParam, Generics}; - use FromGenerics; + use crate::FromGenerics; #[test] fn generics() { diff --git a/core/src/codegen/attr_extractor.rs b/core/src/codegen/attr_extractor.rs index 8049e3a..a9b8715 100644 --- a/core/src/codegen/attr_extractor.rs +++ b/core/src/codegen/attr_extractor.rs @@ -1,7 +1,7 @@ use proc_macro2::TokenStream; -use options::ForwardAttrs; -use util::PathList; +use crate::options::ForwardAttrs; +use crate::util::PathList; /// Infrastructure for generating an attribute extractor. pub trait ExtractAttribute { diff --git a/core/src/codegen/field.rs b/core/src/codegen/field.rs index 4aefd05..6256b24 100644 --- a/core/src/codegen/field.rs +++ b/core/src/codegen/field.rs @@ -4,8 +4,8 @@ use proc_macro2::TokenStream; use quote::{ToTokens, TokenStreamExt}; use syn::{Ident, Path, Type}; -use codegen::{DefaultExpression, PostfixTransform}; -use usage::{self, IdentRefSet, IdentSet, UsesTypeParams}; +use crate::codegen::{DefaultExpression, PostfixTransform}; +use crate::usage::{self, IdentRefSet, IdentSet, UsesTypeParams}; /// Properties needed to generate code for a field in all the contexts /// where one may appear. diff --git a/core/src/codegen/from_derive_impl.rs b/core/src/codegen/from_derive_impl.rs index 2e45165..d21d791 100644 --- a/core/src/codegen/from_derive_impl.rs +++ b/core/src/codegen/from_derive_impl.rs @@ -1,11 +1,13 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use syn::{self, Ident}; - -use ast::Data; -use codegen::{ExtractAttribute, OuterFromImpl, TraitImpl}; -use options::{ForwardAttrs, Shape}; -use util::PathList; +use syn::Ident; + +use crate::{ + ast::Data, + codegen::{ExtractAttribute, OuterFromImpl, TraitImpl}, + options::{ForwardAttrs, Shape}, + util::PathList, +}; pub struct FromDeriveInputImpl<'a> { pub ident: Option<&'a Ident>, diff --git a/core/src/codegen/from_field.rs b/core/src/codegen/from_field.rs index b2ee586..8b27280 100644 --- a/core/src/codegen/from_field.rs +++ b/core/src/codegen/from_field.rs @@ -1,10 +1,12 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use syn::{self, Ident}; +use syn::Ident; -use codegen::{ExtractAttribute, OuterFromImpl, TraitImpl}; -use options::ForwardAttrs; -use util::PathList; +use crate::{ + codegen::{ExtractAttribute, OuterFromImpl, TraitImpl}, + options::ForwardAttrs, + util::PathList, +}; /// `impl FromField` generator. This is used for parsing an individual /// field and its attributes. diff --git a/core/src/codegen/from_meta_impl.rs b/core/src/codegen/from_meta_impl.rs index 191c5a8..a66de7b 100644 --- a/core/src/codegen/from_meta_impl.rs +++ b/core/src/codegen/from_meta_impl.rs @@ -1,9 +1,8 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use syn; -use ast::{Data, Fields, Style}; -use codegen::{Field, OuterFromImpl, TraitImpl, Variant}; +use crate::ast::{Data, Fields, Style}; +use crate::codegen::{Field, OuterFromImpl, TraitImpl, Variant}; pub struct FromMetaImpl<'a> { pub base: TraitImpl<'a>, diff --git a/core/src/codegen/from_type_param.rs b/core/src/codegen/from_type_param.rs index 5b53be6..26d1009 100644 --- a/core/src/codegen/from_type_param.rs +++ b/core/src/codegen/from_type_param.rs @@ -1,10 +1,10 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use syn::{self, Ident}; +use syn::Ident; -use codegen::{ExtractAttribute, OuterFromImpl, TraitImpl}; -use options::ForwardAttrs; -use util::PathList; +use crate::codegen::{ExtractAttribute, OuterFromImpl, TraitImpl}; +use crate::options::ForwardAttrs; +use crate::util::PathList; pub struct FromTypeParamImpl<'a> { pub base: TraitImpl<'a>, diff --git a/core/src/codegen/from_variant_impl.rs b/core/src/codegen/from_variant_impl.rs index 4ad3441..3880bc8 100644 --- a/core/src/codegen/from_variant_impl.rs +++ b/core/src/codegen/from_variant_impl.rs @@ -1,10 +1,10 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use syn::{self, Ident}; +use syn::Ident; -use codegen::{ExtractAttribute, OuterFromImpl, TraitImpl}; -use options::{DataShape, ForwardAttrs}; -use util::PathList; +use crate::codegen::{ExtractAttribute, OuterFromImpl, TraitImpl}; +use crate::options::{DataShape, ForwardAttrs}; +use crate::util::PathList; pub struct FromVariantImpl<'a> { pub base: TraitImpl<'a>, diff --git a/core/src/codegen/mod.rs b/core/src/codegen/mod.rs index ef2f2a1..20c9bbb 100644 --- a/core/src/codegen/mod.rs +++ b/core/src/codegen/mod.rs @@ -13,7 +13,7 @@ mod trait_impl; mod variant; mod variant_data; -pub(in codegen) use self::attr_extractor::ExtractAttribute; +pub(in crate::codegen) use self::attr_extractor::ExtractAttribute; pub use self::default_expr::DefaultExpression; pub use self::field::Field; pub use self::from_derive_impl::FromDeriveInputImpl; diff --git a/core/src/codegen/outer_from_impl.rs b/core/src/codegen/outer_from_impl.rs index dbb5579..29d792c 100644 --- a/core/src/codegen/outer_from_impl.rs +++ b/core/src/codegen/outer_from_impl.rs @@ -2,8 +2,8 @@ use proc_macro2::TokenStream; use quote::{ToTokens, TokenStreamExt}; use syn::{GenericParam, Generics, Path, TraitBound, TraitBoundModifier, TypeParamBound}; -use codegen::TraitImpl; -use usage::IdentSet; +use crate::codegen::TraitImpl; +use crate::usage::IdentSet; /// Wrapper for "outer From" traits, such as `FromDeriveInput`, `FromVariant`, and `FromField`. pub trait OuterFromImpl<'a> { diff --git a/core/src/codegen/trait_impl.rs b/core/src/codegen/trait_impl.rs index 78b8a82..1566426 100644 --- a/core/src/codegen/trait_impl.rs +++ b/core/src/codegen/trait_impl.rs @@ -1,11 +1,12 @@ use proc_macro2::TokenStream; use syn::{Generics, Ident, WherePredicate}; -use ast::{Data, Fields}; -use codegen::error::{ErrorCheck, ErrorDeclaration}; -use codegen::field; -use codegen::{DefaultExpression, Field, FieldsGen, PostfixTransform, Variant}; -use usage::{CollectTypeParams, IdentSet, Purpose}; +use crate::ast::{Data, Fields}; +use crate::codegen::{ + error::{ErrorCheck, ErrorDeclaration}, + field, DefaultExpression, Field, FieldsGen, PostfixTransform, Variant, +}; +use crate::usage::{CollectTypeParams, IdentSet, Purpose}; #[derive(Debug)] pub struct TraitImpl<'a> { @@ -86,7 +87,7 @@ impl<'a> TraitImpl<'a> { } /// Generate local variable declarations for all fields. - pub(in codegen) fn local_declarations(&self) -> TokenStream { + pub(in crate::codegen) fn local_declarations(&self) -> TokenStream { if let Data::Struct(ref vd) = self.data { let vdr = vd.as_ref().map(Field::as_declaration); let decls = vdr.fields.as_slice(); @@ -97,7 +98,7 @@ impl<'a> TraitImpl<'a> { } /// Generate immutable variable declarations for all fields. - pub(in codegen) fn immutable_declarations(&self) -> TokenStream { + pub(in crate::codegen) fn immutable_declarations(&self) -> TokenStream { if let Data::Struct(ref vd) = self.data { let vdr = vd.as_ref().map(|f| field::Declaration::new(f, false)); let decls = vdr.fields.as_slice(); @@ -107,12 +108,12 @@ impl<'a> TraitImpl<'a> { } } - pub(in codegen) fn post_transform_call(&self) -> Option { + pub(in crate::codegen) fn post_transform_call(&self) -> Option { self.post_transform.map(|pt| quote!(#pt)) } /// Generate local variable declaration and initialization for instance from which missing fields will be taken. - pub(in codegen) fn fallback_decl(&self) -> TokenStream { + pub(in crate::codegen) fn fallback_decl(&self) -> TokenStream { let default = self.default.as_ref().map(DefaultExpression::as_declaration); quote!(#default) } @@ -127,12 +128,12 @@ impl<'a> TraitImpl<'a> { } } - pub(in codegen) fn initializers(&self) -> TokenStream { + pub(in crate::codegen) fn initializers(&self) -> TokenStream { self.make_field_ctx().initializers() } /// Generate the loop which walks meta items looking for property matches. - pub(in codegen) fn core_loop(&self) -> TokenStream { + pub(in crate::codegen) fn core_loop(&self) -> TokenStream { self.make_field_ctx().core_loop() } diff --git a/core/src/codegen/variant.rs b/core/src/codegen/variant.rs index e982a2e..783b118 100644 --- a/core/src/codegen/variant.rs +++ b/core/src/codegen/variant.rs @@ -4,10 +4,10 @@ use proc_macro2::TokenStream; use quote::{ToTokens, TokenStreamExt}; use syn::Ident; -use ast::Fields; -use codegen::error::{ErrorCheck, ErrorDeclaration}; -use codegen::{Field, FieldsGen}; -use usage::{self, IdentRefSet, IdentSet, UsesTypeParams}; +use crate::ast::Fields; +use crate::codegen::error::{ErrorCheck, ErrorDeclaration}; +use crate::codegen::{Field, FieldsGen}; +use crate::usage::{self, IdentRefSet, IdentSet, UsesTypeParams}; /// A variant of the enum which is deriving `FromMeta`. #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/core/src/codegen/variant_data.rs b/core/src/codegen/variant_data.rs index 4817e38..9e57408 100644 --- a/core/src/codegen/variant_data.rs +++ b/core/src/codegen/variant_data.rs @@ -1,8 +1,7 @@ use proc_macro2::TokenStream; -use ast::Fields; -use ast::Style; -use codegen::Field; +use crate::ast::{Fields, Style}; +use crate::codegen::Field; pub struct FieldsGen<'a> { fields: &'a Fields>, @@ -18,7 +17,7 @@ impl<'a> FieldsGen<'a> { } /// Create declarations for all the fields in the struct. - pub(in codegen) fn declarations(&self) -> TokenStream { + pub(in crate::codegen) fn declarations(&self) -> TokenStream { match *self.fields { Fields { style: Style::Struct, @@ -33,7 +32,7 @@ impl<'a> FieldsGen<'a> { } /// Generate the loop which walks meta items looking for property matches. - pub(in codegen) fn core_loop(&self) -> TokenStream { + pub(in crate::codegen) fn core_loop(&self) -> TokenStream { let arms = self.fields.as_ref().map(Field::as_match); // If we're allowing unknown fields, then handling one is a no-op. @@ -84,7 +83,7 @@ impl<'a> FieldsGen<'a> { } } - pub(in codegen) fn initializers(&self) -> TokenStream { + pub(in crate::codegen) fn initializers(&self) -> TokenStream { let inits = self.fields.as_ref().map(Field::as_initializer); let inits = inits.iter(); diff --git a/core/src/derive.rs b/core/src/derive.rs index 92dce8e..75258a2 100644 --- a/core/src/derive.rs +++ b/core/src/derive.rs @@ -5,7 +5,7 @@ use proc_macro2::TokenStream; use quote::ToTokens; use syn::DeriveInput; -use options; +use crate::options; /// Run an expression which returns a `darling::Result`, then either return the tokenized /// representation of the `Ok` value, or the tokens of the compiler errors in the `Err` case. diff --git a/core/src/error/kind.rs b/core/src/error/kind.rs index 92d4afe..8d7f110 100644 --- a/core/src/error/kind.rs +++ b/core/src/error/kind.rs @@ -1,6 +1,6 @@ use std::fmt; -use error::Error; +use crate::error::Error; type DeriveInputShape = String; type FieldName = String; @@ -10,7 +10,7 @@ type MetaFormat = String; // Don't want to publicly commit to ErrorKind supporting equality yet, but // not having it makes testing very difficult. #[cfg_attr(test, derive(Clone, PartialEq, Eq))] -pub(in error) enum ErrorKind { +pub(in crate::error) enum ErrorKind { /// An arbitrary error message. Custom(String), DuplicateField(FieldName), @@ -108,7 +108,7 @@ impl From for ErrorKind { // Don't want to publicly commit to ErrorKind supporting equality yet, but // not having it makes testing very difficult. #[cfg_attr(test, derive(Clone, PartialEq, Eq))] -pub(in error) struct ErrorUnknownField { +pub(in crate::error) struct ErrorUnknownField { name: String, did_you_mean: Option, } diff --git a/core/src/error/mod.rs b/core/src/error/mod.rs index 10b88e3..565482e 100644 --- a/core/src/error/mod.rs +++ b/core/src/error/mod.rs @@ -74,7 +74,7 @@ fn path_to_string(path: &syn::Path) -> String { /// Error creation functions impl Error { - pub(in error) fn new(kind: ErrorKind) -> Self { + pub(in crate::error) fn new(kind: ErrorKind) -> Self { Error { kind, locations: Vec::new(), diff --git a/core/src/from_derive_input.rs b/core/src/from_derive_input.rs index 740dd08..b5bb86f 100644 --- a/core/src/from_derive_input.rs +++ b/core/src/from_derive_input.rs @@ -1,6 +1,6 @@ use syn::DeriveInput; -use Result; +use crate::Result; /// Creates an instance by parsing an entire proc-macro `derive` input, /// including the, identity, generics, and visibility of the type. diff --git a/core/src/from_field.rs b/core/src/from_field.rs index 074bdc0..7ce4e55 100644 --- a/core/src/from_field.rs +++ b/core/src/from_field.rs @@ -1,6 +1,6 @@ -use syn::{self, Field}; +use syn::Field; -use Result; +use crate::Result; /// Creates an instance by parsing an individual field and its attributes. pub trait FromField: Sized { diff --git a/core/src/from_generic_param.rs b/core/src/from_generic_param.rs index 168600c..757ad76 100644 --- a/core/src/from_generic_param.rs +++ b/core/src/from_generic_param.rs @@ -1,6 +1,4 @@ -use syn; - -use Result; +use crate::Result; /// Creates an instance by parsing a specific `syn::GenericParam`. /// This can be a type param, a lifetime, or a const param. diff --git a/core/src/from_generics.rs b/core/src/from_generics.rs index eb6e5c9..8f68710 100644 --- a/core/src/from_generics.rs +++ b/core/src/from_generics.rs @@ -1,6 +1,6 @@ use syn::Generics; -use Result; +use crate::Result; /// Creates an instance by parsing an entire generics declaration, including the /// `where` clause. diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs index f22b5a9..f5cc4fa 100644 --- a/core/src/from_meta.rs +++ b/core/src/from_meta.rs @@ -7,10 +7,9 @@ use std::rc::Rc; use std::sync::atomic::AtomicBool; use std::sync::Arc; -use ident_case; -use syn::{self, Expr, Lit, Meta, NestedMeta}; +use syn::{Expr, Lit, Meta, NestedMeta}; -use {Error, Result}; +use crate::{Error, Result}; /// Create an instance from an item in an attribute declaration. /// @@ -584,9 +583,8 @@ hash_map!(syn::Path); #[cfg(test)] mod tests { use proc_macro2::TokenStream; - use syn; - use {Error, FromMeta, Result}; + use crate::{Error, FromMeta, Result}; /// parse a string as a syn::Meta instance. fn pm(tokens: TokenStream) -> ::std::result::Result { diff --git a/core/src/from_type_param.rs b/core/src/from_type_param.rs index cc9c5da..bea9796 100644 --- a/core/src/from_type_param.rs +++ b/core/src/from_type_param.rs @@ -1,6 +1,6 @@ -use syn::{self, TypeParam}; +use syn::TypeParam; -use Result; +use crate::Result; /// Creates an instance by parsing an individual type_param and its attributes. pub trait FromTypeParam: Sized { diff --git a/core/src/from_variant.rs b/core/src/from_variant.rs index d4dd5f2..50bf635 100644 --- a/core/src/from_variant.rs +++ b/core/src/from_variant.rs @@ -1,6 +1,6 @@ -use syn::{self, Variant}; +use syn::Variant; -use Result; +use crate::Result; /// Creates an instance from a specified `syn::Variant`. pub trait FromVariant: Sized { diff --git a/core/src/lib.rs b/core/src/lib.rs index 6ce361b..e38d214 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -33,14 +33,14 @@ pub(crate) mod options; pub mod usage; pub mod util; -pub use error::{Error, Result}; -pub use from_derive_input::FromDeriveInput; -pub use from_field::FromField; -pub use from_generic_param::FromGenericParam; -pub use from_generics::FromGenerics; -pub use from_meta::FromMeta; -pub use from_type_param::FromTypeParam; -pub use from_variant::FromVariant; +pub use self::error::{Error, Result}; +pub use self::from_derive_input::FromDeriveInput; +pub use self::from_field::FromField; +pub use self::from_generic_param::FromGenericParam; +pub use self::from_generics::FromGenerics; +pub use self::from_meta::FromMeta; +pub use self::from_type_param::FromTypeParam; +pub use self::from_variant::FromVariant; // Re-export tokenizer #[doc(hidden)] diff --git a/core/src/macros_public.rs b/core/src/macros_public.rs index a3c5cac..c264fcc 100644 --- a/core/src/macros_public.rs +++ b/core/src/macros_public.rs @@ -12,9 +12,7 @@ /// /// ```rust /// # extern crate syn; -/// # -/// # #[macro_use] -/// # extern crate darling_core; +/// # use darling_core::uses_type_params; /// # /// struct MyField { /// ty: syn::Type, diff --git a/core/src/options/core.rs b/core/src/options/core.rs index 43b5260..64bb5c1 100644 --- a/core/src/options/core.rs +++ b/core/src/options/core.rs @@ -1,12 +1,11 @@ use ident_case::RenameRule; -use syn; - -use ast::{Data, Fields, Style}; -use codegen; -use codegen::PostfixTransform; -use options::{DefaultExpression, InputField, InputVariant, ParseAttribute, ParseData}; -use util::Flag; -use {Error, FromMeta, Result}; + +use crate::ast::{Data, Fields, Style}; +use crate::codegen; +use crate::codegen::PostfixTransform; +use crate::options::{DefaultExpression, InputField, InputVariant, ParseAttribute, ParseData}; +use crate::util::Flag; +use crate::{Error, FromMeta, Result}; /// A struct or enum which should have `FromMeta` or `FromDeriveInput` implementations /// generated. diff --git a/core/src/options/forward_attrs.rs b/core/src/options/forward_attrs.rs index eccdb78..c72d009 100644 --- a/core/src/options/forward_attrs.rs +++ b/core/src/options/forward_attrs.rs @@ -1,7 +1,7 @@ use syn::NestedMeta; -use util::PathList; -use {FromMeta, Result}; +use crate::util::PathList; +use crate::{FromMeta, Result}; /// A rule about which attributes to forward to the generated struct. #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/core/src/options/from_derive.rs b/core/src/options/from_derive.rs index 42ed2e1..5507451 100644 --- a/core/src/options/from_derive.rs +++ b/core/src/options/from_derive.rs @@ -1,10 +1,10 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use syn::{self, Ident}; +use syn::Ident; -use codegen::FromDeriveInputImpl; -use options::{OuterFrom, ParseAttribute, ParseData, Shape}; -use {FromMeta, Result}; +use crate::codegen::FromDeriveInputImpl; +use crate::options::{OuterFrom, ParseAttribute, ParseData, Shape}; +use crate::{FromMeta, Result}; #[derive(Debug)] pub struct FdiOptions { diff --git a/core/src/options/from_field.rs b/core/src/options/from_field.rs index e7d9896..fcfab75 100644 --- a/core/src/options/from_field.rs +++ b/core/src/options/from_field.rs @@ -1,10 +1,10 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use syn::{self, Ident}; +use syn::Ident; -use codegen::FromFieldImpl; -use options::{OuterFrom, ParseAttribute, ParseData}; -use Result; +use crate::codegen::FromFieldImpl; +use crate::options::{OuterFrom, ParseAttribute, ParseData}; +use crate::Result; #[derive(Debug)] pub struct FromFieldOptions { diff --git a/core/src/options/from_meta.rs b/core/src/options/from_meta.rs index e497027..18c2bfa 100644 --- a/core/src/options/from_meta.rs +++ b/core/src/options/from_meta.rs @@ -1,10 +1,9 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use syn; -use codegen::FromMetaImpl; -use options::{Core, ParseAttribute, ParseData}; -use Result; +use crate::codegen::FromMetaImpl; +use crate::options::{Core, ParseAttribute, ParseData}; +use crate::Result; pub struct FromMetaOptions { base: Core, diff --git a/core/src/options/from_type_param.rs b/core/src/options/from_type_param.rs index 2dfd2ee..5ab3241 100644 --- a/core/src/options/from_type_param.rs +++ b/core/src/options/from_type_param.rs @@ -1,10 +1,10 @@ use proc_macro2::TokenStream; use quote::ToTokens; -use syn::{self, Ident}; +use syn::Ident; -use codegen::FromTypeParamImpl; -use options::{OuterFrom, ParseAttribute, ParseData}; -use Result; +use crate::codegen::FromTypeParamImpl; +use crate::options::{OuterFrom, ParseAttribute, ParseData}; +use crate::Result; #[derive(Debug)] pub struct FromTypeParamOptions { diff --git a/core/src/options/from_variant.rs b/core/src/options/from_variant.rs index e2e2989..3c6cd51 100644 --- a/core/src/options/from_variant.rs +++ b/core/src/options/from_variant.rs @@ -2,9 +2,9 @@ use proc_macro2::TokenStream; use quote::ToTokens; use syn::{DeriveInput, Field, Ident, Meta}; -use codegen::FromVariantImpl; -use options::{DataShape, OuterFrom, ParseAttribute, ParseData}; -use {FromMeta, Result}; +use crate::codegen::FromVariantImpl; +use crate::options::{DataShape, OuterFrom, ParseAttribute, ParseData}; +use crate::{FromMeta, Result}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct FromVariantOptions { diff --git a/core/src/options/input_field.rs b/core/src/options/input_field.rs index 5402cda..f47d535 100644 --- a/core/src/options/input_field.rs +++ b/core/src/options/input_field.rs @@ -1,10 +1,8 @@ use std::borrow::Cow; -use syn; - -use codegen; -use options::{Core, DefaultExpression, ParseAttribute}; -use {Error, FromMeta, Result}; +use crate::codegen; +use crate::options::{Core, DefaultExpression, ParseAttribute}; +use crate::{Error, FromMeta, Result}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct InputField { diff --git a/core/src/options/input_variant.rs b/core/src/options/input_variant.rs index 08398fe..8ddda48 100644 --- a/core/src/options/input_variant.rs +++ b/core/src/options/input_variant.rs @@ -1,11 +1,9 @@ use std::borrow::Cow; -use syn; - -use ast::Fields; -use codegen; -use options::{Core, InputField, ParseAttribute}; -use {Error, FromMeta, Result}; +use crate::ast::Fields; +use crate::codegen; +use crate::options::{Core, InputField, ParseAttribute}; +use crate::{Error, FromMeta, Result}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct InputVariant { diff --git a/core/src/options/mod.rs b/core/src/options/mod.rs index a884f5a..3956149 100644 --- a/core/src/options/mod.rs +++ b/core/src/options/mod.rs @@ -1,6 +1,4 @@ -use syn; - -use {Error, FromMeta, Result}; +use crate::{Error, FromMeta, Result}; mod core; mod forward_attrs; diff --git a/core/src/options/outer_from.rs b/core/src/options/outer_from.rs index 6c51437..4186461 100644 --- a/core/src/options/outer_from.rs +++ b/core/src/options/outer_from.rs @@ -1,8 +1,8 @@ -use syn::{self, Field, Ident, Meta}; +use syn::{Field, Ident, Meta}; -use options::{Core, DefaultExpression, ForwardAttrs, ParseAttribute, ParseData}; -use util::PathList; -use {FromMeta, Result}; +use crate::options::{Core, DefaultExpression, ForwardAttrs, ParseAttribute, ParseData}; +use crate::util::PathList; +use crate::{FromMeta, Result}; /// Reusable base for `FromDeriveInput`, `FromVariant`, `FromField`, and other top-level /// `From*` traits. diff --git a/core/src/options/shape.rs b/core/src/options/shape.rs index 7a38428..77be9b0 100644 --- a/core/src/options/shape.rs +++ b/core/src/options/shape.rs @@ -5,7 +5,7 @@ use proc_macro2::TokenStream; use quote::{ToTokens, TokenStreamExt}; use syn::{Meta, NestedMeta}; -use {Error, FromMeta, Result}; +use crate::{Error, FromMeta, Result}; /// Receiver struct for shape validation. Shape validation allows a deriving type /// to declare that it only accepts - for example - named structs, or newtype enum @@ -228,10 +228,9 @@ fn match_arm(name: &'static str, is_supported: bool) -> TokenStream { #[cfg(test)] mod tests { use proc_macro2::TokenStream; - use syn; use super::Shape; - use FromMeta; + use crate::FromMeta; /// parse a string as a syn::Meta instance. fn pm(tokens: TokenStream) -> ::std::result::Result { diff --git a/core/src/usage/generics_ext.rs b/core/src/usage/generics_ext.rs index 82af2f5..74e5142 100644 --- a/core/src/usage/generics_ext.rs +++ b/core/src/usage/generics_ext.rs @@ -1,6 +1,6 @@ use syn::Generics; -use usage::{IdentSet, LifetimeSet}; +use crate::usage::{IdentSet, LifetimeSet}; /// Extension trait for pulling specific generics data from a generics AST representation. pub trait GenericsExt { diff --git a/core/src/usage/lifetimes.rs b/core/src/usage/lifetimes.rs index 2a6b441..eb80329 100644 --- a/core/src/usage/lifetimes.rs +++ b/core/src/usage/lifetimes.rs @@ -1,8 +1,8 @@ use fnv::FnvHashSet; use syn::punctuated::Punctuated; -use syn::{self, Lifetime, Type}; +use syn::{Lifetime, Type}; -use usage::Options; +use crate::usage::Options; /// A set of lifetimes. pub type LifetimeSet = FnvHashSet; @@ -282,11 +282,11 @@ impl UsesLifetimes for syn::TypeParamBound { #[cfg(test)] mod tests { use proc_macro2::Span; - use syn::{self, DeriveInput}; + use syn::DeriveInput; use super::UsesLifetimes; - use usage::GenericsExt; - use usage::Purpose::*; + use crate::usage::GenericsExt; + use crate::usage::Purpose::*; #[test] fn struct_named() { diff --git a/core/src/usage/type_params.rs b/core/src/usage/type_params.rs index cf907c9..b504048 100644 --- a/core/src/usage/type_params.rs +++ b/core/src/usage/type_params.rs @@ -1,7 +1,7 @@ use syn::punctuated::Punctuated; -use syn::{self, Ident, Type}; +use syn::{Ident, Type}; -use usage::{IdentRefSet, IdentSet, Options}; +use crate::usage::{IdentRefSet, IdentSet, Options}; /// Searcher for finding type params in a syntax tree. /// This can be used to determine if a given type parameter needs to be bounded in a generated impl. @@ -250,8 +250,8 @@ mod tests { use syn::{DeriveInput, Ident}; use super::UsesTypeParams; - use usage::IdentSet; - use usage::Purpose::*; + use crate::usage::IdentSet; + use crate::usage::Purpose::*; fn ident_set(idents: Vec<&str>) -> IdentSet { idents diff --git a/core/src/util/ident_string.rs b/core/src/util/ident_string.rs index 293610e..12b8c64 100644 --- a/core/src/util/ident_string.rs +++ b/core/src/util/ident_string.rs @@ -5,7 +5,7 @@ use proc_macro2::{Span, TokenStream}; use quote::ToTokens; use syn::{Ident, Meta}; -use {FromMeta, Result}; +use crate::{FromMeta, Result}; /// A wrapper for an `Ident` which also keeps the value as a string. /// diff --git a/core/src/util/ignored.rs b/core/src/util/ignored.rs index 9347fb4..b74acfd 100644 --- a/core/src/util/ignored.rs +++ b/core/src/util/ignored.rs @@ -1,7 +1,5 @@ -use syn; - -use usage::{self, UsesLifetimes, UsesTypeParams}; -use { +use crate::{ + usage::{self, UsesLifetimes, UsesTypeParams}, FromDeriveInput, FromField, FromGenericParam, FromGenerics, FromMeta, FromTypeParam, FromVariant, Result, }; diff --git a/core/src/util/mod.rs b/core/src/util/mod.rs index bb9c13a..f2603e3 100644 --- a/core/src/util/mod.rs +++ b/core/src/util/mod.rs @@ -2,8 +2,7 @@ use std::ops::{BitAnd, BitOr, Deref, Not}; -use syn; -use {FromMeta, Result}; +use crate::{FromMeta, Result}; mod ident_string; mod ignored; diff --git a/core/src/util/over_ride.rs b/core/src/util/over_ride.rs index 5223a02..b4014a9 100644 --- a/core/src/util/over_ride.rs +++ b/core/src/util/over_ride.rs @@ -2,7 +2,7 @@ use std::fmt; use syn::{Lit, NestedMeta}; -use {FromMeta, Result}; +use crate::{FromMeta, Result}; use self::Override::*; @@ -17,10 +17,7 @@ use self::Override::*; /// In a struct collecting input for this attribute, that would be written as: /// /// ```rust,ignore -/// # #[macro_use] -/// # extern crate darling; -/// # extern crate syn; -/// use darling::util::Override; +/// use darling::{util::Override, FromField}; /// #[derive(FromField)] /// #[darling(attributes(darling))] /// pub struct Options { diff --git a/core/src/util/path_list.rs b/core/src/util/path_list.rs index aeb185c..5f3cf7a 100644 --- a/core/src/util/path_list.rs +++ b/core/src/util/path_list.rs @@ -3,7 +3,7 @@ use std::string::ToString; use syn::{Meta, NestedMeta, Path}; -use {Error, FromMeta, Result}; +use crate::{Error, FromMeta, Result}; /// A list of `syn::Path` instances. This type is used to extract a list of paths from an /// attribute. @@ -72,9 +72,9 @@ impl FromMeta for PathList { #[cfg(test)] mod tests { use super::PathList; + use crate::FromMeta; use proc_macro2::TokenStream; use syn::{Attribute, Meta}; - use FromMeta; /// parse a string as a syn::Meta instance. fn pm(tokens: TokenStream) -> ::std::result::Result { diff --git a/core/src/util/spanned_value.rs b/core/src/util/spanned_value.rs index 82daaed..3f658de 100644 --- a/core/src/util/spanned_value.rs +++ b/core/src/util/spanned_value.rs @@ -1,8 +1,8 @@ use proc_macro2::Span; use std::ops::{Deref, DerefMut}; -use syn; use syn::spanned::Spanned; -use { + +use crate::{ FromDeriveInput, FromField, FromGenericParam, FromGenerics, FromMeta, FromTypeParam, FromVariant, Result, }; diff --git a/core/src/util/with_original.rs b/core/src/util/with_original.rs index 42d305e..5aa82f8 100644 --- a/core/src/util/with_original.rs +++ b/core/src/util/with_original.rs @@ -1,6 +1,4 @@ -use syn; - -use { +use crate::{ FromDeriveInput, FromField, FromGenericParam, FromGenerics, FromMeta, FromTypeParam, FromVariant, Result, }; diff --git a/examples/automatic_bounds.rs b/examples/automatic_bounds.rs index 73e236b..8312afe 100644 --- a/examples/automatic_bounds.rs +++ b/examples/automatic_bounds.rs @@ -1,9 +1,4 @@ -#[macro_use] -extern crate darling; - -extern crate syn; - -use darling::FromDeriveInput; +use darling::{FromDeriveInput, FromMeta}; #[derive(FromMeta, PartialEq, Eq, Debug)] enum Volume { diff --git a/examples/consume_fields.rs b/examples/consume_fields.rs index 4f9f21a..339f15b 100644 --- a/examples/consume_fields.rs +++ b/examples/consume_fields.rs @@ -1,16 +1,8 @@ //! This example shows how to do struct and field parsing using darling. -#[macro_use] -extern crate darling; -extern crate proc_macro2; -#[macro_use] -extern crate quote; -extern crate syn; - -use darling::ast; -use darling::FromDeriveInput; +use darling::{ast, FromDeriveInput, FromField, FromMeta}; use proc_macro2::TokenStream; -use quote::ToTokens; +use quote::{quote, ToTokens}; use syn::parse_str; /// A speaking volume. Deriving `FromMeta` will cause this to be usable diff --git a/examples/fallible_read.rs b/examples/fallible_read.rs index 4ebf3c9..850465e 100644 --- a/examples/fallible_read.rs +++ b/examples/fallible_read.rs @@ -5,10 +5,6 @@ //! 1. Using `Result` to attempt a recovery in imperative code //! 1. Using the `map` darling meta-item to post-process a field before returning //! 1. Using the `and_then` darling meta-item to post-process the receiver before returning -#[macro_use] -extern crate darling; - -extern crate syn; use darling::{FromDeriveInput, FromMeta}; use syn::parse_str; diff --git a/examples/supports_struct.rs b/examples/supports_struct.rs index dbf8238..2cd3a15 100644 --- a/examples/supports_struct.rs +++ b/examples/supports_struct.rs @@ -1,9 +1,4 @@ -#[macro_use] -extern crate darling; - -extern crate syn; - -use darling::{ast, util, FromDeriveInput}; +use darling::{ast, util, FromDeriveInput, FromField}; use syn::{Ident, Type}; #[derive(Debug, FromField)] diff --git a/macro/Cargo.toml b/macro/Cargo.toml index f2e6506..740ad1c 100644 --- a/macro/Cargo.toml +++ b/macro/Cargo.toml @@ -8,10 +8,11 @@ Internal support for a proc-macro library for reading attributes into structs wh implementing custom derives. Use https://crates.io/crates/darling in your code. """ license = "MIT" +edition = "2018" [dependencies] -quote = "1" -syn = "1" +quote = "1.0.9" +syn = "1.0.69" darling_core = { version = "=0.12.4", path = "../core" } [lib] diff --git a/macro/src/lib.rs b/macro/src/lib.rs index 629526c..db9edfc 100644 --- a/macro/src/lib.rs +++ b/macro/src/lib.rs @@ -1,12 +1,9 @@ +// This is needed for 1.31.0 to keep compiling extern crate proc_macro; -#[macro_use] -extern crate syn; - -extern crate darling_core; - -use proc_macro::TokenStream; use darling_core::{derive, Error}; +use proc_macro::TokenStream; +use syn::parse_macro_input; #[proc_macro_derive(FromMeta, attributes(darling))] pub fn derive_from_meta(input: TokenStream) -> TokenStream { diff --git a/src/lib.rs b/src/lib.rs index f6df452..94e463f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,7 +65,6 @@ //! |`attrs`|`Vec`|The forwarded attributes from the passed in variant. These are controlled using the `forward_attrs` attribute.| extern crate core; -extern crate darling_core; #[allow(unused_imports)] #[macro_use] diff --git a/tests/accrue_errors.rs b/tests/accrue_errors.rs index 9ae8212..364bebd 100644 --- a/tests/accrue_errors.rs +++ b/tests/accrue_errors.rs @@ -1,15 +1,8 @@ //! These tests verify that multiple errors will be collected up from throughout //! the parsing process and returned correctly to the caller. -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use darling::ast; -use darling::FromDeriveInput; +use darling::{ast, FromDeriveInput, FromField, FromMeta}; +use syn::parse_quote; #[derive(Debug, FromDeriveInput)] #[darling(attributes(accrue))] diff --git a/tests/computed_bound.rs b/tests/computed_bound.rs index 94fd307..abdb102 100644 --- a/tests/computed_bound.rs +++ b/tests/computed_bound.rs @@ -1,8 +1,4 @@ -#[macro_use] -extern crate darling; -extern crate syn; - -use darling::FromDeriveInput; +use darling::{FromDeriveInput, FromMeta}; fn parse(src: &str) -> T { let ast = syn::parse_str(src).unwrap(); diff --git a/tests/custom_bound.rs b/tests/custom_bound.rs index 4266a74..090c28d 100644 --- a/tests/custom_bound.rs +++ b/tests/custom_bound.rs @@ -1,9 +1,7 @@ -#[macro_use] -extern crate darling; -extern crate syn; - use std::ops::Add; +use darling::{FromDeriveInput, FromMeta}; + #[derive(Debug, Clone, FromMeta)] #[darling(bound = "T: FromMeta + Add")] struct Wrapper(pub T); diff --git a/tests/defaults.rs b/tests/defaults.rs index 50579a7..9d04d32 100644 --- a/tests/defaults.rs +++ b/tests/defaults.rs @@ -1,11 +1,5 @@ -#[macro_use] -extern crate darling; -#[macro_use] -extern crate quote; -#[macro_use] -extern crate syn; - use darling::FromDeriveInput; +use syn::parse_quote; mod foo { pub mod bar { diff --git a/tests/enums_newtype.rs b/tests/enums_newtype.rs index 0fd12f0..c2c4ec9 100644 --- a/tests/enums_newtype.rs +++ b/tests/enums_newtype.rs @@ -1,11 +1,5 @@ -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use darling::FromDeriveInput; +use darling::{FromDeriveInput, FromMeta}; +use syn::parse_quote; #[derive(Debug, Default, PartialEq, Eq, FromMeta)] #[darling(default)] diff --git a/tests/enums_struct.rs b/tests/enums_struct.rs index 63ce690..3c1011b 100644 --- a/tests/enums_struct.rs +++ b/tests/enums_struct.rs @@ -1,9 +1,6 @@ //! Test expansion of enums which have struct variants. -#[macro_use] -extern crate darling; -extern crate syn; - +use darling::FromMeta; #[derive(Debug, FromMeta)] #[darling(rename_all = "snake_case")] enum Message { diff --git a/tests/enums_unit.rs b/tests/enums_unit.rs index f9eb23f..34e0135 100644 --- a/tests/enums_unit.rs +++ b/tests/enums_unit.rs @@ -1,8 +1,6 @@ //! Test expansion of enum variants which have no associated data. -#[macro_use] -extern crate darling; -extern crate syn; +use darling::FromMeta; #[derive(Debug, FromMeta)] #[darling(rename_all = "snake_case")] diff --git a/tests/error.rs b/tests/error.rs index edd72eb..b4080a2 100644 --- a/tests/error.rs +++ b/tests/error.rs @@ -1,12 +1,7 @@ //! In case of bad input, parsing should fail. The error should have locations set in derived implementations. -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use darling::FromDeriveInput; + +use darling::{FromDeriveInput, FromMeta}; +use syn::parse_quote; #[derive(Debug, FromMeta)] struct Dolor { diff --git a/tests/from_generics.rs b/tests/from_generics.rs index 1965f4a..259acea 100644 --- a/tests/from_generics.rs +++ b/tests/from_generics.rs @@ -2,13 +2,11 @@ //! These tests assume `FromTypeParam` is working and only look at whether the wrappers for magic //! fields are working as expected. -#[macro_use] -extern crate darling; -extern crate syn; - -use darling::ast::{self, GenericParamExt}; -use darling::util::{Ignored, WithOriginal}; -use darling::{FromDeriveInput, Result}; +use darling::{ + ast::{self, GenericParamExt}, + util::{Ignored, WithOriginal}, + FromDeriveInput, FromTypeParam, Result, +}; #[derive(FromDeriveInput)] #[darling(attributes(lorem))] diff --git a/tests/from_type_param.rs b/tests/from_type_param.rs index adaf34d..86742e0 100644 --- a/tests/from_type_param.rs +++ b/tests/from_type_param.rs @@ -1,12 +1,5 @@ -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - use darling::FromTypeParam; -use syn::{DeriveInput, GenericParam, Ident, TypeParam}; +use syn::{parse_quote, DeriveInput, GenericParam, Ident, TypeParam}; #[darling(attributes(lorem), from_ident)] #[derive(FromTypeParam)] diff --git a/tests/from_type_param_default.rs b/tests/from_type_param_default.rs index eb0ecc7..691823e 100644 --- a/tests/from_type_param_default.rs +++ b/tests/from_type_param_default.rs @@ -1,12 +1,5 @@ -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - use darling::FromTypeParam; -use syn::{DeriveInput, GenericParam, TypeParam}; +use syn::{parse_quote, DeriveInput, GenericParam, TypeParam}; #[darling(attributes(lorem), default)] #[derive(Default, FromTypeParam)] diff --git a/tests/from_variant.rs b/tests/from_variant.rs index a226576..e89b8ff 100644 --- a/tests/from_variant.rs +++ b/tests/from_variant.rs @@ -1,7 +1,3 @@ -#[macro_use] -extern crate darling; -extern crate syn; - use darling::FromVariant; use syn::{spanned::Spanned, Expr, ExprLit, LitInt}; diff --git a/tests/generics.rs b/tests/generics.rs index a83d03e..6978fae 100644 --- a/tests/generics.rs +++ b/tests/generics.rs @@ -1,11 +1,5 @@ -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use darling::FromDeriveInput; +use darling::{FromDeriveInput, FromMeta}; +use syn::parse_quote; #[derive(Debug, Clone, FromMeta)] struct Wrapper(pub T); diff --git a/tests/happy_path.rs b/tests/happy_path.rs index df1bfad..a56aee7 100644 --- a/tests/happy_path.rs +++ b/tests/happy_path.rs @@ -1,11 +1,5 @@ -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use darling::FromDeriveInput; +use darling::{FromDeriveInput, FromMeta}; +use syn::parse_quote; #[derive(Default, FromMeta, PartialEq, Debug)] #[darling(default)] diff --git a/tests/hash_map.rs b/tests/hash_map.rs index 8bc28dd..5d9a011 100644 --- a/tests/hash_map.rs +++ b/tests/hash_map.rs @@ -1,14 +1,7 @@ -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - use std::collections::HashMap; use darling::FromMeta; -use syn::{Attribute, Path}; +use syn::{parse_quote, Attribute, Path}; #[derive(Debug, FromMeta, PartialEq, Eq)] struct MapValue { diff --git a/tests/multiple.rs b/tests/multiple.rs index e705280..b2243e6 100644 --- a/tests/multiple.rs +++ b/tests/multiple.rs @@ -1,11 +1,5 @@ -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use darling::FromDeriveInput; +use darling::{FromDeriveInput, FromMeta}; +use syn::parse_quote; #[derive(FromDeriveInput)] #[darling(attributes(hello))] diff --git a/tests/newtype.rs b/tests/newtype.rs index 5219d9a..10d0238 100644 --- a/tests/newtype.rs +++ b/tests/newtype.rs @@ -1,13 +1,7 @@ //! A newtype struct should be able to derive `FromMeta` if its member implements it. -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use darling::FromDeriveInput; +use darling::{FromDeriveInput, FromMeta}; +use syn::parse_quote; #[derive(Debug, FromMeta, PartialEq, Eq)] struct Lorem(bool); diff --git a/tests/skip.rs b/tests/skip.rs index b4e0f64..1439060 100644 --- a/tests/skip.rs +++ b/tests/skip.rs @@ -1,13 +1,7 @@ //! Test that skipped fields are not read into structs when they appear in input. -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use darling::FromDeriveInput; +use darling::{FromDeriveInput, FromMeta}; +use syn::parse_quote; #[derive(Debug, PartialEq, Eq, FromDeriveInput)] #[darling(attributes(skip_test))] diff --git a/tests/split_declaration.rs b/tests/split_declaration.rs index 6eda1c4..8db11d0 100644 --- a/tests/split_declaration.rs +++ b/tests/split_declaration.rs @@ -1,16 +1,8 @@ //! When input is split across multiple attributes on one element, //! darling should collapse that into one struct. -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use std::string::ToString; - use darling::{Error, FromDeriveInput}; +use syn::parse_quote; #[derive(Debug, FromDeriveInput, PartialEq, Eq)] #[darling(attributes(split))] diff --git a/tests/suggestions.rs b/tests/suggestions.rs index 3499e9e..f66aaec 100644 --- a/tests/suggestions.rs +++ b/tests/suggestions.rs @@ -1,13 +1,7 @@ #![cfg(feature = "suggestions")] -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use darling::FromDeriveInput; +use darling::{FromDeriveInput, FromMeta}; +use syn::parse_quote; #[derive(Debug, FromDeriveInput)] #[darling(attributes(suggest))] diff --git a/tests/supports.rs b/tests/supports.rs index 62c648b..29c097e 100644 --- a/tests/supports.rs +++ b/tests/supports.rs @@ -1,12 +1,4 @@ -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -use darling::ast; -use darling::FromDeriveInput; +use darling::{ast, FromDeriveInput, FromVariant}; #[derive(Debug, FromDeriveInput)] #[darling(attributes(from_variants), supports(enum_any))] @@ -28,7 +20,7 @@ pub struct StructContainer { } mod source { - use syn::DeriveInput; + use syn::{parse_quote, DeriveInput}; pub fn newtype_enum() -> DeriveInput { parse_quote! { diff --git a/tests/unsupported_attributes.rs b/tests/unsupported_attributes.rs index ce26b72..14edf2c 100644 --- a/tests/unsupported_attributes.rs +++ b/tests/unsupported_attributes.rs @@ -1,10 +1,5 @@ -#[macro_use] -extern crate darling; -#[macro_use] -extern crate syn; - use darling::FromDeriveInput; -use syn::{Ident, LitStr, Path}; +use syn::{parse_quote, Ident, LitStr, Path}; #[derive(Debug, FromDeriveInput)] #[darling(supports(struct_unit), attributes(bar))]