Open
Description
openedon Dec 29, 2019
Problem
cargo-metadata
appears to always resolve features at the "workspace" level, rather than for root crate. This means that cargo metadata
will report features as enabled that aren't actually when cargo build
is run in the same directory.
Steps
- Clone https://github.com/sfackler/rust-postgres
- Run
cargo metadata --format-version 1 --manifest-path postgres-derive/Cargo.toml | jq '.resolve.nodes|.[]|select(.id|test("postgres-types"))'
. - Note that the entry for
postgres-types
has thederive
andpostgres-derive
features enabled even though they are off by default for that crate. Thepostgres-derive-test
crate in the same workspace enables that feature, which I assume is where that's coming from:
{
"id": "postgres-types 0.1.0 (path+file:///home/sfackler/code/rust-postgres/postgres-types)",
"dependencies": [
"bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"postgres-derive 0.4.0 (path+file:///home/sfackler/code/rust-postgres/postgres-derive)",
"postgres-protocol 0.5.0 (path+file:///home/sfackler/code/rust-postgres/postgres-protocol)"
],
"deps": [
{
"name": "bytes",
"pkg": "bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"dep_kinds": [
{
"kind": null,
"target": null
},
{
"kind": null,
"target": null
}
]
},
{
"name": "fallible_iterator",
"pkg": "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dep_kinds": [
{
"kind": null,
"target": null
},
{
"kind": null,
"target": null
}
]
},
{
"name": "postgres_derive",
"pkg": "postgres-derive 0.4.0 (path+file:///home/sfackler/code/rust-postgres/postgres-derive)",
"dep_kinds": [
{
"kind": null,
"target": null
}
]
},
{
"name": "postgres_protocol",
"pkg": "postgres-protocol 0.5.0 (path+file:///home/sfackler/code/rust-postgres/postgres-protocol)",
"dep_kinds": [
{
"kind": null,
"target": null
},
{
"kind": null,
"target": null
}
]
}
],
"features": [
"derive",
"postgres-derive"
]
}
Possible Solution(s)
cargo metadata
should respect the root crate when resolving the crate graph.
Notes
Output of cargo version
: cargo 1.41.0-nightly (19a0de2 2019-12-12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Area: features — conditional compilationArea: features — conditional compilationCategory: bugCategory: bugStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.