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

Make cfg imply doc(cfg) #89596

Merged
merged 7 commits into from
Oct 7, 2021
Merged

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Oct 6, 2021

This is a reopening of #79341, rebased and modified a bit (we made a lot of refactoring in rustdoc's types so they needed to be reflected in this PR as well):

  • hidden_cfg is now in the Cache instead of DocContext because cfg information isn't stored anymore on clean::Attributes type but instead computed on-demand, so we need this information in later parts of rustdoc.
  • I removed the bool_to_options feature (which makes the code a bit simpler to read for SingleExt trait implementation.
  • I updated the version for the feature.

There is only one thing I couldn't figure out: this comment

I think I'll likely scrap the whole SingleExt extension trait as the diagnostics for 0 and >1 items should be different.

How/why should they differ?

EDIT: this part has been solved, the current code was fine, just needed a little simplification.

cc @Nemo157
r? @jyn514

Original PR description:

This is only active when the doc_cfg feature is active.

The implicit cfg can be overridden via #[doc(cfg(...))], so e.g. to hide a #[cfg] you can use something like:

#[cfg(unix)]
#[doc(cfg(all()))]
pub struct Unix;

By adding #![doc(cfg_hide(foobar))] to the crate attributes the cfg #[cfg(foobar)] (and only that exact cfg) will not be implicitly treated as a doc(cfg) to render a message in the documentation.

Nemo157 and others added 5 commits October 5, 2021 17:25
This is only active when the `doc_cfg` feature is active.

The implicit cfg can be overridden via #[doc(cfg(...))], so e.g. to
hide a #[cfg] you can use something like:

```rust
 #[cfg(unix)]
 #[doc(cfg(all()))]
pub struct Unix;
```

(since `all()` is always true, it is never shown in the docs)
By adding #![doc(cfg_hide(foobar))] to the crate attributes the cfg
 #[cfg(foobar)] (and _only_ that _exact_ cfg) will not be implicitly
treated as a doc(cfg) to render a message in the documentation.
@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. F-doc_cfg `#![feature(doc_cfg)]` labels Oct 6, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

 * Remove "bool_to_options" feature
 * Update version for compiler feature
 * rustfmt
@rust-log-analyzer

This comment has been minimized.

#[doc(cfg(), cfg(foo, bar))]
//~^ ERROR
//~^^ ERROR
#[doc(cfg(foo), cfg(bar))] // ok!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be ignored, right, because you use single()? That doesn't seem right, either they should be ANDed or it should give a hard error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is valid and is supposed to work. I added it to ensure that rustdoc was happy with it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to put it into a rustdoc test though. I'll do that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 7, 2021
@GuillaumeGomez GuillaumeGomez added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 7, 2021
@jyn514
Copy link
Member

jyn514 commented Oct 7, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Oct 7, 2021

📌 Commit 09c7688 has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 7, 2021
Thomasdezeeuw added a commit to Thomasdezeeuw/heph that referenced this pull request Oct 10, 2021
Following rust-lang/rust#89596 it now docs all
`cfg` attributes.
eggyal added a commit to eggyal/rattish that referenced this pull request Oct 14, 2021
eggyal added a commit to eggyal/rattish that referenced this pull request Oct 14, 2021
eggyal added a commit to eggyal/rattish that referenced this pull request Oct 14, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 14, 2021
…, r=notriddle

Fix missing remaining compiler specific cfg information

Follow-up of rust-lang#89596. We forgot a few of them:

![Screenshot from 2021-10-14 11-36-44](https://user-images.githubusercontent.com/3050060/137292700-64ebc59f-d9d2-41f2-be3a-fa5bf211523c.png)
![Screenshot from 2021-10-14 11-36-56](https://user-images.githubusercontent.com/3050060/137292703-f63fa4e5-2c56-446b-9f86-3652f03dfe59.png)

r? `@notriddle`
arqunis added a commit to serenity-rs/serenity that referenced this pull request Oct 16, 2021
This removes all uses of the `#[doc(cfg(...))]` attribute. The purpose of this
attribute was to tell `rustdoc` to add an annotation, which would inform users
what features an item (module, struct, trait, method, etc.) needed. However, in
the latest Nightly, [this attribute is implicit when `#![feature(doc_cfg)]` is
enabled][rust-pr]. Thus, our usage of this attribute is unnecessary and we can
remove it.

[rust-pr]: rust-lang/rust#89596
tyranron added a commit to cucumber-rs/cucumber that referenced this pull request Oct 25, 2021
- bump up MSRV to 1.56.0
- remove explicit `#[doc(cfg(...))]` attribute usage where it's implied by `#[cfg(...)]` (rust-lang/rust#89596)
tyranron added a commit to cucumber-rs/cucumber that referenced this pull request Oct 25, 2021
- bump up MSRV to 1.56.0
- remove explicit `#[doc(cfg(...))]` attribute usage where it's implied by `#[cfg(...)]` (rust-lang/rust#89596)
tyranron added a commit to cucumber-rs/cucumber that referenced this pull request Oct 25, 2021
- bump up MSRV to 1.56.0
- remove explicit `#[doc(cfg(...))]` attribute usage where it's implied by `#[cfg(...)]` (rust-lang/rust#89596)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-doc_cfg `#![feature(doc_cfg)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants