Skip to content

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

@lopopolo

Description

@lopopolo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions