Skip to content

Consider interaction between artifact dependencies and required-features #12061

@dtolnay

Description

@dtolnay

Problem

When you use artifact dependency to depend on a binary that has required-features, those features do not get enabled automatically. Should they?

This was not addressed in the artifact dependencies RFC.

Steps

For example the lalrpop package currently contains this binary crate:

[package]
name = "lalrpop"
version = "0.19.12"

[dependencies]
pico-args = { version = "0.4", default_features = false, optional = true }

[[bin]]
name = "lalrpop"
required-features = ["pico-args"]

If something depends on that binary as an artifact dependency, it will fail to build.

[dependencies]
lalrpop = { version = "=0.19.12", artifact = "bin" }
$ cargo check -Z bindeps

error[E0463]: can't find crate for `pico_args`
 --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lalrpop-0.19.12/src/main.rs:2:1
  |
2 | extern crate pico_args;
  | ^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

Possible Solution(s)

I would prefer if required-features of an artifact dependency automatically got enabled.

Notes

Mentioning artifact dependencies tracking issue: #9096

Version

cargo 1.71.0-nightly (9e586fbd8 2023-04-25)
release: 1.71.0-nightly
commit-hash: 9e586fbd8b931494067144623b76c37d213b1ab6
commit-date: 2023-04-25
host: x86_64-unknown-linux-gnu
libgit2: 1.6.3 (sys:0.17.0 vendored)
libcurl: 8.0.1-DEV (sys:0.4.61+curl-8.0.1 vendored ssl:OpenSSL/1.1.1t)
ssl: OpenSSL 1.1.1t  7 Feb 2023
os: Ubuntu 22.04 (jammy) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-needs-rfcStatus: Needs an RFC to make progress.Z-bindepsNightly: binary artifact dependencies

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions