Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support name prefix configs for setters #233

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bon-macros/src/builder/builder_gen/input_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn parse_top_level_config(item_struct: &syn::ItemStruct) -> Result<TopLevelConfi
),
};

crate::parsing::require_non_empty_paren_meta_list_or_name_value(&attr.meta)?;
crate::parsing::require_classic_non_empty(&attr.meta)?;

let meta = darling::ast::NestedMeta::parse_meta_list(meta.tokens.clone())?;

Expand Down
4 changes: 2 additions & 2 deletions bon-macros/src/builder/builder_gen/member/config/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl FromMeta for GetterConfig {
}

// Reject empty parens such as `#[builder(getter())]`
crate::parsing::require_non_empty_paren_meta_list_or_name_value(meta)?;
crate::parsing::require_classic_non_empty(meta)?;

// Nested `Parsed` struct used as a helper for parsing the verbose form
#[derive(FromMeta)]
Expand Down Expand Up @@ -70,7 +70,7 @@ impl FromMeta for GetterConfig {
if let [kind1, kind2, ..] = kinds.as_slice() {
bail!(
&kind1.key,
"`{}` can't be specified together with `{}`",
"`{}` is mutually exclusive with `{}`",
kind1.key,
kind2.key
);
Expand Down
6 changes: 3 additions & 3 deletions bon-macros/src/builder/builder_gen/member/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub(crate) struct MemberConfig {
pub(crate) required: darling::util::Flag,

/// Configurations for the setter methods.
#[darling(with = crate::parsing::parse_non_empty_paren_meta_list)]
#[darling(with = crate::parsing::parse_classic_non_empty)]
pub(crate) setters: Option<SettersConfig>,

/// Skip generating a setter method for this member.
Expand Down Expand Up @@ -166,7 +166,7 @@ impl MemberConfig {

bail!(
&attr_span,
"`{attr_name}` attribute can't be specified together with {conflicting}",
"`{attr_name}` is mutually exclusive with {conflicting}",
);
}

Expand Down Expand Up @@ -278,7 +278,7 @@ impl MemberConfig {
if let Some(Some(_expr)) = self.default.as_deref() {
bail!(
&skip.key.span(),
"`skip` attribute can't be specified with the `default` attribute; \
"`skip` is mutually exclusive with `default`; \
if you wanted to specify a value for the member, then use \
the following syntax instead `#[builder(skip = value)]`",
);
Expand Down
117 changes: 97 additions & 20 deletions bon-macros/src/builder/builder_gen/member/config/setters.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
use crate::parsing::{ItemSigConfig, ItemSigConfigParsing, SpannedKey};
use crate::parsing::{reject_syntax, SpannedKey};
use crate::util::prelude::*;
use darling::util::SpannedValue;
use darling::FromMeta;
use syn::spanned::Spanned;

const DOCS_CONTEXT: &str = "builder struct's impl block";

fn parse_setter_fn(meta: &syn::Meta) -> Result<SpannedKey<ItemSigConfig>> {
let params = ItemSigConfigParsing {
meta,
reject_self_mentions: Some(DOCS_CONTEXT),
}
.parse()?;

SpannedKey::new(meta.path(), params)
}

fn parse_docs(meta: &syn::Meta) -> Result<SpannedKey<Vec<syn::Attribute>>> {
crate::parsing::parse_docs_without_self_mentions(DOCS_CONTEXT, meta)
}

#[derive(Debug, FromMeta)]
pub(crate) struct SettersConfig {
pub(crate) name: Option<SpannedKey<syn::Ident>>,
pub(crate) vis: Option<SpannedKey<syn::Visibility>>,
name: Option<SpannedKey<syn::Ident>>,

#[darling(rename = "doc", default, with = parse_docs, map = Some)]
pub(crate) docs: Option<SpannedKey<Vec<syn::Attribute>>>,
#[darling(default, map = Some, with = parse_ident_or_str_lit)]
prefix: Option<SpannedKey<SpannedValue<String>>>,

vis: Option<SpannedKey<syn::Visibility>>,

#[darling(rename = "doc", default, map = Some, with = parse_docs)]
docs: Option<SpannedKey<Vec<syn::Attribute>>>,

#[darling(flatten)]
pub(crate) fns: SettersFnsConfig,
fns: SettersFnsConfig,
}

#[derive(Debug, FromMeta)]
Expand All @@ -36,13 +32,94 @@ pub(crate) struct SettersFnsConfig {
/// type `Option<T>` or with `#[builder(default)]`.
///
/// By default, it's named `{member}` without any prefix or suffix.
#[darling(default, with = parse_setter_fn, map = Some)]
pub(crate) some_fn: Option<SpannedKey<ItemSigConfig>>,
pub(crate) some_fn: Option<SpannedKey<SetterFnSigConfig>>,

/// The setter that accepts the value of type `Option<T>` for a member of
/// type `Option<T>` or with `#[builder(default)]`.
///
/// By default, it's named `maybe_{member}`.
#[darling(default, with = parse_setter_fn, map = Some)]
pub(crate) option_fn: Option<SpannedKey<ItemSigConfig>>,
pub(crate) option_fn: Option<SpannedKey<SetterFnSigConfig>>,
}

#[derive(Debug, Default)]
pub(crate) struct SetterFnSigConfig {
pub(crate) name: Option<SpannedKey<syn::Ident>>,
pub(crate) prefix: Option<SpannedKey<SpannedValue<String>>>,
pub(crate) vis: Option<SpannedKey<syn::Visibility>>,
pub(crate) docs: Option<SpannedKey<Vec<syn::Attribute>>>,
}

impl FromMeta for SetterFnSigConfig {
fn from_meta(meta: &syn::Meta) -> Result<Self> {
if let syn::Meta::NameValue(meta) = meta {
let val = &meta.value;
let name = syn::parse2(val.to_token_stream())?;

return Ok(SetterFnSigConfig {
name: Some(SpannedKey::new(&meta.path, name)?),
prefix: None,
vis: None,
docs: None,
});
}

#[derive(Debug, FromMeta)]
struct Full {
name: Option<SpannedKey<syn::Ident>>,

#[darling(default, map = Some, with = parse_ident_or_str_lit)]
prefix: Option<SpannedKey<SpannedValue<String>>>,

vis: Option<SpannedKey<syn::Visibility>>,

#[darling(rename = "doc", default, map = Some, with = parse_docs)]
docs: Option<SpannedKey<Vec<syn::Attribute>>>,
}

let Full {
name,
prefix,
vis,
docs,
} = crate::parsing::parse_classic_non_empty(meta)?;

let config = SetterFnSigConfig {
name,
prefix,
vis,
docs,
};

Ok(config)
}
}

fn parse_ident_or_str_lit(meta: &syn::Meta) -> Result<SpannedKey<SpannedValue<String>>> {
let expr = darling::util::parse_expr::preserve_str_literal(meta)?;
let value = match &expr {
syn::Expr::Lit(syn::ExprLit {
attrs,
lit: syn::Lit::Str(str),
..
}) => {
reject_syntax("attribute", &attrs.first())?;
str.value()
}

syn::Expr::Path(syn::ExprPath {
attrs, qself, path, ..
}) => {
reject_syntax("attribute", &attrs.first())?;
reject_syntax("<T as Trait> syntax", qself)?;
path.get_ident()
.ok_or_else(|| err!(&path, "expected an identifier"))?
.to_string()
}

_ => bail!(&expr, "expected an indetifier or a string literal",),
};

let value = SpannedValue::new(value, expr.span());

SpannedKey::new(meta.path(), value)
}
4 changes: 1 addition & 3 deletions bon-macros/src/builder/builder_gen/member/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ impl Member {
.map(|member| {
for attr in member.attrs {
if attr.meta.path().is_ident("builder") {
crate::parsing::require_non_empty_paren_meta_list_or_name_value(
&attr.meta,
)?;
crate::parsing::require_classic_non_empty(&attr.meta)?;
}
}

Expand Down
9 changes: 5 additions & 4 deletions bon-macros/src/builder/builder_gen/member/named.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use super::config::MemberConfig;
use super::{config, MemberOrigin};
use crate::builder::builder_gen::member::config::SettersFnsConfig;
use crate::builder::builder_gen::member::SetterFnSigConfig;
use crate::builder::builder_gen::top_level_config::OnConfig;
use crate::normalization::SyntaxVariant;
use crate::parsing::{ItemSigConfig, SpannedKey};

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (nightly)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (beta)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (ubuntu)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (ubuntu)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_20)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10_alloc)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_3)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (macos)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (macos)

unused import: `ItemSigConfig`

Check warning on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (ubuntu)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (macos)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (windows)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (windows)

unused import: `ItemSigConfig`

Check failure on line 7 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (windows)

unused import: `ItemSigConfig`
use crate::util::prelude::*;

#[derive(Debug)]
Expand Down Expand Up @@ -109,16 +110,16 @@
.setters
.as_ref()
.map(|setters| {
if setters.docs.is_some() {

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (nightly)

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (beta)

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (ubuntu)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (ubuntu)

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_20)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10_alloc)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_3)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (macos)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (macos)

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (ubuntu)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (macos)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (windows)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (windows)

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 113 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (windows)

field `docs` of struct `config::setters::SettersConfig` is private
return true;
}

let SettersFnsConfig { some_fn, option_fn } = &setters.fns;

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (nightly)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (beta)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (ubuntu)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (ubuntu)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_20)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10_alloc)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_3)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (macos)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (macos)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (ubuntu)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (macos)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (windows)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (windows)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 117 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (windows)

field `fns` of struct `config::setters::SettersConfig` is private
matches!(
(some_fn.as_deref(), option_fn.as_deref()),
(
Some(ItemSigConfig { docs: Some(_), .. }),
Some(ItemSigConfig { docs: Some(_), .. })
Some(SetterFnSigConfig { docs: Some(_), .. }),
Some(SetterFnSigConfig { docs: Some(_), .. })
)
)
})
Expand Down Expand Up @@ -151,7 +152,7 @@
};

