Skip to content

remove 'complete' feature flag, make it unconditional #131

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

Merged

Conversation

BenWiederhake
Copy link
Contributor

@BenWiederhake BenWiederhake commented Apr 12, 2025

This avoids using cfg with the destination-crate's feature "complete" in proc-macro "derive".

Quoting cargo:

using a cfg inside a derive macro will use the cfgs from the
destination crate and not the ones from the defining crate

In these two instances, the cfg was simply used to avoid emitting dead code if the "complete" feature is not desired. By passing the "complete" feature down to the derive crate and evaluating if there, we achieve the same goal, without having to deal with suprisingly-valued and unexpected cfgs downstream. (EDIT: this sentence was a copy-paste-error, my bad!)

Discovered while trying to integrate uutils-args into coreutils: https://github.com/uutils/coreutils/actions/runs/14420666926/job/40442804575?pr=7739

This is my preferred approach.

Alternatively, we could just evaluate the flag inside the derive crate, and pass the feature flag to it, as implemented in #132.

This avoids using cfg with the destination-crate's feature "complete"
in proc-macro "derive".

Quoting cargo:

    using a cfg inside a derive macro will use the cfgs from the
    destination crate and not the ones from the defining crate

In these two instances, the cfg was simply used to avoid emitting dead
code if the "complete" feature is not desired. By passing the "complete"
feature down to the derive crate and evaluating if there, we achieve the
same goal, without having to deal with suprisingly-valued and unexpected
cfgs downstream.

Alternatively, we could just evaluate the flag inside the derive crate,
and pass the feature flag to it.
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

Successfully merging this pull request may close these issues.

2 participants