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

Check for missing features in Cargo.toml #8070

Closed
elichai opened this issue Apr 5, 2020 · 2 comments
Closed

Check for missing features in Cargo.toml #8070

elichai opened this issue Apr 5, 2020 · 2 comments
Labels
A-features Area: features — conditional compilation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@elichai
Copy link

elichai commented Apr 5, 2020

Hi,
Right not as I understand it there's no real communication between rustc to cargo about what cfg features exist in the code, only the opposite(cargo passes --cfg flags to rustc).

But it would be a great feature IMHO to check somehow if there are any cfg features in the code that don't exist in the toml and produce a warning.

Example:
toml:

[package]
name = "Example"
version = "0.1.0"
authors = ["Elichai Turkel <elichai.turkel@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

main.rs:

#[cfg(feature = "binary")]
fn main() {
    println!("Hello, world!");
}

Real world example: rust-bitcoin/rust-secp256k1#199 A typo in a feature name, in cargo toml it was defined as external-symbols but in rust it was external_symbols

@elichai elichai added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Apr 5, 2020
@ehuss ehuss added the A-features Area: features — conditional compilation label Apr 15, 2020
@heisen-li
Copy link
Contributor

I'm sorry, I don't understand this very well. This is also checked for syntax or cfg in cargo? But as far as I know, the rust compiler does a check at compile time. What is the point of doing this?

@ehuss
Copy link
Contributor

ehuss commented Jul 6, 2021

I think the point is to check for typos and other mistakes, where the author writes the wrong cfg expressions.

I'm going to close this, as there is an accepted RFC to implemented this, see tracking issue rust-lang/rust#82450.

@ehuss ehuss closed this as completed Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-features Area: features — conditional compilation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

3 participants