- Support
#[darling(with = ...)]
on thedata
field when derivingFromDeriveInput
. This allows the use of simpler receiver types, such as aVec
of enum variants. - Bump version of
proc-macro2
to 1.0.86. - Accept closures for
#[darling(with = ...)]
on fields inFromDeriveInput
,FromMeta
,FromField
, etc. #309
- Add
#[allow(clippy::manual_unwrap_or_default)]
to all generated impls to avoid causing clippy fails in crates usingdarling
#296 - Properly initialize
attrs
magic field in derivedFromAttributes
impls #297
- Allow word-form for newtype enum variants whose only field produces a value when
from_none
is called on their type #249 - Add
FromMeta
impls for thestd::num::NonZero*
types #288 - Fix panic in number
FromMeta
impls when the parsed value is too large for the receiver type #289
- Add
#[darling(with = ...)]
support toattrs
magic field to allow using custom receiver types forattrs
#273
- Add
#[darling(flatten)]
to allow forwarding unknown fields to another struct #146 - Don't suggest names of skipped fields in derived impls #268
- Fix some missing syn invisible group handling in
FromMeta
impls #263 - Fix misleading error message on
Error::unexpected_type
so it no longer implies the type was a literal #264 - Impl
FromMeta
Vec
of literals, e.g.LitStr
#265
- Add
Flag::span
inherent method, asFlag
can no longer implsyn::spanned::Spanned
#242
- Accept bare paths in
#[darling(default = ...)]
#258 - Add
FromMeta
impl forPathBuf
#259 - Improve
FromMeta
implementation for enums #260- Properly implement unit arms in
FromMeta::from_list
to provide a consistent API for heterogeneous enums that include a mix of unit, newtype and struct variants - Add
#[darling(word)]
attribute for unit enum variants (See #63 for details)
- Properly implement unit arms in
- Add
FromMeta
impl foru128
andi128
#243
- Allow darling users to omit quotation marks for paths and idents #236
- Add new util functions for controlling how quotation marks are handled when reading into
Expr
fields #235
- Add
Clone
impl forNestedMeta
#230
- Bump syn to version 2, courtesy of @jonasbb #227
-
Replace all occurrences of syn::NestedMeta with darling::ast::NestedMeta.
-
Replacement for the deprecated AttributeArgs:
// Before
parse_macro_input!(args as AttributeArgs);
// After
match NestedMeta::parse_meta_list(args) {
Ok(v) => v,
Err(e) => {
return TokenStream::from(Error::from(e).write_errors());
}
};
- In GenericParamExt,
LifetimeDef
is nowLifetimeParam
. - In GenericParamExt,
as_lifetime_def
is renamed toas_lifetime_param
. - Flag and SpannedValue no longer implement
syn::spanned::Spanned
. - The MSRV (minimum supported Rust version) is now 1.56, because of syn.
In previous versions of darling
, arbitrary expressions were passed in attributes by wrapping them in quotation marks.
v0.20.0 preserves this behavior for syn::Expr
, but as a result a field expecting a syn::Expr
cannot accept a string literal - it will incorrectly attempt to parse the contents. If this is an issue for you, please add a comment to #229.
- Add support for child diagnostics when
diagnostics
feature enabled #224
- Re-export
syn
fromdarling
to avoid requiring that consuming crates have asyn
dependency. - Change
<SpannedValue<T> as FromMeta>
impl to more precisely capture the value span, as opposed to the span of the entire item. - Add
darling::util::{AsShape, Shape, ShapeSet}
to improve "shape" validation for structs and variants. #222
- Derived impls of
FromMeta
will now error on literals, rather than silently ignoring them. #193 - Don't include property paths in compile errors when spans are available. #203
- Fix a bug where using a trait that accepts
#[darling(attributes(...))]
without specifying any attributes would emit code that did not compile. #183 - Impl
Clone
fordarling::Error
#184 - Impl
From<darling::Error> for syn::Error
#184 - Add
Error::span
andError::explicit_span
methods #184
- BREAKING CHANGE: Remove many trait impls from
util::Flag
. This type had a number of deref and operator impls that made it usable as sort-of-a-boolean. Real-world usage showed this type is more useful if it's able to carry a span for good errors, and that most of those impls were unnecessary. #179 - Remove need for
#[darling(default)]
onOption<T>
andFlag
fields #161 - Improve validation of enum shapes #178
- Bump
proc-macro2
dependency to 1.0.37 #180 - Bump
quote
dependency to 1.0.18 #180 - Bump
syn
dependency to 1.0.91 #180
- Impl
FromMeta
forsyn::Visibility
#173
- Add
error::Accumulator
for dealing with multiple errors #164 - Impl
FromMeta
forsyn::Type
and its variants #172
- Impl
FromMeta
forsyn::ExprPath
#169
- Add
FromAttributes
trait and macro #151
- Update darling to 2018 edition #129
- Error on duplicate fields in
#[darling(...)]
attributes #130 - Impl
Copy
forSpannedValue<T: Copy>
- Add
SpannedValue::map_ref
- Add
and_then
to derive macros fordarling
- Fix
FromMeta
impl forchar
not to panic #126
- Impl
FromMeta
forHashMap<Ident, V>
andHashMap<Path, V>
- Impl
FromMeta
forsyn::ExprArray
#122 - Remove use of
unreachable
fromdarling::ast::Data
#123 - Add
darling::ast::Data::try_empty_from
to avoid panics when trying to read a union body #123
- POSSIBLY BREAKING: Derived impls of
FromDeriveInput
,FromField
,FromVariant
, andFromTypeParam
will now error when encountering an attributedarling
has been asked to parse that isn't a supported shape. Any crates usingdarling
that relied on those attributes being silently ignored could see new errors reported in their dependent crates. #113 - Impl
syn::spanned::Spanned
fordarling::util::SpannedValue
#113 - Add
darling::util::parse_attribute_to_meta_list
to provide useful errors during attribute parsing #113 - Add
impl From<syn::Error> for Error
to losslessly propagatesyn
errors #116
- Bump minor version due to unexpected breaking change #107
- Add
discriminant
magic field when derivingFromVariant
#105
- Bump syn dependency to 1.0.1 #83
- Fix test compilation errors #81
- Bump syn and quote to 1.0 #79
- Increase rust version to 1.31
- Enable "did you mean" suggestions by default
- Make
darling_core::{codegen, options}
private #58 - Fix
Override::as_mut
: #66
- Added "did you mean" suggestions for unknown fields behind the
suggestions
flag #60 - Added
Error::unknown_field_with_alts
to support the suggestion use-case. - Added
ast::Fields::len
andast::Fields::is_empty
methods.
- Accept unquoted positive numeric literals #52
- Add
FromMeta
to thesyn::Lit
enum and its variants - Improve error message for unexpected literal formats to not say "other"
- Use
syn::Error
to provide precise errors beforeproc_macro::Diagnostic
is available - Add
diagnostics
feature flag to toggle between stable and unstable error backends - Attach error information in more contexts
- Add
allow_unknown_fields
to support parsing the same attribute multiple times for different macros #51 - Proc-macro authors will now see better errors in
darling
attributes
- Attach spans to errors in generated trait impls #37
- Attach spans to errors for types with provided bespoke implementations
- Deprecate
set_span
from 0.8.2, as spans should never be broadened after being initially set
- Add spans to errors to make quality warnings and errors easy in darling. This is blocked on diagnostics stabilizing.
- Add
darling::util::SpannedValue
so proc-macro authors can remember position information alongside parsed values.
- Update dependency on
syn
to 0.15 #44. Thanks to @hcpl
- Update dependencies on
syn
andproc-macro2
- Add
util::IdentString
, which acts as an Ident or its string equivalent
- Add support for
Uses*
traits in where predicates
- Add
usage
module for tracking type param and lifetime usage in generic declarations - Don't add
FromMeta
bounds to type parameters only used by skipped fields #40
- Fix an issue where the
syn
update broke shape validation #36
- Renamed
FromMetaItem
toFromMeta
, and renamedfrom_meta_item
method tofrom_meta
- Added dedicated
derive(FromMetaItem)
which panics and redirects users toFromMeta
- Add
ast::Generics
andast::GenericParam
to work with generics in a manner similar toast::Data
- Add
ast::GenericParamExt
to support alternate representations of generic parameters - Add
util::WithOriginal
to get a parsed representation and syn's own struct for a syntax block - Add
FromGenerics
andFromGenericParam
traits (without derive support) - Change generated code for
generics
magic field to invokeFromGenerics
trait during parsing - Add
FromTypeParam
trait #30. Thanks to @upsuper
- Update dependencies on
proc-macro
,quote
, andsyn
#26. Thanks to @hcpl
YANKED
- Derive
Default
ondarling::Ignored
(fixes #25).
- Support proc-macro2/nightly #24. Thanks to @kdy1
- Update
syn
to 0.12 #20. Thanks to @Eijebong - Update
quote
to 0.4 #20. Thanks to @Eijebong - Rename magic field
body
in derivedFromDeriveInput
structs todata
to stay in sync withsyn
- Rename magic field
data
in derivedFromVariant
structs tofields
to stay in sync withsyn
- Update
lazy_static
to 1.0 #15. Thanks to @Eijebong
- Add
impl FromMetaItem
for integer types #15