-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add some hints to the docs for cfg()
targets
#6990
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Could you add a link to the conditional compilation docs? Probably just link the part above that says "#[cfg]
syntax" to ../reference/conditional-compilation.html
(generally use relative links between books here).
Also, can you delete the sentence about it "only been available since Cargo 0.9.0", that has long since passed.
If you want to know which cfg targets are used by the release profile, | ||
add the `-O` parameter. | ||
|
||
This same set of values is used throughout the build for all crates in your project, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused by how this is worded. Instead of trying to explain why it works this way, I would just be direct and say cfg(feature = "foo")
cannot be used in the [target]
table, with a link to the [features]
section. Similarly test
, proc-macro
, and debug-assertions
do not work either, though I'm not sure if it is worthwhile to list everything that does or does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not wanting to list all of the configuration options is the reason I tried to explain why it works this way. Between giving a mechanical explanation of why feature flags don't work, and pointing the user at --print=cfg
, I figured those would allow the user to figure out which options work and which options don't.
I stripped it out, though. Let me know if you can think of a better way to do this.
Thanks, I think it's fine. I pushed a commit with some additional fixes. @bors r+ |
📌 Commit 69f9adb has been approved by |
Add some hints to the docs for `cfg()` targets https://users.rust-lang.org/t/what-cfg-expressions-are-expected-to-work-in-cargo-toml-quoted-targets/28662
☀️ Test successful - checks-travis, status-appveyor |
Update cargo Update cargo 19 commits in 545f354259be4e9745ea00a524c0e4c51df01aa6..807429e1b6da4e2ec52488ef2f59e77068c31e1f 2019-05-23 17:45:30 +0000 to 2019-06-11 14:06:10 +0000 - Stabilize publish-lockfile. (rust-lang/cargo#7026) - change package cache lock message (rust-lang/cargo#7029) - Fix documenting an example. (rust-lang/cargo#7023) - Fix nonconcurrent tests (rust-lang/cargo#6900) - Update git2 crates for libgit2 0.28 (rust-lang/cargo#7018) - fix bunch of clippy warnings (rust-lang/cargo#7019) - Ignore remap-path-prefix in metadata hash. (rust-lang/cargo#6966) - Don't synthesize feature diretives for non-optional deps (rust-lang/cargo#7010) - Handle pipelined tests of libraries (rust-lang/cargo#7008) - Import the cargo-vendor subcommand into Cargo (rust-lang/cargo#6869) - Remove unnecessary outlives bounds (rust-lang/cargo#7000) - Catch filename output collisions in rustdoc. (rust-lang/cargo#6998) - the testing SAT solver was messed up by a refactor (rust-lang/cargo#6995) - Add some hints to the docs for `cfg()` targets (rust-lang/cargo#6990) - Test the Resolver against the varisat Library (rust-lang/cargo#6980) - Update changelog. (rust-lang/cargo#6984) - Update cache-messages tracking issue. (rust-lang/cargo#6987) - zsh: Add --all-targets option to cargo-check and cargo-build (rust-lang/cargo#6985) - Fix typo (rust-lang/cargo#6982)
Update cargo Update cargo 19 commits in 545f354259be4e9745ea00a524c0e4c51df01aa6..807429e1b6da4e2ec52488ef2f59e77068c31e1f 2019-05-23 17:45:30 +0000 to 2019-06-11 14:06:10 +0000 - Stabilize publish-lockfile. (rust-lang/cargo#7026) - change package cache lock message (rust-lang/cargo#7029) - Fix documenting an example. (rust-lang/cargo#7023) - Fix nonconcurrent tests (rust-lang/cargo#6900) - Update git2 crates for libgit2 0.28 (rust-lang/cargo#7018) - fix bunch of clippy warnings (rust-lang/cargo#7019) - Ignore remap-path-prefix in metadata hash. (rust-lang/cargo#6966) - Don't synthesize feature diretives for non-optional deps (rust-lang/cargo#7010) - Handle pipelined tests of libraries (rust-lang/cargo#7008) - Import the cargo-vendor subcommand into Cargo (rust-lang/cargo#6869) - Remove unnecessary outlives bounds (rust-lang/cargo#7000) - Catch filename output collisions in rustdoc. (rust-lang/cargo#6998) - the testing SAT solver was messed up by a refactor (rust-lang/cargo#6995) - Add some hints to the docs for `cfg()` targets (rust-lang/cargo#6990) - Test the Resolver against the varisat Library (rust-lang/cargo#6980) - Update changelog. (rust-lang/cargo#6984) - Update cache-messages tracking issue. (rust-lang/cargo#6987) - zsh: Add --all-targets option to cargo-check and cargo-build (rust-lang/cargo#6985) - Fix typo (rust-lang/cargo#6982)
Update cargo Update cargo 19 commits in 545f354259be4e9745ea00a524c0e4c51df01aa6..807429e1b6da4e2ec52488ef2f59e77068c31e1f 2019-05-23 17:45:30 +0000 to 2019-06-11 14:06:10 +0000 - Stabilize publish-lockfile. (rust-lang/cargo#7026) - change package cache lock message (rust-lang/cargo#7029) - Fix documenting an example. (rust-lang/cargo#7023) - Fix nonconcurrent tests (rust-lang/cargo#6900) - Update git2 crates for libgit2 0.28 (rust-lang/cargo#7018) - fix bunch of clippy warnings (rust-lang/cargo#7019) - Ignore remap-path-prefix in metadata hash. (rust-lang/cargo#6966) - Don't synthesize feature diretives for non-optional deps (rust-lang/cargo#7010) - Handle pipelined tests of libraries (rust-lang/cargo#7008) - Import the cargo-vendor subcommand into Cargo (rust-lang/cargo#6869) - Remove unnecessary outlives bounds (rust-lang/cargo#7000) - Catch filename output collisions in rustdoc. (rust-lang/cargo#6998) - the testing SAT solver was messed up by a refactor (rust-lang/cargo#6995) - Add some hints to the docs for `cfg()` targets (rust-lang/cargo#6990) - Test the Resolver against the varisat Library (rust-lang/cargo#6980) - Update changelog. (rust-lang/cargo#6984) - Update cache-messages tracking issue. (rust-lang/cargo#6987) - zsh: Add --all-targets option to cargo-check and cargo-build (rust-lang/cargo#6985) - Fix typo (rust-lang/cargo#6982)
https://users.rust-lang.org/t/what-cfg-expressions-are-expected-to-work-in-cargo-toml-quoted-targets/28662