Skip to content

Commit

Permalink
Rollup merge of rust-lang#126356 - epage:check-cfg, r=Urgau
Browse files Browse the repository at this point in the history
docs(rustc): Improve discoverable of Cargo docs

In preparing Cargo's blog post for 1.80, I tried to find the documentation for the lint configuration and I couldn't.  The link is only visible from the lint itself, which isn't where I started, and the side bar, which was collapsed for me.

The first place I went was the docs for `unexpected_cfgs` because this is configuration for that lint.  If using lint configuration were a one off, I could see skipping it here.  However, when we discussed this with at least one T-compiler member, there was interest in using this for other lints in the future.  To that end, it seems like we should be exposing this with the lint itself.

The second place I checked was the `check-cfg` documentation.  This now has a call out for the sub-page.
  • Loading branch information
compiler-errors committed Jun 13, 2024
2 parents 93de3a3 + e171e64 commit 5523a20
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3257,7 +3257,11 @@ declare_lint! {
/// See the [Checking Conditional Configurations][check-cfg] section for more
/// details.
///
/// See the [Cargo Specifics][unexpected_cfgs_lint_config] section for configuring this lint in
/// `Cargo.toml`.
///
/// [check-cfg]: https://doc.rust-lang.org/nightly/rustc/check-cfg.html
/// [unexpected_cfgs_lint_config]: https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html#check-cfg-in-lintsrust-table
pub UNEXPECTED_CFGS,
Warn,
"detects unexpected names and values in `#[cfg]` conditions",
Expand Down
7 changes: 5 additions & 2 deletions src/doc/rustc/src/check-cfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ development process.
In order to accomplish that goal, `rustc` accepts the `--check-cfg` flag, which specifies
whether to check conditions and how to check them.

> **Note:** No implicit expectation is added when using `--cfg`. Users are expected to
pass all expected names and values using the _check cfg specification_.
> **Note:** For interacting with this through Cargo,
see [Cargo Specifics](check-cfg/cargo-specifics.md) page.

[^reachable]: `rustc` promises to at least check reachable `#[cfg]`, and while non-reachable
`#[cfg]` are not currently checked, they may well be checked in the future without it being a
Expand All @@ -23,6 +23,9 @@ breaking change.
To specify expected names and values, the _check cfg specification_ provides the `cfg(...)`
option which enables specifying for an expected config name and it's expected values.

> **Note:** No implicit expectation is added when using `--cfg`. Users are expected to
pass all expected names and values using the _check cfg specification_.

It has this basic form:

```bash
Expand Down

0 comments on commit 5523a20

Please sign in to comment.