Skip to content

Conversation

@antalsz
Copy link
Contributor

@antalsz antalsz commented Jul 2, 2024

I found that when I had an optional dependency in a crate and a feature that depended on it with the same name, the expanded crate would not create explicit dependencies on the dep:foo optional features, and then Cargo would complain that dep:foo was unused. For instance:

# Original my_crate Cargo.toml

[features]
foo = ["dep:foo", "other/foo"]

[dependencies]
foo = { version = "1.0.0", optional = true }

would give rise to

error: failed to parse manifest at `/.../macrotest000/Cargo.toml`

Caused by:
  optional dependency `foo` is not included in any feature
  Make sure that `dep:foo` is included in one of features in the [features] table.

because the generated Cargo.toml would look like

# macrotest generated Cargo.toml

[features]

foo = ["original_crate/foo"]

[dependencies]
foo = { version = "1.0.0", optional = true }

and the automatic foo feature would not be created. This PR preserves all dep:… features when creating the expanded Cargo.toml:

# New macrotest generated Cargo.toml

[features]

foo = ["original_crate/foo", "dep:foo"]

[dependencies]
foo = { version = "1.0.0", optional = true }

Copy link
Collaborator

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@taiki-e taiki-e merged commit fd7a125 into eupn:master Jul 9, 2024
@taiki-e
Copy link
Collaborator

taiki-e commented Jul 9, 2024

Published in v1.0.13.

antalsz added a commit to rigetti/rigetti-pyo3 that referenced this pull request Jul 9, 2024
antalsz added a commit to rigetti/rigetti-pyo3 that referenced this pull request Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants