cargo icon indicating copy to clipboard operation
cargo copied to clipboard

private/hidden features

Open ehuss opened this issue 1 year ago • 0 comments

It can sometimes be useful to have a feature that you do not want users to use.

docs.rs has a convention that features prefixed with an underscore are not displayed in its UI. Looking through crates.io, I found the following packages declaring features with a leading underscore: https://gist.github.com/ehuss/c2c759067266d530712fc98afcb8513d. The majority look like they are intended to be hidden or internal only, but some are ambiguous.

To some degree, the need for this has been alleviated with the introduction of dep: prefixes which remove the implicit feature created by optional dependencies. However, there are still some use cases.

Some example use cases may be:

  • Testing and CI-only features. For example, deny-warnings
  • Docs-specific features (TODO: add a concrete example, can this be covered by doc(cfg)?)
  • TODO: add more use cases here (summarize the features in the linked gist above)

It is not clear what restrictions a private/hidden feature should have. Not displaying them in the UI and documentation seems useful, but are there other restrictions that can be added? One option is to prevent the use of the feature in a [dependencies] table and only enabled via the CLI or other features in the [features] table, but I'm concerned that rules out some use cases (see gist for some examples).

Proposed syntax:

[features.foobar]
public = false   # or maybe hidden?

I'm opening this issue to track this feature request, but this isn't something we will likely pursue in the near term. This will require an RFC to explore the design in more detail.

See also:

  • Previous request: #7769
  • Ivy has a visibility attribute for its configurations
  • deprecated features: #7130
  • feature descriptions: #4956
  • unstable features: #10881

ehuss avatar Jul 19 '22 21:07 ehuss