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

config derive conflicts with some other derive macro attributes. Better error message / documentation #31

Open
luketpeterson opened this issue Jun 20, 2023 · 0 comments

Comments

@luketpeterson
Copy link
Contributor

luketpeterson commented Jun 20, 2023

This code doesn't compile:

#[config]
#[derive(Parser, Debug, Default)]
pub struct FrameworkConfig <AppArgsT>
    where AppArgsT: clap::Args + Clone + Sync + Send + std::fmt::Debug + Default + DeserializeOwned + Serialize
{
    #[command(flatten)]
    #[serde(skip)]
    pub app_args: AppArgsT,
}

But this does:

#[derive(Parser, Debug, Default)]
#[config]
pub struct FrameworkConfig <AppArgsT>
    where AppArgsT: clap::Args + Clone + Sync + Send + std::fmt::Debug + Default + DeserializeOwned + Serialize
{
    #[command(flatten)]
    #[serde(skip)]
    pub app_args: AppArgsT,
}

The issue is the way the config proc macro handles the clap field attributes. Basically the config proc macro need to run first.

I don't see an easy fix for this, given the #[config] macro fundamentally reimplements the type, rather than just deriving a trait implementation. Perhaps it can be documented or better error messages can be given though.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant