Skip to content

Improve --print=check-cfg documentation #131053

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

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/doc/unstable-book/src/compiler-flags/print-check-cfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@ The tracking issue for this feature is: [#125704](https://github.com/rust-lang/r

------------------------

This option of the `--print` flag print the list of expected cfgs.
This option of the `--print` flag print the list of all the expected cfgs.

This is related to the `--check-cfg` flag which allows specifying arbitrary expected
This is related to the [`--check-cfg` flag][check-cfg] which allows specifying arbitrary expected
names and values.

This print option works similarly to `--print=cfg` (modulo check-cfg specifics):
- *check_cfg syntax*: *output of --print=check-cfg*
- `cfg(windows)`: `windows`
- `cfg(feature, values("foo", "bar"))`: `feature="foo"` and `feature="bar"`
- `cfg(feature, values(none(), ""))`: `feature` and `feature=""`
- `cfg(feature, values(any()))`: `feature=any()`
- `cfg(feature, values())`: `feature=`
- `cfg(any())`: `any()`
- *nothing*: `any()=any()`
This print option works similarly to `--print=cfg` (modulo check-cfg specifics).

| `--check-cfg` | `--print=check-cfg` |
|-----------------------------------|-----------------------------|
| `cfg(foo)` | `foo` |
| `cfg(foo, values("bar"))` | `foo="bar"` |
| `cfg(foo, values(none(), "bar"))` | `foo` & `foo="bar"` |
| | *check-cfg specific syntax* |
| `cfg(foo, values(any())` | `foo=any()` |
| `cfg(foo, values())` | `foo=` |
| `cfg(any())` | `any()` |
| *none* | `any()=any()` |

To be used like this:

```bash
rustc --print=check-cfg -Zunstable-options lib.rs
```

[check-cfg]: https://doc.rust-lang.org/nightly/rustc/check-cfg.html
Loading