Skip to content

Expose dependency renames so that enabled features make sense #1539

@dtolnay

Description

@dtolnay

As of rust-lang/cargo#4953, Cargo supports renaming dependencies from Cargo.toml. For example the following dependency specification would introduce a dependency on a crate whose real name is tarpc-lib, but referring to it as rpc within the current crate.

[dependencies]
rpc = { package = "tarpc-lib", version = "0.1" }

This introduces the potential for feature names that cannot be meaningfully interpreted through the API of crates.io. Consider tarpc 0.13.0:

$ curl https://crates.io/api/v1/crates/tarpc/0.13.0
{
  "version": {
    "id": 113315,
    "crate": "tarpc",
    "num": "0.13.0",
    ...
    "features": {
      "serde1": [
        "rpc/serde1",
        "serde",
        "serde/derive"
      ]
    },
    ...
  }
}
$ curl https://crates.io/api/v1/crates/tarpc/0.13.0/dependencies
{
  "dependencies": [
    ...
    {
      "id": 529683,
      "version_id": 113315,
      "crate_id": "tarpc-lib",
      "req": "^0.1",
      "optional": false,
      "default_features": true,
      "features": [],
      "target": null,
      "kind": "normal",
      "downloads": 0
    },
    ...
  ]
}

There is no indication that the "rpc/serde1" feature depended on by tarpc's "serde1" feature refers to the dependency on tarpc-lib. This information lives only in Cargo.toml.

I would like to see renames listed in the response of /crates/:crate_id/:version/dependencies so that the complete dependency graph can be understood without downloading the crate's source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancement ✨Category: Adding new behavior or a change to the way an existing feature works

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions