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

Reference doc on cfg does not cover cfg(feature = "...") #34803

Closed
dhardy opened this issue Jul 13, 2016 · 4 comments
Closed

Reference doc on cfg does not cover cfg(feature = "...") #34803

dhardy opened this issue Jul 13, 2016 · 4 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools

Comments

@dhardy
Copy link
Contributor

dhardy commented Jul 13, 2016

Rust appears to support #[cfg(feature = "foo")] to control optional features: Cargo doc.

The Rust reference on cfg does not mention feature: nightly doc.

@kennytm
Copy link
Member

kennytm commented Jul 15, 2016

Rust support #[cfg(anything)] when you pass --cfg anything to rustc. Cargo is just passing --cfg feature=foo to the compiler.

The documentation could be improved to mention the --cfg flag though.

@dhardy
Copy link
Contributor Author

dhardy commented Jul 18, 2016

Something's slightly odd with the doc though, because this says that the feature="foo" form is only allowed with compiler-defined configuration options, which means feature is compiler-defined.

@kennytm
Copy link
Member

kennytm commented Jul 18, 2016

Probably outdated, or the reference is misinterpreting the meaning of RFC 194. The following works:

fn main() {
    println!("{}", cfg!(a="b"));
}
$ rustc --cfg 'a="b"' 1.rs && ./1
true

@steveklabnik steveklabnik added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Mar 10, 2017
@steveklabnik
Copy link
Member

The reference has its own repo now, I have migrated this issue over there: rust-lang/reference#21 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

No branches or pull requests

3 participants