if self.is_required() {
let SettersFnsConfig { some_fn, option_fn } = &setters.fns;

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (nightly)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (beta)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (ubuntu)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (ubuntu)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_20)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10_alloc)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_3)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (macos)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (macos)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (ubuntu)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (macos)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (windows)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (windows)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 155 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (windows)

field `fns` of struct `config::setters::SettersConfig` is private

let unexpected_setter = option_fn.as_ref().or(some_fn.as_ref());

Expand All @@ -168,13 +169,13 @@
if let SettersFnsConfig {
some_fn: Some(some_fn),
option_fn: Some(option_fn),
} = &setters.fns

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (nightly)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (beta)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (ubuntu)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (ubuntu)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_20)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10_alloc)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_3)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (macos)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (macos)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (ubuntu)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (macos)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (windows)

field `fns` of struct `config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (windows)

field `fns` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 172 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (windows)

field `fns` of struct `config::setters::SettersConfig` is private
{
let setter_fns = &[some_fn, option_fn];

Self::validate_unused_setters_cfg(setter_fns, &setters.name, |config| &config.name)?;

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (nightly)

field `name` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (nightly)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (beta)

field `name` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (beta)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (ubuntu)

field `name` of struct `config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (ubuntu)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (ubuntu)

field `name` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (ubuntu)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10)

