Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

papercut: cargo does not provide feedback when using a cfg(feature = "...") that is not declared in Cargo.toml #10102

Closed
lopopolo opened this issue Nov 19, 2021 · 2 comments
Labels
C-bug Category: bug

Comments

@lopopolo
Copy link

lopopolo commented Nov 19, 2021

Problem

Rust code in a crate can use cfg(feature = "...") attributes even if those features are not defined in Cargo.toml.

I would expect this to be an error or a warning.

Steps

git clone https://github.com/artichoke/intaglio.git
cd intaglio/benchmarks
git checkout 28dc9784a59336aac5b879a9c90a56b85bee4216
cargo bench

Then observe that none of the bytes benches are ran.

This was fixed after stumbling upon this code during an ad hoc review:

Possible Solution(s)

Emit a warning when Rust sources use a cfg(feature = "...") attribute for a feature that cargo will never pass for the crate because it is not declared in Cargo.toml.

Notes

No response

Version

$ cargo --version --verbose
cargo 1.56.0 (4ed5d137b 2021-10-04)
release: 1.56.0
commit-hash: 4ed5d137baff5eccf1bae5a7b2ae4b57efad4a7d
commit-date: 2021-10-04
@lopopolo lopopolo added the C-bug Category: bug label Nov 19, 2021
@ehuss
Copy link
Contributor

ehuss commented Nov 19, 2021

Thanks for the suggestion! RFC 3013 has been accepted to implement this. You can follow the tracking issue at rust-lang/rust#82450 for updates.

@ehuss ehuss closed this as completed Nov 19, 2021
@lopopolo
Copy link
Author

ooo thank you. I looked in the cargo issues but didn't think to check the Rust repo. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants