Skip to content

cargo add package@version shows features from oldest instead of current version #11073

Closed

Description

Problem

When adding cargo add with an explicit minimal version, cargo add will show features from the specific version, while actually adding the latest semver-compatible version. This seems misleading and/or confusing.

Steps

  1. cargo add chrono@0.4

Actual result:

djc-2021 main test-rs $ cargo add chrono@0.4
    Updating crates.io index
      Adding chrono v0.4 to dependencies.
             Features:
             - rustc-serialize
             - serde

Expected result:

    Updating crates.io index
      Adding chrono v0.4.22 to dependencies.
             Features:
             + clock
             + iana-time-zone
             + js-sys
             + oldtime
             + std
             + time
             + wasm-bindgen
             + wasmbind
             + winapi
             - __doctest
             - __internal_bench
             - alloc
             - criterion
             - libc
             - pure-rust-locales
             - rkyv
             - rustc-serialize
             - serde
             - unstable-locales

This is the output from cargo add chrono@0.4.22, which is the version that add chrono@0.4 actually pulls in at this time.

Possible Solution(s)

Bump the version to the latest semver-compatible one before extracting features, instead of after.

Version

cargo 1.65.0-nightly (4ed54cecc 2022-08-27)
release: 1.65.0-nightly
commit-hash: 4ed54cecce3ce9ab6ff058781f4c8a500ee6b8b5
commit-date: 2022-08-27
host: aarch64-apple-darwin
libgit2: 1.5.0 (sys:0.15.0 vendored)
libcurl: 7.79.1 (sys:0.4.55+curl-7.83.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 12.5.1 [64-bit]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions