-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Make cfg imply doc(cfg) #89596
Conversation
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.
720f695
to
6a31840
Compare
This comment has been minimized.
This comment has been minimized.
6a31840
to
edebce9
Compare
This comment has been minimized.
This comment has been minimized.
* Remove "bool_to_options" feature * Update version for compiler feature * rustfmt
edebce9
to
779091e
Compare
This comment has been minimized.
This comment has been minimized.
… they are not useful
779091e
to
09c7688
Compare
#[doc(cfg(), cfg(foo, bar))] | ||
//~^ ERROR | ||
//~^^ ERROR | ||
#[doc(cfg(foo), cfg(bar))] // ok! |
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.
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.
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.
This is valid and is supposed to work. I added it to ensure that rustdoc was happy with it.
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.
Might be better to put it into a rustdoc
test though. I'll do that.
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.
We actually already have a test for this: https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/doc-cfg.rs#L100
@bors r+ |
📌 Commit 09c7688 has been approved by |
Following rust-lang/rust#89596 it now docs all `cfg` attributes.
These are superfluous now rust-lang/rust#89596 has landed.
These are superfluous now rust-lang/rust#89596 has landed.
These are superfluous now rust-lang/rust#89596 has landed.
…, 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`
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
- bump up MSRV to 1.56.0 - remove explicit `#[doc(cfg(...))]` attribute usage where it's implied by `#[cfg(...)]` (rust-lang/rust#89596)
- bump up MSRV to 1.56.0 - remove explicit `#[doc(cfg(...))]` attribute usage where it's implied by `#[cfg(...)]` (rust-lang/rust#89596)
- bump up MSRV to 1.56.0 - remove explicit `#[doc(cfg(...))]` attribute usage where it's implied by `#[cfg(...)]` (rust-lang/rust#89596)
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 theCache
instead ofDocContext
becausecfg
information isn't stored anymore onclean::Attributes
type but instead computed on-demand, so we need this information in later parts of rustdoc.bool_to_options
feature (which makes the code a bit simpler to read forSingleExt
trait implementation.There is only one thing I couldn't figure out: this comment
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: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 adoc(cfg)
to render a message in the documentation.