commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
a3f7bb15eaa9220e7a55a1101a4d5e520aa1ed38 | Al Liu | 2025-07-10T18:35:36 | impl `from_list` for `()` (#354)
Co-authored-by: Ted Driggs <ted.driggs@outlook.com> | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index b4feefc..6846f6b 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -162,6 +162,31 @@ impl FromMeta for () {
fn from_word() -> Result<Self> {
Ok(())
}
+
+ fn from_list(items: &[NestedMeta]) -> Result<Self> {
+ l... | 1 | 32 | 0 |
976224595a42ca6c52cd9744a2f8909d40a6b84a | Ted Driggs | 2023-01-11T18:32:53 | Impl UsesTypeParams and UsesLifetimes for WithOriginal
Fixes #215 | diff --git a/core/src/util/with_original.rs b/core/src/util/with_original.rs
index 5aa82f8..7b890f6 100644
--- a/core/src/util/with_original.rs
+++ b/core/src/util/with_original.rs
@@ -1,4 +1,5 @@
use crate::{
+ usage::{UsesLifetimes, UsesTypeParams},
FromDeriveInput, FromField, FromGenericParam, FromGenerics,... | 1 | 23 | 0 |
15be7b32060e5a1a89e4f06ba17709e0f96d68c9 | Ted Driggs | 2025-07-09T13:11:15 | NFC: Replace some `syn` paths with use | diff --git a/core/src/util/callable.rs b/core/src/util/callable.rs
index 50c4101..626bd34 100644
--- a/core/src/util/callable.rs
+++ b/core/src/util/callable.rs
@@ -1,4 +1,5 @@
use quote::ToTokens;
+use syn::{Expr, ExprClosure, ExprLit, ExprPath, Lit, Path};
use crate::{Error, FromMeta, Result};
@@ -15,18 +16,18 ... | 1 | 19 | 19 |
09f6219433501bd5a75c677683d3dba7d42ca8e6 | Ted Driggs | 2025-07-09T12:40:26 | Add test for flatten behavior with multiple errors | diff --git a/tests/flatten.rs b/tests/flatten.rs
index d7c533c..3984bec 100644
--- a/tests/flatten.rs
+++ b/tests/flatten.rs
@@ -164,6 +164,19 @@ fn do_not_suggest_invalid_alts() {
);
}
+#[cfg(feature = "suggestions")]
+#[track_caller]
+fn assert_error_has_suggestion(error: &darling::Error, field: &str) {
+ ... | 1 | 38 | 6 |
766856bc5a2ec744eeb9a5e6f304e39c7bffeb23 | jerryq | 2025-06-30T17:41:36 | Make `syn::TypePath` supports both quote-wrapped and bare values. (#352) | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index ba01b61..b4feefc 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -462,7 +462,6 @@ from_syn_parse!(syn::TypeMacro);
from_syn_parse!(syn::TypeNever);
from_syn_parse!(syn::TypeParam);
from_syn_parse!(syn::TypeParen);
-from_syn_parse!(syn... | 1 | 33 | 1 |
39098b126e5ca69c30d6c6bb92bac8ccf2fe2175 | Techassi | 2025-06-25T13:31:27 | Add optional serde support for IdentString (#341)
* Add optional `serde` dependency
* Move `IdentString` to be a mod
* Add doc comment about (de)serialization of IdentString | diff --git a/Cargo.toml b/Cargo.toml
index d53e1ef..4ad2cec 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,6 +34,7 @@ trybuild = "1.0.89"
default = ["suggestions"]
diagnostics = ["darling_core/diagnostics"]
suggestions = ["darling_core/suggestions"]
+serde = ["darling_core/serde"]
[workspace]
members = ["macro"... | 4 | 65 | 0 |
042aa45987be6245f9b4fad4c5200a73bfcec97b | Al Liu | 2025-06-24T18:06:01 | Support parsing attributes which containing keywords (#348)
* Allow keywords as name in `FromMeta`
* Add more enum unit tests
Fixes #238 | diff --git a/core/src/ast/data.rs b/core/src/ast/data/mod.rs
similarity index 91%
rename from core/src/ast/data.rs
rename to core/src/ast/data/mod.rs
index facc2d4..6e5804b 100644
--- a/core/src/ast/data.rs
+++ b/core/src/ast/data/mod.rs
@@ -2,16 +2,17 @@ use std::{slice, vec};
use proc_macro2::{Span, TokenStream};
... | 3 | 254 | 42 |
e4ae877ad47985f044a79337dd5fb159b90458d6 | Mateusz Maćkowski | 2025-06-06T04:19:11 | Add `PreservedStrExpr` utility wrapper (#346)
* Add `PreservedStrExpr` utility wrapper | diff --git a/core/src/util/mod.rs b/core/src/util/mod.rs
index 107ecd8..1403750 100644
--- a/core/src/util/mod.rs
+++ b/core/src/util/mod.rs
@@ -9,6 +9,7 @@ mod parse_attribute;
pub mod parse_expr;
mod path_list;
mod path_to_string;
+mod preserved_str_expr;
mod shape;
mod spanned_value;
mod with_original;
@@ -21,... | 2 | 66 | 0 |
53ed79dbfceadded56c1a606891b865a946f5c6e | Ted Driggs | 2025-05-19T15:08:51 | Fix some clippy issues | diff --git a/core/src/ast/data.rs b/core/src/ast/data.rs
index d024cad..facc2d4 100644
--- a/core/src/ast/data.rs
+++ b/core/src/ast/data.rs
@@ -414,6 +414,8 @@ impl From<&syn::Fields> for Style {
}
#[derive(Debug, Clone)]
+// Addressing this would break many users of the crate.
+#[allow(clippy::large_enum_variant)... | 5 | 6 | 4 |
2357beb1be0f9bb34217f5064b28aa469a688f32 | Suika | 2025-04-21T20:33:49 | accept string literals as paths in #[darling(with = ...)]
Fixes #338 | diff --git a/core/src/util/callable.rs b/core/src/util/callable.rs
index c726679..50c4101 100644
--- a/core/src/util/callable.rs
+++ b/core/src/util/callable.rs
@@ -24,6 +24,16 @@ impl AsRef<syn::Expr> for Callable {
}
}
+impl From<syn::Path> for Callable {
+ fn from(path: syn::Path) -> Self {
+ Self:... | 2 | 37 | 1 |
f18d5d53883ee62377f2374bfb272b8d67e03754 | Nathan West | 2025-03-04T23:33:24 | Add explicit implementations of `FromMeta` methods to `SpannedValue` and `Override` (#326)
* Add explicit overrides for `Override` so that they work when called directly
* Add explicit implementations of `FromMeta` methods to SpannedValue
Explicit implementations ensure that `SpannedValue` still works when these met... | diff --git a/core/src/util/over_ride.rs b/core/src/util/over_ride.rs
index 620cc5f..1f8113f 100644
--- a/core/src/util/over_ride.rs
+++ b/core/src/util/over_ride.rs
@@ -148,4 +148,16 @@ impl<T: FromMeta> FromMeta for Override<T> {
fn from_value(lit: &Lit) -> Result<Self> {
Ok(Explicit(FromMeta::from_value... | 3 | 142 | 0 |
a6e5f524b234a5694b89549e11f2aed789c9461e | Ted Driggs | 2025-01-22T22:24:17 | Move generation of from_word body for unit variants | diff --git a/core/src/codegen/from_meta_impl.rs b/core/src/codegen/from_meta_impl.rs
index 2d0013f..4c59627 100644
--- a/core/src/codegen/from_meta_impl.rs
+++ b/core/src/codegen/from_meta_impl.rs
@@ -1,3 +1,5 @@
+use std::borrow::Cow;
+
use proc_macro2::TokenStream;
use quote::{quote, quote_spanned, ToTokens};
use ... | 5 | 54 | 27 |
3a848ca2821ee34973f0d7407c1860a57d418f84 | Ted Driggs | 2025-01-22T15:32:29 | Extract path-or-closure to darling::util::Callable
This was previously used within darling_core for `with` fields, but is
more broadly applicable. | diff --git a/core/src/options/input_field.rs b/core/src/options/input_field.rs
index 6569b83..71e843a 100644
--- a/core/src/options/input_field.rs
+++ b/core/src/options/input_field.rs
@@ -4,7 +4,7 @@ use syn::{parse_quote_spanned, spanned::Spanned};
use crate::codegen;
use crate::options::{Core, DefaultExpression,... | 3 | 52 | 25 |
af24bdf87a824eadb365c32441171bf2216ddf6e | Ted Driggs | 2025-01-21T21:27:47 | Reject extra data passed to unit enum variants
- Remove ToTokens impl from Variant to force caller to choose right usage context (e.g. as_data_match_arm)
- Update DataMatchArm to allow unit variants if the value is just a path
- Add test written by @Sufflope to avoid regressions
Fixes #306 | diff --git a/core/src/codegen/from_meta_impl.rs b/core/src/codegen/from_meta_impl.rs
index ec34fbe..d96e639 100644
--- a/core/src/codegen/from_meta_impl.rs
+++ b/core/src/codegen/from_meta_impl.rs
@@ -106,6 +106,8 @@ impl ToTokens for FromMetaImpl<'_> {
))
});
+ ... | 3 | 122 | 13 |
b7a248f8ee4503a949de0730170934587dccfb8e | Ted Driggs | 2024-12-02T22:33:45 | Fix clippy violations by removing unnecessary iifetimes | diff --git a/core/src/ast/data.rs b/core/src/ast/data.rs
index 03036d8..d024cad 100644
--- a/core/src/ast/data.rs
+++ b/core/src/ast/data.rs
@@ -403,7 +403,7 @@ impl From<syn::Fields> for Style {
}
}
-impl<'a> From<&'a syn::Fields> for Style {
+impl From<&syn::Fields> for Style {
fn from(vd: &syn::Fields) ... | 12 | 27 | 27 |
c330c3440bfecf3d556ffa1f03c96c7b7eac416b | Techassi | 2024-08-16T13:24:48 | Add `FromMeta` support for `BTreeMap` (#287)
Co-authored-by: Ted Driggs <ted.driggs@outlook.com> | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index dd3a2b0..0a7869d 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -1,5 +1,6 @@
use std::borrow::Cow;
use std::cell::RefCell;
+use std::collections::btree_map::BTreeMap;
use std::collections::hash_map::HashMap;
use std::collections::Ha... | 1 | 182 | 68 |
ba5457d7685587f880cb01bd449a768b10bf4324 | Ted Driggs | 2024-07-31T19:31:42 | Fix clippy: Allow compiletests cfg | diff --git a/Cargo.toml b/Cargo.toml
index 33bd7d7..05daec2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -37,3 +37,6 @@ suggestions = ["darling_core/suggestions"]
[workspace]
members = ["macro", "core"]
+
+[lints.rust]
+unexpected_cfgs = { level = "warn", check-cfg = ['cfg(compiletests)'] } | 1 | 3 | 0 |
0a24c6f2cdf7f397e33df60df5db9b51e4c79b2e | Ted Driggs | 2024-07-16T15:00:33 | Rename AttrsField to ForwardedField
This provides a reusable primitive for all forwarded fields which should support `with` | diff --git a/core/src/codegen/attrs_field.rs b/core/src/codegen/attrs_field.rs
index 8b21267..fa7c54c 100644
--- a/core/src/codegen/attrs_field.rs
+++ b/core/src/codegen/attrs_field.rs
@@ -1,12 +1,12 @@
use quote::{quote, quote_spanned, ToTokens, TokenStreamExt};
use syn::spanned::Spanned;
-use crate::options::{Att... | 5 | 56 | 54 |
d32836df74a26685d9c8288829d7f3ae561e8b38 | Ted Driggs | 2024-07-09T13:25:02 | Properly forward attrs in FromAttributes
Fixes #295 | diff --git a/core/src/codegen/from_attributes_impl.rs b/core/src/codegen/from_attributes_impl.rs
index 0dc1f25..1e40c26 100644
--- a/core/src/codegen/from_attributes_impl.rs
+++ b/core/src/codegen/from_attributes_impl.rs
@@ -38,6 +38,7 @@ impl ToTokens for FromAttributesImpl<'_> {
}
}
+ l... | 3 | 25 | 1 |
6a057da846ec5693d40ae62a6edbd2fdc3853615 | Ted Driggs | 2024-07-09T12:21:41 | Allow manual_unwrap_or_default in all generated impls | diff --git a/core/src/codegen/outer_from_impl.rs b/core/src/codegen/outer_from_impl.rs
index 79c5c68..5e266ef 100644
--- a/core/src/codegen/outer_from_impl.rs
+++ b/core/src/codegen/outer_from_impl.rs
@@ -28,6 +28,7 @@ pub trait OuterFromImpl<'a> {
tokens.append_all(quote!(
#[automatically_deriv... | 1 | 1 | 0 |
303f12b662033b7674d7f2c4917665ba85558e6d | Ted Driggs | 2024-07-08T15:04:07 | Remove unused bound field from codegen::TraitImpl
Fixes clippy violation | diff --git a/core/src/codegen/trait_impl.rs b/core/src/codegen/trait_impl.rs
index 1fac884..1dab56f 100644
--- a/core/src/codegen/trait_impl.rs
+++ b/core/src/codegen/trait_impl.rs
@@ -1,6 +1,6 @@
use proc_macro2::TokenStream;
use quote::quote;
-use syn::{Generics, Ident, WherePredicate};
+use syn::{Generics, Ident};... | 2 | 1 | 3 |
2d9b0dc59e8fefbc543046b97ca4000860ed8229 | Ted Driggs | 2024-05-13T17:19:36 | NFC: Slightly clean up imports in darling_core::from_meta | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index c37271c..dd3a2b0 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -3,10 +3,7 @@ use std::cell::RefCell;
use std::collections::hash_map::HashMap;
use std::collections::HashSet;
use std::hash::BuildHasher;
-use std::num::{
- NonZeroI1... | 1 | 14 | 17 |
195eccf350431d99abb3edfd9b0f83982d1550a7 | Ted Driggs | 2024-05-13T16:50:52 | Propagate Err from number parsing
Previously, an unwrap was used.
Propagating the error will preserve spans and improve the error message.
This fixes #289 | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 048acb7..c37271c 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -232,7 +232,7 @@ macro_rules! from_meta_num {
fn from_value(value: &Lit) -> Result<Self> {
(match *value {
Lit::Str(ref s... | 1 | 7 | 2 |
ba363b86304c8459dd72d11c7c46a24ad24cc4e0 | Michał Papierski | 2024-05-13T16:39:03 | Add support for non-zero integers. (#288) | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 9bcea00..048acb7 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -3,6 +3,10 @@ use std::cell::RefCell;
use std::collections::hash_map::HashMap;
use std::collections::HashSet;
use std::hash::BuildHasher;
+use std::num::{
+ NonZeroI1... | 1 | 32 | 0 |
e44e043b8b39f72968995b9883b386752e6f2190 | Ted Driggs | 2024-05-13T14:53:54 | Use clone_from to fix clippy violation | diff --git a/core/src/options/from_derive.rs b/core/src/options/from_derive.rs
index eb27641..3f371b3 100644
--- a/core/src/options/from_derive.rs
+++ b/core/src/options/from_derive.rs
@@ -54,15 +54,15 @@ impl ParseData for FdiOptions {
fn parse_field(&mut self, field: &syn::Field) -> Result<()> {
match f... | 5 | 10 | 10 |
78f3d11e76b5f63c47a453daa679956f1507af43 | Martin Geisler | 2024-04-11T12:30:07 | Apply suggestions from code review
Oh, of course! I had the change locally and just transcribed it to the GitHub editor... but not 100% accurately :-D
Co-authored-by: Ted Driggs <ted.driggs@outlook.com> | diff --git a/tests/flatten.rs b/tests/flatten.rs
index e89ce65..d7c533c 100644
--- a/tests/flatten.rs
+++ b/tests/flatten.rs
@@ -165,7 +165,7 @@ fn do_not_suggest_invalid_alts() {
}
#[test]
-#[cfg(features = "suggestions")]
+#[cfg(feature = "suggestions")]
fn suggest_valid_parent_alts() {
let errors = Outer::... | 1 | 1 | 1 |
ce481a976b91e1cfd1c78873dc31fef778376f36 | Martin Geisler | 2024-04-09T11:51:54 | Fix `cargo test --no-default-features`
The suggestion is not given when the `suggestions` Cargo feature is disabled. | diff --git a/tests/flatten.rs b/tests/flatten.rs
index 34e6ae1..e89ce65 100644
--- a/tests/flatten.rs
+++ b/tests/flatten.rs
@@ -165,6 +165,7 @@ fn do_not_suggest_invalid_alts() {
}
#[test]
+#[cfg(features = "suggestions")]
fn suggest_valid_parent_alts() {
let errors = Outer::from_derive_input(&parse_quote! {... | 1 | 1 | 0 |
3e240a6e2d89a4accbf216800ed8515bb2138934 | GnomedDev | 2024-04-01T17:23:15 | Bump strsim version | diff --git a/core/Cargo.toml b/core/Cargo.toml
index d0de17c..2f8497b 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -21,4 +21,4 @@ proc-macro2 = "1.0.37"
quote = "1.0.18"
syn = { version = "2.0.15", features = ["full", "extra-traits"] }
fnv = "1.0.7"
-strsim = { version = "0.10.0", optional = true }
+strsim ... | 1 | 1 | 1 |
b199da73d794b09f8aedcbf789c85805e0c6267a | GnomedDev | 2024-04-02T23:57:08 | Document rust-version in Cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index 1f13ba9..785880b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,6 +11,7 @@ implementing custom derives.
license = "MIT"
readme = "README.md"
edition = "2021"
+rust-version = "1.56"
exclude = ["/.travis.yml", "/publish.sh", "/.github/**"]
[badges]
diff --git a/core/Carg... | 3 | 3 | 0 |
efcab3449d73969e3e539c9c69d398895b4b5506 | GnomedDev | 2024-04-01T20:44:29 | Bump to edition 2021 | diff --git a/Cargo.toml b/Cargo.toml
index c2fe839..1f13ba9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,7 @@ implementing custom derives.
"""
license = "MIT"
readme = "README.md"
-edition = "2018"
+edition = "2021"
exclude = ["/.travis.yml", "/publish.sh", "/.github/**"]
[badges]
diff --git a/core/Carg... | 3 | 3 | 3 |
c21ae617ac1acc0659f2870f2ef39ea986285d43 | GnomedDev | 2024-04-01T20:42:15 | Conform to Rust 2018 Idioms | diff --git a/core/src/ast/data.rs b/core/src/ast/data.rs
index 4b91595..03036d8 100644
--- a/core/src/ast/data.rs
+++ b/core/src/ast/data.rs
@@ -244,7 +244,7 @@ impl<T> Fields<T> {
}
}
- pub fn iter(&self) -> slice::Iter<T> {
+ pub fn iter(&self) -> slice::Iter<'_, T> {
self.fields.iter()... | 19 | 30 | 30 |
cd8360d3c6e881d4ae5b9ed26eb6c9f58e4aa326 | Ted Driggs | 2024-02-27T15:49:01 | Update readme to acknowledge `with = ...` | diff --git a/src/lib.rs b/src/lib.rs
index 657a6ff..458d55a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -38,7 +38,7 @@
//! |`vis`|`syn::Visibility`|The visibility of the passed-in type|
//! |`generics`|`T: darling::FromGenerics`|The generics of the passed-in type. This can be `syn::Generics`, `darling::ast::Generics`... | 1 | 4 | 4 |
3d40677a29de2ca7240e4887481ad1c49bc7705b | Ted Driggs | 2024-02-26T19:26:43 | Forward from_list to inner type in smart pointer FromMeta impls | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 7e50e4e..9bcea00 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -596,63 +596,57 @@ impl<T: FromMeta> FromMeta for Option<T> {
}
}
-impl<T: FromMeta> FromMeta for Box<T> {
- fn from_none() -> Option<Self> {
- T::from_no... | 2 | 57 | 40 |
0b260ccd55f9cbfebbfdd8bff4fc8d5c80946a9b | Ted Driggs | 2024-02-26T19:19:51 | Revert "Forward from_list in smart pointer FromMeta impls"
This reverts commit 549d98e845052ccbe6b70429b089dc66d4fd0595. | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 31e1fe4..7e50e4e 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -596,33 +596,25 @@ impl<T: FromMeta> FromMeta for Option<T> {
}
}
-/// Create an impl that forwards to an inner type `T` for parsing.
-macro_rules! smart_pointer_t ... | 2 | 46 | 47 |
549d98e845052ccbe6b70429b089dc66d4fd0595 | Ted Driggs | 2024-02-26T19:14:07 | Forward from_list in smart pointer FromMeta impls
This enables use of Box, Rc, and more in flatten positions. | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 7e50e4e..31e1fe4 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -596,26 +596,34 @@ impl<T: FromMeta> FromMeta for Option<T> {
}
}
-impl<T: FromMeta> FromMeta for Box<T> {
- fn from_none() -> Option<Self> {
- T::from_no... | 2 | 47 | 46 |
a1fda4d41d79c47db1af8482e593e307f3be7dfd | Ted Driggs | 2024-02-23T15:25:41 | Add Error::unknown_field_path_with_alts | diff --git a/core/src/error/mod.rs b/core/src/error/mod.rs
index 0ebe3a9..3c22d4c 100644
--- a/core/src/error/mod.rs
+++ b/core/src/error/mod.rs
@@ -125,6 +125,17 @@ impl Error {
Error::new(ErrorUnknownField::with_alts(field, alternates).into())
}
+ /// Creates a new error for a field name that appea... | 1 | 11 | 0 |
d8e65cebf6dd578c4a6a5da019295eec011e6b17 | Ted Driggs | 2024-02-22T21:38:04 | Fix flattening to work with 0..n attributes
Fixes #271 | diff --git a/core/src/codegen/field.rs b/core/src/codegen/field.rs
index c17cc90..51020a9 100644
--- a/core/src/codegen/field.rs
+++ b/core/src/codegen/field.rs
@@ -96,6 +96,17 @@ impl<'a> ToTokens for Declaration<'a> {
} else {
quote!(let mut #ident: (bool, ::darling::export::Option<#ty>) = (fals... | 4 | 63 | 31 |
4790d7991b011d5ba4de2808acaf3ab53c506a7c | Ted Driggs | 2024-02-22T17:51:12 | Add test for flattening in FromField | diff --git a/tests/flatten_from_field.rs b/tests/flatten_from_field.rs
new file mode 100644
index 0000000..44eebcf
--- /dev/null
+++ b/tests/flatten_from_field.rs
@@ -0,0 +1,46 @@
+use darling::{ast, util::Ignored, FromDeriveInput, FromField, FromMeta};
+use proc_macro2::{Ident, Span};
+use syn::parse_quote;
+
+#[deriv... | 1 | 46 | 0 |
78ad51228af667eed58915c8ce093e9929083083 | Ted Driggs | 2024-02-22T14:50:53 | Include parents in "did you mean" suggestions
For flattened members, this makes the "did you mean" suggestions accurate and more useful | diff --git a/core/src/codegen/field.rs b/core/src/codegen/field.rs
index 4780b2c..c17cc90 100644
--- a/core/src/codegen/field.rs
+++ b/core/src/codegen/field.rs
@@ -48,8 +48,14 @@ impl<'a> Field<'a> {
Declaration(self)
}
- pub fn as_flatten_initializer(&'a self) -> FlattenInitializer<'a> {
- F... | 5 | 163 | 6 |
4ad0775940fbf5620e0f8905db472cd6eae070c3 | Ted Driggs | 2024-02-22T14:49:37 | Store similarity score in ErrorUnknownField
This will allow cheap comparison against other alternates.
This required dropping the test-only Eq impl, as f64 does not impl Eq. | diff --git a/core/src/error/kind.rs b/core/src/error/kind.rs
index 0351172..98362c0 100644
--- a/core/src/error/kind.rs
+++ b/core/src/error/kind.rs
@@ -9,7 +9,7 @@ type MetaFormat = String;
#[derive(Debug, Clone)]
// Don't want to publicly commit to ErrorKind supporting equality yet, but
// not having it makes test... | 1 | 9 | 9 |
80db5372943a510ef397dbc05a0b925c2c8cc2c0 | Ted Driggs | 2024-02-22T04:26:00 | Add #[automatically_derived]
This addressed some issues of warnings for unread assignments. | diff --git a/core/src/codegen/outer_from_impl.rs b/core/src/codegen/outer_from_impl.rs
index c2939a6..79c5c68 100644
--- a/core/src/codegen/outer_from_impl.rs
+++ b/core/src/codegen/outer_from_impl.rs
@@ -27,6 +27,7 @@ pub trait OuterFromImpl<'a> {
let (impl_generics, ty_generics, where_clause) = generics.spli... | 1 | 1 | 0 |
a43190f6cab0350916c6f3978e1c05926fa5e2c8 | Thomas B | 2024-02-14T20:53:50 | Add FromMeta for Vec of literals(#265)
There is no general implementation for `Vec`, but having the ability to accept a list of literals
and require that they be of the same type is useful enough to merit specific impls.
Co-authored-by: Ted Driggs <ted.driggs@outlook.com> | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 6752059..7e50e4e 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -516,6 +516,33 @@ macro_rules! from_meta_lit {
}
}
}
+
+ impl FromMeta for Vec<$impl_ty> {
+ fn from_list(items: &[... | 1 | 38 | 0 |
db0e40fca933d8b29a40b76f8471390183fff41d | Ted Driggs | 2024-02-13T19:13:34 | Add unit test to confirm negative integer literals work without quotation marks
Fixes #244 | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index cf25e23..6752059 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -842,6 +842,12 @@ mod tests {
assert_eq!(fm::<u32>(quote!(ignore = 5000i32)), 5000u32);
}
+ #[test]
+ fn negative_int_without_quotes() {
+ asse... | 1 | 6 | 0 |
3ee36d90db1ffb623dea70ea22330842d28bec5d | Thomas B | 2024-02-12T20:16:01 | Fix some missing syn invisible group handling in FromMeta implementations (#263)
As of syn 2.40, syn may generate an invisible token when the input to the darling proc macro (specifically, the attributes) are generated by a macro_rules!
This update looks "through" that invisible group so parsing works as-expected. | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index ba2a3a2..cf25e23 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -122,7 +122,14 @@ pub trait FromMeta: Sized {
fn from_expr(expr: &Expr) -> Result<Self> {
match *expr {
Expr::Lit(ref lit) => Self::from_value(&l... | 1 | 40 | 25 |
fbcc1b4dc24ad1aa43b157ff7c4cacf4823c4b43 | Thomas BESSOU | 2024-02-08T17:05:28 | Fix misleading error message on UnexpectedType
It's currently named "Unexpected litteral type", but it can also be instantiated when not parsing a litteral, e.g. https://github.com/TedDriggs/darling/blob/224a866727cd9e40c2cd80430852b1ea0deeb40e/core/src/error/mod.rs#L152
This specifically made investigation of #263 mo... | diff --git a/core/src/error/kind.rs b/core/src/error/kind.rs
index 2b4eda6..0351172 100644
--- a/core/src/error/kind.rs
+++ b/core/src/error/kind.rs
@@ -44,7 +44,7 @@ impl ErrorKind {
UnknownField(_) => "Unexpected field",
UnsupportedShape { .. } => "Unsupported shape",
Unexpected... | 1 | 2 | 2 |
22a12681ad46d16e32fe6d86bcaa972e2142d786 | Ted Driggs | 2023-10-16T15:41:22 | Fix clippy violation | diff --git a/core/src/util/over_ride.rs b/core/src/util/over_ride.rs
index 3de6ed5..0b52dd8 100644
--- a/core/src/util/over_ride.rs
+++ b/core/src/util/over_ride.rs
@@ -103,7 +103,10 @@ impl<T> Override<T> {
impl<T: Default> Override<T> {
/// Returns the contained value or the default value of `T`.
pub fn un... | 1 | 4 | 1 |
7928941075bab9b474288cd950349f43b02d14b9 | Sergey Potapov | 2023-07-11T20:57:24 | Implement FromMeta for i128 and u128 | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 1878b06..ff57ab0 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -228,11 +228,13 @@ from_meta_num!(u8);
from_meta_num!(u16);
from_meta_num!(u32);
from_meta_num!(u64);
+from_meta_num!(u128);
from_meta_num!(usize);
from_meta_num!(i8);... | 1 | 2 | 0 |
8c4d6adca2d71c4f80da019fef5bd6366a6c8bfe | Ted Driggs | 2023-06-07T21:06:50 | Fix clippy violation | diff --git a/core/src/error/mod.rs b/core/src/error/mod.rs
index 6f2c045..2c14a3e 100644
--- a/core/src/error/mod.rs
+++ b/core/src/error/mod.rs
@@ -775,7 +775,7 @@ impl Accumulator {
/// This function defuses the drop bomb.
#[must_use = "Accumulated errors should be handled or propagated to the caller"]
... | 1 | 1 | 1 |
6d6f6e015f0dace091a187fdbdb7a66559ea5796 | Ted Driggs | 2023-05-22T16:28:27 | Add new parsing util functions for Exprs | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 5413d04..1878b06 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -279,6 +279,9 @@ impl<T: syn::parse::Parse, P: syn::parse::Parse> FromMeta for syn::punctuated::P
/// For backwards-compatibility to versions of `darling` based on `syn` 1... | 4 | 109 | 0 |
e4d22dd127352b11dfee97e45bd32252570b3b2b | tenuous-guidance | 2023-05-02T09:13:00 | Allow `Clone`ing `NestedMeta` | diff --git a/core/src/ast/data.rs b/core/src/ast/data.rs
index 38b0190..4b91595 100644
--- a/core/src/ast/data.rs
+++ b/core/src/ast/data.rs
@@ -413,7 +413,7 @@ impl<'a> From<&'a syn::Fields> for Style {
}
}
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub enum NestedMeta {
Meta(syn::Meta),
Lit(syn::Li... | 1 | 1 | 1 |
b0bfdfd4e81d06f424fa6ee0ebbfb78260554a4e | Ted Driggs | 2023-04-27T15:51:01 | Bump version to 0.20.0 | diff --git a/Cargo.toml b/Cargo.toml
index 2049149..56751cd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,9 +1,9 @@
[package]
name = "darling"
-version = "0.14.4"
+version = "0.20.0"
authors = ["Ted Driggs <ted.driggs@outlook.com>"]
repository = "https://github.com/TedDriggs/darling"
-documentation = "https://docs... | 3 | 7 | 7 |
2c9ba697b861c7c5b88dabf53af464f7d5471e34 | Ted Driggs | 2023-04-20T23:09:58 | Bump syn to 2.0.15 | diff --git a/Cargo.toml b/Cargo.toml
index 5326366..2049149 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,7 +23,7 @@ darling_macro = { version = "=0.14.4", path = "macro" }
[dev-dependencies]
proc-macro2 = "1.0.37"
quote = "1.0.18"
-syn = "2.0.0"
+syn = "2.0.15"
[target.'cfg(compiletests)'.dev-dependencies]
ru... | 3 | 3 | 3 |
1d6f8df731c78e6b120d56a817f39d86bf1660f5 | Jonas Bushart | 2023-04-07T16:02:09 | Replace `Default` returns with explicit panics for unknown enum variants | diff --git a/core/src/usage/lifetimes.rs b/core/src/usage/lifetimes.rs
index 921debe..b7124aa 100644
--- a/core/src/usage/lifetimes.rs
+++ b/core/src/usage/lifetimes.rs
@@ -247,7 +247,8 @@ impl UsesLifetimes for syn::WherePredicate {
syn::WherePredicate::Type(ref v) => v.uses_lifetimes(options, lifetimes),... | 2 | 12 | 6 |
3fcf61a12b47104c6e115a6b8b7447b916ef2d06 | Ted Driggs | 2023-04-07T00:40:55 | Add support for unquoted expressions in value position | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 8dd7271..4c1ce24 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -274,6 +274,74 @@ impl<T: syn::parse::Parse, P: syn::parse::Parse> FromMeta for syn::punctuated::P
}
}
+/// Support for arbitrary expressions as values in a meta it... | 1 | 84 | 13 |
c03616225175831db83a0b84b5866253f4d8ab43 | Jonas Bushart | 2023-03-22T18:28:56 | Handle invisible groups in `from_expr` | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index d858d5f..8dd7271 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -122,6 +122,7 @@ pub trait FromMeta: Sized {
fn from_expr(expr: &Expr) -> Result<Self> {
match *expr {
Expr::Lit(ref lit) => Self::from_value(&li... | 1 | 1 | 0 |
809739750489d5e57ab068909323bb28805943eb | Jonas Bushart | 2023-03-22T18:15:06 | Remove unnecessary clones | diff --git a/core/src/codegen/attr_extractor.rs b/core/src/codegen/attr_extractor.rs
index a5d911c..4afb174 100644
--- a/core/src/codegen/attr_extractor.rs
+++ b/core/src/codegen/attr_extractor.rs
@@ -55,7 +55,7 @@ pub trait ExtractAttribute {
#(#attr_names)|* => {
match ::darling:... | 2 | 3 | 3 |
fba64662ec78dfcc7cf4e0777a29857f831f506a | Jonas Bushart | 2023-03-22T18:05:59 | Rename more occurences of lifetime "def" to "param" | diff --git a/core/src/ast/generics.rs b/core/src/ast/generics.rs
index d048e6a..d4bf0c9 100644
--- a/core/src/ast/generics.rs
+++ b/core/src/ast/generics.rs
@@ -23,7 +23,7 @@ pub trait GenericParamExt {
}
/// If this GenericParam is a lifetime, get the underlying value.
- fn as_lifetime_def(&self) -> Opt... | 2 | 5 | 5 |
1da921845727ebd061cf8d2c33ffe80a8d97c963 | Jonas Bushart | 2023-03-22T18:01:33 | `from_nested_meta` can stay a part of `FromMeta` trait
This was initially removed in an attempt to get rid of `NestedMeta`, but
since the type stays, the function can too. | diff --git a/core/src/error/mod.rs b/core/src/error/mod.rs
index 17b5876..6f2c045 100644
--- a/core/src/error/mod.rs
+++ b/core/src/error/mod.rs
@@ -307,6 +307,7 @@ impl Error {
/// overridden:
///
/// * `FromMeta::from_meta`
+ /// * `FromMeta::from_nested_meta`
/// * `FromMeta::from_value`
... | 2 | 9 | 0 |
71beef6a4d18fcbcda1e427c2446713ea0a2e0e0 | Jonas Bushart | 2023-03-22T18:01:20 | Add a missing comment about non-exhaustive enums | diff --git a/core/src/usage/lifetimes.rs b/core/src/usage/lifetimes.rs
index db065e9..921debe 100644
--- a/core/src/usage/lifetimes.rs
+++ b/core/src/usage/lifetimes.rs
@@ -295,6 +295,7 @@ impl UsesLifetimes for syn::TypeParamBound {
match *self {
syn::TypeParamBound::Trait(ref v) => v.uses_lifeti... | 1 | 1 | 0 |
d36be704de578a32bc8b44c35ba81465658a1141 | Jonas Bushart | 2023-03-22T17:51:54 | Fix new clippy warnings enabled by MSRV bump | diff --git a/core/src/options/core.rs b/core/src/options/core.rs
index c79f7d5..cc05f21 100644
--- a/core/src/options/core.rs
+++ b/core/src/options/core.rs
@@ -166,7 +166,7 @@ impl<'a> From<&'a Core> for codegen::TraitImpl<'a> {
.map_enum_variants(|variant| variant.as_codegen_variant(&v.ident)),
... | 7 | 7 | 37 |
013ef4b5cd739f04526e0ba4ac96aec05f52a831 | Ted Driggs | 2023-03-21T22:18:20 | Fix rustfmt violation | diff --git a/core/src/util/parse_attribute.rs b/core/src/util/parse_attribute.rs
index 129e49c..87b61d8 100644
--- a/core/src/util/parse_attribute.rs
+++ b/core/src/util/parse_attribute.rs
@@ -54,9 +54,9 @@ impl fmt::Display for DisplayPath<'_> {
#[cfg(test)]
mod tests {
use super::parse_attribute_to_meta_list;
... | 1 | 1 | 1 |
3edb4b395bfb85150bde42c96e313c68a8bd48de | Ted Driggs | 2023-03-21T20:49:12 | Add `dyn` to fix unit tests
It's no longer allowed to use bare trait types for Box type parameter. | diff --git a/core/src/usage/type_params.rs b/core/src/usage/type_params.rs
index 5c95b97..74967ae 100644
--- a/core/src/usage/type_params.rs
+++ b/core/src/usage/type_params.rs
@@ -327,7 +327,7 @@ mod tests {
#[test]
fn box_fn_output() {
- let input: DeriveInput = parse_quote! { struct Foo<T>(Box<Fn(... | 1 | 2 | 2 |
ad5f8e6e13abd7d50f7f99fcd85f87ffa3d5c18f | Jonas Bushart | 2023-03-20T20:50:05 | Fix some formatting issues | diff --git a/core/src/error/mod.rs b/core/src/error/mod.rs
index f165ff7..17b5876 100644
--- a/core/src/error/mod.rs
+++ b/core/src/error/mod.rs
@@ -13,7 +13,7 @@ use std::iter::{self, Iterator};
use std::string::ToString;
use std::vec;
use syn::spanned::Spanned;
-use syn::{Lit, LitStr, Path, Expr};
+use syn::{Expr,... | 7 | 10 | 9 |
94a2601127711fd40a4d6a7ce94692e32ec3465e | Jonas Bushart | 2023-03-20T20:44:30 | Fix two `.nested` which were not converted | diff --git a/core/src/util/parse_attribute.rs b/core/src/util/parse_attribute.rs
index 1ffe769..129e49c 100644
--- a/core/src/util/parse_attribute.rs
+++ b/core/src/util/parse_attribute.rs
@@ -56,18 +56,21 @@ mod tests {
use super::parse_attribute_to_meta_list;
use syn::spanned::Spanned;
use syn::{parse_... | 1 | 5 | 2 |
408dd51890feee6042e3a2cb6fb8e67156c28feb | Jonas Bushart | 2023-03-18T15:34:54 | Fix tests | diff --git a/tests/unsupported_attributes.rs b/tests/unsupported_attributes.rs
index 14edf2c..98b190d 100644
--- a/tests/unsupported_attributes.rs
+++ b/tests/unsupported_attributes.rs
@@ -20,8 +20,8 @@ fn non_meta_attribute_gets_own_error() {
};
let errors: darling::Error = Bar::from_derive_input(&di).unwr... | 1 | 4 | 4 |
6cba87ff4b477934f66c8417024fe41e8a692c31 | Jonas Bushart | 2023-03-18T14:06:57 | Get the macro generated code to compile.
Switch access to `.nested` to use `parse_meta_list` instead. | diff --git a/core/src/codegen/attr_extractor.rs b/core/src/codegen/attr_extractor.rs
index 521d01c..a5d911c 100644
--- a/core/src/codegen/attr_extractor.rs
+++ b/core/src/codegen/attr_extractor.rs
@@ -55,13 +55,18 @@ pub trait ExtractAttribute {
#(#attr_names)|* => {
match ::darlin... | 3 | 15 | 9 |
b561f32129f89927a42a5efb090ce7c0dadf2919 | Jonas Bushart | 2023-03-18T13:56:44 | Migrate to syn v2
darling heavily relies on `syn::NestedMeta`. This type has been removed
in syn v2. Instead create a copy under `darling::ast::NestedMeta` and
use that to replace all uses of `syn::NestedMeta`. | diff --git a/Cargo.toml b/Cargo.toml
index 6f9aa30..5326366 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,7 +23,7 @@ darling_macro = { version = "=0.14.4", path = "macro" }
[dev-dependencies]
proc-macro2 = "1.0.37"
quote = "1.0.18"
-syn = "1.0.91"
+syn = "2.0.0"
[target.'cfg(compiletests)'.dev-dependencies]
ru... | 17 | 167 | 68 |
f94271c3b35cbf2bef8b74e7271280f492ea16b3 | Jonas Bushart | 2023-03-18T13:50:27 | Update implementation of UsesLifetimes | diff --git a/core/src/usage/lifetimes.rs b/core/src/usage/lifetimes.rs
index b940173..87a2d82 100644
--- a/core/src/usage/lifetimes.rs
+++ b/core/src/usage/lifetimes.rs
@@ -112,20 +112,20 @@ impl UsesLifetimes for Lifetime {
}
uses_lifetimes!(syn::AngleBracketedGenericArguments, args);
+uses_lifetimes!(syn::AssocTy... | 1 | 27 | 8 |
5e840534b95e2c4a765a6036e5d658e64048950a | Jonas Bushart | 2023-03-18T13:50:09 | Update implementation of UsesTypeParams | diff --git a/core/src/usage/type_params.rs b/core/src/usage/type_params.rs
index 152d218..5c95b97 100644
--- a/core/src/usage/type_params.rs
+++ b/core/src/usage/type_params.rs
@@ -87,8 +87,8 @@ impl<T: UsesTypeParams, U> UsesTypeParams for Punctuated<T, U> {
}
uses_type_params!(syn::AngleBracketedGenericArguments,... | 1 | 11 | 7 |
cfd1b1c49c629d9a6e584491b78f26f0858d679f | Jonas Bushart | 2023-03-18T10:32:34 | Do not implement Spanned manually
The Spanned trait becomes sealed in v2 of syn.
This means manual implementations of Spanned are no longer possible. If
needed, the only way to implement Spanned is to implement
`quote::ToTokens`, because there is a blanket implementation. | diff --git a/core/src/util/flag.rs b/core/src/util/flag.rs
index ade8898..66f2adc 100644
--- a/core/src/util/flag.rs
+++ b/core/src/util/flag.rs
@@ -77,12 +77,6 @@ impl FromMeta for Flag {
}
}
-impl Spanned for Flag {
- fn span(&self) -> Span {
- self.0.unwrap_or_else(Span::call_site)
- }
-}
-
imp... | 3 | 4 | 15 |
7e80119efb48184edf3a6a544297708bcb4de849 | Ted Driggs | 2023-02-01T21:38:06 | Add Error::unsupported_shape_with_expected
Unsupported shape errors can now indicate what they expected to receive. | diff --git a/core/src/error/kind.rs b/core/src/error/kind.rs
index 0030e0d..2b4eda6 100644
--- a/core/src/error/kind.rs
+++ b/core/src/error/kind.rs
@@ -15,7 +15,10 @@ pub(in crate::error) enum ErrorKind {
Custom(String),
DuplicateField(FieldName),
MissingField(FieldName),
- UnsupportedShape(DeriveInp... | 3 | 31 | 5 |
a4c0e9572e8506b389e5db189b107b222d2b1cc7 | Ted Driggs | 2023-01-31T20:32:49 | Add Shape, AsShape, and ShapeSet to darling::util
These will be used at macro execution time for building error messages when shape validation fails. | diff --git a/core/src/util/mod.rs b/core/src/util/mod.rs
index 11f1113..ddc240b 100644
--- a/core/src/util/mod.rs
+++ b/core/src/util/mod.rs
@@ -7,6 +7,7 @@ mod over_ride;
mod parse_attribute;
mod path_list;
mod path_to_string;
+mod shape;
mod spanned_value;
mod with_original;
@@ -17,5 +18,6 @@ pub use self::ove... | 2 | 284 | 0 |
b4a65b3c0eea4a013a168aa8fe1a3842bb2d32ff | Ted Driggs | 2022-11-23T14:10:44 | Use 2018 import for quote::quote
* Delete macros_private::quote
* Delete extern-crate for quote
* Change Error::write_errors not to use quote! with diagnostics feature | diff --git a/core/src/ast/data.rs b/core/src/ast/data.rs
index 96dd6f3..958c7be 100644
--- a/core/src/ast/data.rs
+++ b/core/src/ast/data.rs
@@ -1,7 +1,7 @@
use std::{slice, vec};
use proc_macro2::{Span, TokenStream};
-use quote::ToTokens;
+use quote::{quote, quote_spanned, ToTokens};
use syn::spanned::Spanned;
... | 22 | 21 | 23 |
b4b6c03f715866f8f74a400b5e84183509ec02b0 | Ted Driggs | 2022-11-23T13:55:04 | Remove all "simple" extern crates
Two are left: The proc_macro crate that isn't in Cargo.toml, and quote because of how often its macros are used. | diff --git a/core/src/lib.rs b/core/src/lib.rs
index 65fa667..6a0e576 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -3,13 +3,8 @@
#[macro_use]
extern crate quote;
-extern crate fnv;
-extern crate ident_case;
#[cfg(feature = "diagnostics")]
extern crate proc_macro;
-extern crate proc_macro2;
-#[cfg(feature... | 1 | 0 | 5 |
3004ba5f9de9766211bcf133a8a3b7989f9fbc65 | Ted Driggs | 2022-11-23T13:53:34 | Remove extern crate for syn
Explicitly use syn::parse_quote where needed | diff --git a/core/src/ast/generics.rs b/core/src/ast/generics.rs
index 0909bad..3de3c57 100644
--- a/core/src/ast/generics.rs
+++ b/core/src/ast/generics.rs
@@ -177,6 +177,8 @@ impl<'a, P: GenericParamExt> Iterator for TypeParams<'a, P> {
#[cfg(test)]
mod tests {
+ use syn::parse_quote;
+
use super::{Generi... | 11 | 14 | 5 |
f77e99935458ceb25f5efcf922e645c7f5059044 | Ted Driggs | 2022-09-26T16:11:56 | Update docs
- Accurately label the type of fields in FromVariant derivers
- Add bounds constraint to magic field docs
Fix #200 | diff --git a/src/lib.rs b/src/lib.rs
index 2429c7c..c84a55c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -61,7 +61,7 @@
//! |---|---|---|
//! |`ident`|`syn::Ident`|The identifier of the passed-in variant|
//! |`discriminant`|`Option<syn::Expr>`|For a variant such as `Example = 2`, the `2`|
-//! |`fields`|`Option<darl... | 1 | 1 | 1 |
ab279f575e420cb6fbb3234315ede47968217d4f | Ted Driggs | 2022-09-26T15:31:32 | Fix clippy violation | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index ea77f88..3c39af5 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -621,7 +621,7 @@ mod tests {
#[test]
fn unit_succeeds() {
- let _ = fm::<()>(quote!(ignore));
+ fm::<()>(quote!(ignore));
}
#[test] | 1 | 1 | 1 |
2dd15cd385e5e390083005d75952e43b9b077bfd | Ted Driggs | 2022-09-08T19:15:50 | Fix clippy violations in integration test | diff --git a/tests/from_meta.rs b/tests/from_meta.rs
index 7523de3..3e7278c 100644
--- a/tests/from_meta.rs
+++ b/tests/from_meta.rs
@@ -11,27 +11,27 @@ struct Meta {
#[test]
fn nested_meta_meta_value() {
- let meta = Meta::from_list(&vec![parse_quote! {
+ let meta = Meta::from_list(&[parse_quote! {
... | 1 | 7 | 7 |
161587a227093dc76ffd4a4d386a1a0e67e03f2c | Leigh McCulloch | 2022-09-08T18:50:53 | Emit Error when parsing FromMeta containing NestedMeta::Lit (#193)
darling silently ignored literals in NestedMeta, which could indirectly cause confusing error messages if the user provided something that wasn't of the intended format.
This update makes that error more explicit, and includes tests to showcase the ... | diff --git a/core/src/codegen/variant_data.rs b/core/src/codegen/variant_data.rs
index c36a263..b1f4450 100644
--- a/core/src/codegen/variant_data.rs
+++ b/core/src/codegen/variant_data.rs
@@ -58,11 +58,17 @@ impl<'a> FieldsGen<'a> {
quote!(
for __item in __items {
- if let ::syn:... | 2 | 77 | 5 |
fad4cb7b7375523df181ff996b54bd67d5aaaa6a | Nickie S | 2022-08-19T10:19:51 | Do not panic in Accumulator::drop() if we are already panicking | diff --git a/core/src/error/mod.rs b/core/src/error/mod.rs
index ca68956..87dbdff 100644
--- a/core/src/error/mod.rs
+++ b/core/src/error/mod.rs
@@ -683,10 +683,14 @@ impl Extend<Error> for Accumulator {
impl Drop for Accumulator {
fn drop(&mut self) {
- if let Some(errors) = &mut self.0 {
- m... | 1 | 8 | 4 |
b71b23e59c9522dbb5b9408c3419d3ab000bbaf8 | Ted Driggs | 2022-07-05T14:34:49 | Fix clippy violation | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 39c980b..ea77f88 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -621,7 +621,7 @@ mod tests {
#[test]
fn unit_succeeds() {
- let () = fm::<()>(quote!(ignore));
+ let _ = fm::<()>(quote!(ignore));
}
#... | 1 | 1 | 1 |
e660fe2cbafd2a4fbe7579775443c00602f957f7 | Ted Driggs | 2022-04-28T13:41:19 | impl From<Error> for syn::Error
The addition of syn::Error::combine makes this possible. | diff --git a/core/src/error/mod.rs b/core/src/error/mod.rs
index 3c5a26b..ceae921 100644
--- a/core/src/error/mod.rs
+++ b/core/src/error/mod.rs
@@ -350,18 +350,7 @@ impl Error {
#[cfg(not(feature = "diagnostics"))]
{
- self.flatten()
- .into_iter()
- .map(|e... | 1 | 18 | 12 |
d125c0aa32e5b7498bc791c01bece41f5b30a42a | Ted Driggs | 2022-04-28T13:35:09 | Expose Error span | diff --git a/core/src/error/mod.rs b/core/src/error/mod.rs
index eaa8b71..3c5a26b 100644
--- a/core/src/error/mod.rs
+++ b/core/src/error/mod.rs
@@ -252,6 +252,20 @@ impl Error {
self
}
+ /// Get a span for the error.
+ ///
+ /// # Return Value
+ /// This function will return [`Span::call_si... | 1 | 14 | 0 |
c908b33c441552325a8ca1a67fa0159aba045f2a | Ted Driggs | 2022-04-19T14:00:27 | Use error::Accumulator in generated code
This fixes a bug where shape validation preempted other diagnostics. | diff --git a/core/src/codegen/error.rs b/core/src/codegen/error.rs
index 5b5e52e..2055a82 100644
--- a/core/src/codegen/error.rs
+++ b/core/src/codegen/error.rs
@@ -10,7 +10,7 @@ pub struct ErrorDeclaration {
impl ToTokens for ErrorDeclaration {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.appe... | 4 | 8 | 23 |
77075f433f580f5213e211cb778c3c7af7f7926d | Ted Driggs | 2022-04-13T15:33:43 | Bump min versions of quote, syn, and proc-macro2
This ensures we get the performance gains of quote 1.0.18 | diff --git a/Cargo.toml b/Cargo.toml
index 04166c7..bacb9e2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,9 +21,9 @@ darling_core = { version = "=0.13.4", path = "core" }
darling_macro = { version = "=0.13.4", path = "macro" }
[dev-dependencies]
-proc-macro2 = "1.0.26"
-quote = "1.0.9"
-syn = "1.0.69"
+proc-macro... | 3 | 8 | 8 |
b8bc2770b791ec917088124e3b9e406383b538d0 | Ted Driggs | 2022-04-13T13:26:46 | Improve Flag documentation | diff --git a/core/src/util/flag.rs b/core/src/util/flag.rs
index c714763..ade8898 100644
--- a/core/src/util/flag.rs
+++ b/core/src/util/flag.rs
@@ -5,9 +5,42 @@ use crate::{FromMeta, Result};
/// A meta-item that can be present as a word - with no value - or absent.
///
-/// Unlike `Option<()>`, `Flag` keeps the s... | 1 | 36 | 3 |
956ef2bd69035689ba6ebb675af8bb8fde5f721a | Ted Driggs | 2022-04-12T20:04:38 | Add Span to util::Flag, and remove Deref impl
Remove BitAnd and BitOr ops from Flag | diff --git a/core/src/util/flag.rs b/core/src/util/flag.rs
index 699991f..c714763 100644
--- a/core/src/util/flag.rs
+++ b/core/src/util/flag.rs
@@ -1,22 +1,30 @@
-use std::ops::{BitAnd, BitOr, Deref, Not};
+use proc_macro2::Span;
+use syn::{spanned::Spanned, Meta};
use crate::{FromMeta, Result};
-/// Marker type ... | 2 | 34 | 68 |
2e29e0e7c93a0388a211fcd931040d468f66d9cc | Ted Driggs | 2022-04-12T18:16:28 | Accept allow_unknown_fields = false
This removes an inconsistency between containers and variants.
It also removes all internal uses of darling::util::Flag. | diff --git a/core/src/options/core.rs b/core/src/options/core.rs
index 19acaf3..e70c198 100644
--- a/core/src/options/core.rs
+++ b/core/src/options/core.rs
@@ -4,12 +4,11 @@ use crate::ast::{Data, Fields, Style};
use crate::codegen;
use crate::codegen::PostfixTransform;
use crate::options::{DefaultExpression, Input... | 4 | 6 | 7 |
09ecbd64d375bacb05206bc7b7c1368fc40f1f96 | Ted Driggs | 2022-04-12T15:00:01 | Move Flag to its own module | diff --git a/core/src/util/flag.rs b/core/src/util/flag.rs
new file mode 100644
index 0000000..699991f
--- /dev/null
+++ b/core/src/util/flag.rs
@@ -0,0 +1,101 @@
+use std::ops::{BitAnd, BitOr, Deref, Not};
+
+use crate::{FromMeta, Result};
+
+/// Marker type equivalent to `Option<()>` for use in attribute parsing.
+#[... | 2 | 103 | 102 |
445e6bbab38f18368abf7229ff4c5004e2846ac8 | sreenathkrishnan | 2022-04-13T13:46:23 | Improve enum shape validation (#178)
* Apply shape validation to enum with no variants. Previously, this would not have produced an error.
* If the receiver doesn't support any enum shapes, surface one diagnostic instead of one per variant | diff --git a/core/src/options/shape.rs b/core/src/options/shape.rs
index 41f6eec..481f906 100644
--- a/core/src/options/shape.rs
+++ b/core/src/options/shape.rs
@@ -72,18 +72,28 @@ impl ToTokens for Shape {
} else {
let en = &self.enum_values;
let st = &self.struct_values;
+
+ ... | 2 | 26 | 9 |
a0fb9cceab43fb3fe5e21ada7f247bd35da7022f | Ted Driggs | 2022-04-11T16:20:24 | Use from_none in codegen
This removes the need to use #[darling(default)] on options
in deriving structs.
Fixes #161 | diff --git a/core/src/codegen/field.rs b/core/src/codegen/field.rs
index 6256b24..72e26ef 100644
--- a/core/src/codegen/field.rs
+++ b/core/src/codegen/field.rs
@@ -191,11 +191,19 @@ impl<'a> ToTokens for CheckMissing<'a> {
fn to_tokens(&self, tokens: &mut TokenStream) {
if !self.0.multiple && self.0.defa... | 2 | 75 | 1 |
b981cf5fb949064c15a17b4c70e87d4b47ff4ac7 | Ted Driggs | 2022-04-08T19:02:32 | Add custom impl of <Flag as FromMeta>::from_none | diff --git a/core/src/util/mod.rs b/core/src/util/mod.rs
index 3030eee..d19510a 100644
--- a/core/src/util/mod.rs
+++ b/core/src/util/mod.rs
@@ -41,6 +41,10 @@ impl Deref for Flag {
}
impl FromMeta for Flag {
+ fn from_none() -> Option<Self> {
+ Some(Flag(None))
+ }
+
fn from_meta(mi: &syn::Meta) ... | 1 | 4 | 0 |
bb4c2b510c4e9a0479d0d5e552acf6f530541ec2 | Ted Driggs | 2022-04-08T19:00:46 | Add FromMeta::from_none | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 56dcf5f..39c980b 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -78,6 +78,20 @@ pub trait FromMeta: Sized {
.map_err(|e| e.with_span(item))
}
+ /// When a field is omitted from a parent meta-item, `from_none` is used ... | 1 | 38 | 0 |
50fb21453ba0aa86fdc796895a2269f05d8ae4bd | Ted Driggs | 2022-04-01T16:13:06 | Internally adopt error::Accumulator (not in codegen) (#171)
This switches all the cases where darling manually used an error vec over to use Accumulator. | diff --git a/core/src/ast/data.rs b/core/src/ast/data.rs
index 5670ef1..96dd6f3 100644
--- a/core/src/ast/data.rs
+++ b/core/src/ast/data.rs
@@ -121,20 +121,14 @@ impl<V: FromVariant, F: FromField> Data<V, F> {
pub fn try_from(body: &syn::Data) -> Result<Self> {
match *body {
syn::Data::Enum(... | 4 | 76 | 140 |
0f9800d609705b0840e13b0657efe5c1421a9b3e | Ian Jackson | 2022-03-31T17:18:20 | Add error::Accumulator (#164)
error::Accumulator provides a cleaner and safer API for deferring error return until processing finishes.
darling encourages this paradigm, as it provides better errors to users of darling-powered crates.
Previously, impls of darling traits would typically declare a mutable `errors` v... | diff --git a/core/src/error/mod.rs b/core/src/error/mod.rs
index 4d430f0..eaa8b71 100644
--- a/core/src/error/mod.rs
+++ b/core/src/error/mod.rs
@@ -1,4 +1,4 @@
-//! The `darling::Error` type and its internals.
+//! The `darling::Error` type, the multiple error `Accumulator`, and their internals.
//!
//! Error handli... | 1 | 234 | 4 |
ed74182434513879cdf1a1571ff43f215079909c | BinCheng | 2022-03-30T17:33:00 | Fix: Pass writer to write! macro in consume_fields example (#168) | diff --git a/examples/consume_fields.rs b/examples/consume_fields.rs
index 706f228..b514032 100644
--- a/examples/consume_fields.rs
+++ b/examples/consume_fields.rs
@@ -117,7 +117,7 @@ impl ToTokens for MyInputReceiver {
tokens.extend(quote! {
impl #imp Speak for #ident #ty #wher {
... | 1 | 1 | 1 |
dbe23119990f443148cc5dfae5f3fb21fc298e86 | Ted Driggs | 2022-03-30T15:42:55 | impl FromMeta for syn::ExprPath
Fixes #169 | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 1204752..f31d97e 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -275,6 +275,7 @@ macro_rules! from_syn_parse {
from_syn_parse!(syn::Ident);
from_syn_parse!(syn::Expr);
from_syn_parse!(syn::ExprArray);
+from_syn_parse!(syn::ExprPath);... | 1 | 8 | 0 |
fa9ccf816ace1c91bbcc41d8cb3790cb067b5dd0 | Ted Driggs | 2022-03-30T15:40:53 | Create macro for impl FromMeta on syn types which impl Parse
Migrate compatible impls to macro | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 3846099..1204752 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -238,25 +238,6 @@ macro_rules! from_meta_float {
from_meta_float!(f32);
from_meta_float!(f64);
-/// Parsing support for identifiers. This attempts to preserve span info... | 1 | 21 | 73 |
da38efe1bac77434daf793c748da5c3c3831df7f | Ted Driggs | 2022-03-09T15:30:30 | Add tests showing behavior of defaults (#162)
This is in support of #161, illustrating how defaults combine. | diff --git a/tests/defaults.rs b/tests/defaults.rs
index 9d04d32..084a00a 100644
--- a/tests/defaults.rs
+++ b/tests/defaults.rs
@@ -25,3 +25,99 @@ fn path_default() {
assert_eq!(speaker.first_word, "hello");
}
+
+/// Tests in this module capture the somewhat-confusing behavior observed when defaults
+/// are s... | 1 | 96 | 0 |
9cf84a334aa48c868e5db27ad6021546f7f570c2 | Vitaliy | 2022-03-08T14:38:01 | impl FromMeta for syn::Expr (#159) | diff --git a/core/src/from_meta.rs b/core/src/from_meta.rs
index 1651331..3846099 100644
--- a/core/src/from_meta.rs
+++ b/core/src/from_meta.rs
@@ -272,6 +272,19 @@ impl<T: syn::parse::Parse, P: syn::parse::Parse> FromMeta for syn::punctuated::P
}
}
+/// Parsing support for an expression, i.e. `example = "1 + ... | 1 | 20 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.