field `name` of struct `config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_20)

field `name` of struct `config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_20)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10_alloc)

field `name` of struct `config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10_alloc)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_3)

field `name` of struct `config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_3)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (macos)

field `name` of struct `config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (macos)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (macos)

field `name` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (macos)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

field `name` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (ubuntu)

field `name` of struct `config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (macos)

field `name` of struct `config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (windows)

field `name` of struct `config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (windows)

field `name` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (windows)

mismatched types

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (windows)

field `name` of struct `config::setters::SettersConfig` is private

Check failure on line 176 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (windows)

mismatched types
Self::validate_unused_setters_cfg(setter_fns, &setters.vis, |config| &config.vis)?;

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (nightly)

field `vis` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (nightly)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (beta)

field `vis` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (beta)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (ubuntu)

field `vis` of struct `config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (ubuntu)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (ubuntu)

field `vis` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (ubuntu)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10)

field `vis` of struct `config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_20)

field `vis` of struct `config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_20)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10_alloc)

field `vis` of struct `config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10_alloc)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_3)

field `vis` of struct `config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_3)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (macos)

field `vis` of struct `config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (macos)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (macos)

field `vis` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (macos)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

field `vis` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (ubuntu)

field `vis` of struct `config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (macos)

field `vis` of struct `config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (windows)

