Rollup merge of #131053 - Urgau:print-check-cfg-doc, r=jieyouxu

Improve `--print=check-cfg` documentation

This PR improves the `--print=check-cfg` documentation by:
 1. switching to a table for better readability
 2. adding a clear indication where the specific check-cfg syntax starts
 3. adding a link to the main `--check-cfg` documentation

`@rustbot` label +F-check-cfg
This commit is contained in:
Matthias Krüger 2024-09-30 18:25:15 +02:00 committed by GitHub
commit 8502e99217
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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. names and values.
This print option works similarly to `--print=cfg` (modulo check-cfg specifics): This print option works similarly to `--print=cfg` (modulo check-cfg specifics).
- *check_cfg syntax*: *output of --print=check-cfg*
- `cfg(windows)`: `windows` | `--check-cfg` | `--print=check-cfg` |
- `cfg(feature, values("foo", "bar"))`: `feature="foo"` and `feature="bar"` |-----------------------------------|-----------------------------|
- `cfg(feature, values(none(), ""))`: `feature` and `feature=""` | `cfg(foo)` | `foo` |
- `cfg(feature, values(any()))`: `feature=any()` | `cfg(foo, values("bar"))` | `foo="bar"` |
- `cfg(feature, values())`: `feature=` | `cfg(foo, values(none(), "bar"))` | `foo` & `foo="bar"` |
- `cfg(any())`: `any()` | | *check-cfg specific syntax* |
- *nothing*: `any()=any()` | `cfg(foo, values(any())` | `foo=any()` |
| `cfg(foo, values())` | `foo=` |
| `cfg(any())` | `any()` |
| *none* | `any()=any()` |
To be used like this: To be used like this:
```bash ```bash
rustc --print=check-cfg -Zunstable-options lib.rs rustc --print=check-cfg -Zunstable-options lib.rs
``` ```
[check-cfg]: https://doc.rust-lang.org/nightly/rustc/check-cfg.html