-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement RFC 3631: add rustdoc doc_cfg features #138907
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
Noted! And that will be a nice improvement, thanks! Just one thing left for the cfg expansion missing: |
Do you mean like in #138515? :) |
You're my hero! Gonna need to handle this new attribute then. :) |
4a05a52
to
3d2eef1
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #138923) made this pull request unmergeable. Please resolve the merge conflicts. |
d88598f
to
db25eea
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #138927) made this pull request unmergeable. Please resolve the merge conflicts. |
b8cb424
to
b581ce1
Compare
This comment has been minimized.
This comment has been minimized.
b581ce1
to
1cb7fac
Compare
This comment has been minimized.
This comment has been minimized.
71369a1
to
fbee8a9
Compare
This comment has been minimized.
This comment has been minimized.
Not sure why CI is failing on the GCC backend but seems unrelated to this PR. Anyway, the implementation is now complete and ready for review. \o/ r? @notriddle |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Just realized that the failure was actually a ui test... All fixed. |
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.
Haven't gotten to the meat of it yet, but one thing is (quoting from one of my comments below):
On second thought, I think I'd prefer we land the implementation of the new features without stabilizing doc_cfg/doc_auto_cfg. Then we can check that it behaves as expected and stabilize soon after. It just seems risky to change so much at the same time as stabilizing.
@@ -1346,10 +1386,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | |||
self.check_attr_crate_level(attr, meta, hir_id); | |||
} | |||
|
|||
sym::cfg_hide => { |
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.
Should we delete sym::cfg_hide
as well? Or is it used somewhere else?
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.
As far as I can see, it's not used anywhere else.
@@ -56,88 +56,6 @@ It is also not emitted for foreign items, aliases, extern crates and imports. | |||
These features operate by extending the `#[doc]` attribute, and thus can be caught by the compiler | |||
and enabled with a `#![feature(...)]` attribute in your crate. | |||
|
|||
### `#[doc(cfg)]`: Recording what platforms or features are required for code to be present |
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.
Shouldn't these docs be updated and moved to the stable part of the book instead of just deleted?
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.
On second thought, I think I'd prefer we land the implementation of the new features without stabilizing doc_cfg/doc_auto_cfg. Then we can check that it behaves as expected and stabilize soon after. It just seems risky to change so much at the same time as stabilizing.
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.
Erf. I suppose I badly rebased but it was supposed to be moved to the stable part.
And agreed on not stabilizing right away. One thing though: there are 3 features for this RFC, and cfg_hide
at least it not used anymore. So I'm gonna put them all behind doc_cfg
to make things easier.
e2804ec
to
bff747d
Compare
I put back the features behind the |
This comment has been minimized.
This comment has been minimized.
bff747d
to
1a0781f
Compare
☔ The latest upstream changes (presumably #139996) made this pull request unmergeable. Please resolve the merge conflicts. |
1a0781f
to
6298327
Compare
This comment has been minimized.
This comment has been minimized.
Rebased and replaced usage of removed |
Implementation of rust-lang/rfcs#3631.
This implementation actually resulted in a lot of simplifications:
cfg
computation is now done in one place:propagate_doc_cfg.rs
. Because (trait)impl
s are not retrieved at the same time as the other items, we cannot perform this computation in the clean process, it needs to be after.cfg
inheritance, we can keep track of them in one place (inpropagate_doc_cfg.rs
), meaning we don't need to copy an item's attributes to its children anymore. Only exception: impl items. For them we clone onlycfg
attributes.propagate_doc_cfg.rs
is also now much simpler, much less need to keep track of parents, since everything we need is handled by the newCfgInfo
type.Cfg::simplify_with
could either be removed or at least used directly intopropagate_doc_cfg.rs
when we computecfg
s. Considering how big the PR already is, I'll do it in a follow-up.I didn't remove the
doc_cfg*
features in this PR because some dependencies used inrustc
(likestdarch
) are using it, so we need to have a nightly released with this PR before I can switch to the new feature.r? ghost