field `vis` of struct `config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (windows)

field `vis` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (windows)

mismatched types

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (windows)

field `vis` of struct `config::setters::SettersConfig` is private

Check failure on line 177 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (windows)

mismatched types
Self::validate_unused_setters_cfg(setter_fns, &setters.docs, |config| &config.docs)?;

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (nightly)

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-unstable (beta)

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (ubuntu)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (ubuntu)

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_20)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_10_alloc)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / runtime-benchmarks (args_3)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (macos)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (macos)

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-miri

mismatched types

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (ubuntu)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (macos)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-msrv (windows)

field `docs` of struct `config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / test-stable (windows)

field `docs` of struct `builder::builder_gen::member::config::setters::SettersConfig` is private

Check failure on line 178 in bon-macros/src/builder/builder_gen/member/named.rs

View workflow job for this annotation

GitHub Actions / cargo-doc (windows)

field `docs` of struct `config::setters::SettersConfig` is private
}

Ok(())
Expand All @@ -183,9 +184,9 @@
// Lint from nightly. `&Option<T>` is used to reduce syntax at the call site
#[allow(unknown_lints, clippy::ref_option)]
fn validate_unused_setters_cfg<T>(
overrides: &[&SpannedKey<ItemSigConfig>],
overrides: &[&SpannedKey<SetterFnSigConfig>],
config: &Option<SpannedKey<T>>,
get_val: impl Fn(&ItemSigConfig) -> &Option<SpannedKey<T>>,
get_val: impl Fn(&SetterFnSigConfig) -> &Option<SpannedKey<T>>,
) -> Result {
let config = match config {
Some(config) => config,
Expand Down
4 changes: 2 additions & 2 deletions bon-macros/src/builder/builder_gen/top_level_config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ pub(crate) struct TopLevelConfig {
#[darling(default, with = parse_state_mod)]
pub(crate) state_mod: ItemSigConfig,

#[darling(multiple, with = crate::parsing::parse_non_empty_paren_meta_list)]
#[darling(multiple, with = crate::parsing::parse_classic_non_empty)]
pub(crate) on: Vec<OnConfig>,

/// Specifies the derives to apply to the builder.
#[darling(default, with = crate::parsing::parse_non_empty_paren_meta_list)]
#[darling(default, with = crate::parsing::parse_classic_non_empty)]
pub(crate) derive: DerivesConfig,
}

Expand Down
43 changes: 35 additions & 8 deletions bon-macros/src/builder/builder_gen/top_level_config/on.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ pub(crate) struct OnConfig {
pub(crate) into: darling::util::Flag,
pub(crate) overwritable: darling::util::Flag,
pub(crate) required: darling::util::Flag,
pub(crate) setters: OnSettersConfig,
}

#[derive(Default, Debug, FromMeta)]
pub(crate) struct OnSettersConfig {
pub(crate) prefix: Option<syn::Ident>,

#[darling(default, with = crate::parsing::parse_classic_non_empty)]
pub(crate) some_fn: OnSetterFnConfig,

#[darling(default, with = crate::parsing::parse_classic_non_empty)]
pub(crate) option_fn: OnSetterFnConfig,
}

#[derive(Default, Debug, FromMeta)]
pub(crate) struct OnSetterFnConfig {
pub(crate) prefix: Option<syn::Ident>,
}

impl Parse for OnConfig {
Expand All @@ -24,6 +41,9 @@ impl Parse for OnConfig {
into: darling::util::Flag,
overwritable: darling::util::Flag,
required: darling::util::Flag,

#[darling(default, map = Some, with = crate::parsing::parse_classic_non_empty)]
setters: Option<OnSettersConfig>,
}

let parsed = Parsed::from_meta(&syn::parse_quote!(on(#rest)))?;
Expand Down Expand Up @@ -51,19 +71,24 @@ impl Parse for OnConfig {
into,
overwritable,
required,
setters,
} = &parsed;
let flags = [
("into", into),
("overwritable", overwritable),
("required", required),
let configs = [
("into", into.is_present()),
("overwritable", overwritable.is_present()),
("required", required.is_present()),
("setters", setters.is_some()),
];

if flags.iter().all(|(_, flag)| !flag.is_present()) {
let flags = flags.iter().map(|(name, _)| format!("`{name}`")).join(", ");
if configs.iter().all(|(_, is_present)| !is_present) {
let configs = configs
.iter()
.map(|(name, _)| format!("`{name}`"))
.join(", ");
let err = format!(
"this #[builder(on(type_pattern, ...))] contains no options \
to override the default behavior for the selected setters \
like {flags}, so it does nothing"
to override the default behavior for the selected members \
like {configs}, so it does nothing"
);

return Err(syn::Error::new_spanned(&rest, err));
Expand Down Expand Up @@ -104,13 +129,15 @@ impl Parse for OnConfig {
into,
overwritable,
required,
setters,
} = parsed;

Ok(Self {
type_pattern,
into,
overwritable,
required,
setters: setters.unwrap_or_default(),
})
}
}
Expand Down
4 changes: 1 addition & 3 deletions bon-macros/src/builder/item_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ pub(crate) fn generate(
.filter(|attr| attr.path().is_ident("builder"))
.map(|attr| {
if let syn::Meta::List(_) = attr.meta {
crate::parsing::require_non_empty_paren_meta_list_or_name_value(
&attr.meta,
)?;
crate::parsing::require_classic_non_empty(&attr.meta)?;
}
let meta_list = darling::util::parse_attribute_to_meta_list(attr)?;
NestedMeta::parse_meta_list(meta_list.tokens).map_err(Into::into)
Expand Down
2 changes: 1 addition & 1 deletion bon-macros/src/parsing/item_sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl ItemSigConfigParsing<'_> {
doc: Option<SpannedKey<Vec<syn::Attribute>>>,
}

let full: Full = crate::parsing::parse_non_empty_paren_meta_list(meta)?;
let full: Full = crate::parsing::parse_classic_non_empty(meta)?;

if let Some(context) = self.reject_self_mentions {
if let Some(docs) = &full.doc {
Expand Down
6 changes: 3 additions & 3 deletions bon-macros/src/parsing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ use syn::parse::Parser;
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;

pub(crate) fn parse_non_empty_paren_meta_list<T: FromMeta>(meta: &syn::Meta) -> Result<T> {
require_non_empty_paren_meta_list_or_name_value(meta)?;
pub(crate) fn parse_classic_non_empty<T: FromMeta>(meta: &syn::Meta) -> Result<T> {
require_classic_non_empty(meta)?;
T::from_meta(meta)
}

pub(crate) fn require_non_empty_paren_meta_list_or_name_value(meta: &syn::Meta) -> Result {
pub(crate) fn require_classic_non_empty(meta: &syn::Meta) -> Result {
match meta {
syn::Meta::List(meta) => {
meta.require_parens_delim()?;
Expand Down
4 changes: 2 additions & 2 deletions website/src/reference/builder/member/getter.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ You can override the return type of the getter, its name, visibility, and docs.
deref,

// Return the type specified in parens.
// A deref coercion is expected to be valid to the specified type.
// A deref coercion is expected to exist to the specified type.
// Don't specify the leading `&` here.
deref(T),

Expand All @@ -132,7 +132,7 @@ You can override the return type of the getter, its name, visibility, and docs.
)]
```

## Overriding the return type
## Overriding the Return Type

Here is an example of different return type configurations and what they generate.

Expand Down
Loading