-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
A-featuresArea: features — conditional compilationArea: features — conditional compilationC-bugCategory: bugCategory: bugCommand-metadataS-needs-designStatus: 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.
Description
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-typeshas thederiveandpostgres-derivefeatures enabled even though they are off by default for that crate. Thepostgres-derive-testcrate 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)
ebkalderon, jplatte, jonas-schievink, emakryo, weihanglo and 6 more
Metadata
Metadata
Assignees
Labels
A-featuresArea: features — conditional compilationArea: features — conditional compilationC-bugCategory: bugCategory: bugCommand-metadataS-needs-designStatus: 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.