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

Highlight enables features in cargo info #14634

Open
georgmu opened this issue Oct 2, 2024 · 2 comments
Open

Highlight enables features in cargo info #14634

georgmu opened this issue Oct 2, 2024 · 2 comments
Labels
C-enhancement Category: enhancement Command-info S-triage Status: This issue is waiting on initial triage.

Comments

@georgmu
Copy link

georgmu commented Oct 2, 2024

Problem

As described in #14141, the following thing should be displayed for features:

  • For features enabled by users, a + prefix and colored output are now used for better visibility.
  • For features enabled automatically, colored output is used to distinguish them.
  • For disabled features, non-colored output is used to clearly indicate their status.

The enabled/disabled features are ignored in the cargo info output. There is always just a "+" for default features. Enabled features via Cargo.toml are not displayed as enabled.

Steps

$ grep "^reqwest =" Cargo.toml
reqwest = { version = "*", features = ["blocking", "json", "cookies", "rustls-tls-native-roots"], default-features = false }
$ cargo +nightly info reqwest
reqwest #http #request #client
higher level HTTP client library
version: 0.12.8
license: MIT OR Apache-2.0
rust-version: 1.63.0
documentation: https://docs.rs/reqwest
repository: https:/seanmonstar/reqwest
crates.io: https://crates.io/crates/reqwest/0.12.8
features:
 +default                             = [default-tls, charset, http2, macos-system-configuration]
  __tls                               = [dep:rustls-pemfile, tokio/io-util]
  charset                             = [dep:encoding_rs]
  default-tls                         = [dep:hyper-tls, dep:native-tls-crate, __tls, dep:tokio-native-tls]
  h2                                  = [dep:h2]
  http2                               = [h2, hyper/http2, hyper-util/http2, hyper-rustls?/http2]
  macos-system-configuration          = [dep:system-configuration]
  25 deactivated features
note: to see how you depend on reqwest, run `cargo tree --invert --package [email protected]`

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.83.0-nightly (80d82ca 2024-09-27)
release: 1.83.0-nightly
commit-hash: 80d82ca
commit-date: 2024-09-27
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w 11 Sep 2023
os: Fedora 41.0.0 (FortyOne) [64-bit]

@georgmu georgmu added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Oct 2, 2024
@epage epage added C-enhancement Category: enhancement Command-info and removed C-bug Category: bug labels Oct 2, 2024
@epage epage changed the title cargo info does not correctly display enabled features Highlight enables features in cargo info Oct 2, 2024
@epage
Copy link
Contributor

epage commented Oct 2, 2024

That was stale information and we've only been supporting default atm.

The question is which set of features to be considered enabled

  • For the parent package
  • For all workspace members
  • Across the entire resolve graph

And what should we do when the package isn't depended on by you?

@georgmu
Copy link
Author

georgmu commented Oct 4, 2024

I have no experience with multiple workspace members, but here is what I expect:

  • 1st column "+" and colored output for root dependencies (the same features which are shown when running "cargo add ")
$ cargo add reqwest
    Updating crates.io index
      Adding reqwest v0.12 to dependencies
             Features as of v0.12.0:
             + __rustls
             + __tls
             + blocking
             + cookies
             + json
             + rustls-pki-types
             + rustls-tls-native-roots
             24 deactivated features
  • for non-root dependencies enabling a feature, maybe add a list of these packages (maybe including their dependency path) behind the feature in parentheses or (in non-verbose mode) just print "enabled by X non-root dependencies)

(BTW: cargo add feature list is broken when using version="*" in Cargo.toml - I will open a separate ticket for this.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: enhancement Command-info S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants