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

Fix doc cfg on reexports #101006

Merged
merged 2 commits into from
Aug 26, 2022
Merged

Conversation

GuillaumeGomez
Copy link
Member

Fixes #83428.

The problem was that the newly inlined item cfg propagation was not working since its real parent is different than its current one.

For the implementation, I decided to put it directly into CfgPropagation instead of inside inline.rs because I thought it would be simpler to maintain and to not forget if new kind of items are added if it's all done in one place.

r? @notriddle

@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 25, 2022
@rustbot
Copy link
Collaborator

rustbot commented Aug 25, 2022

Some changes occurred in src/librustdoc/clean/types.rs

cc @camelid

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 25, 2022
@rust-log-analyzer

This comment has been minimized.

src/librustdoc/clean/types.rs Show resolved Hide resolved
let mut attrs = Vec::new();
for (parent_hir_id, _) in hir.parent_iter(hir_id) {
let def_id = hir.local_def_id(parent_hir_id).to_def_id();
attrs.extend_from_slice(load_attrs(self.cx, def_id));
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is going to wind up copying real cfg, and not just doc(cfg). Do we want that? The way libc uses re-exports, this seems like it would make their lives harder, not easier.

Copy link
Member Author

@GuillaumeGomez GuillaumeGomez Aug 25, 2022

Choose a reason for hiding this comment

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

We need to keep both until we call merge_attrs because it internally calls AttributesExt::cfg which makes the "filtering" depending on the doc_cfg and the doc_auto_cfg features (which is why it returns a tuple of two and not just a ast::Attributes).

Copy link
Contributor

Choose a reason for hiding this comment

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

But here's a screenshot of what the libc looks like, when it's built from nightly and #![feature(doc_auto_cfg)] is added:

image

And here's a screenshot of what libc looks like, when it's built from your branch and #![feature(doc_auto_cfg)] is added:

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry I'm a bit lost: isn't it how it should be? The reexports should display the cfg features of the reexported item, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

The docs are claiming things that aren't true:

image

This thing claims that c_short is present on Unix and absent on Windows. But c_short is definitely present on Windows; it's just implemented separately.

Basically, if this PR is going to be merged, then doc_auto_cfg should probably be off by default. Otherwise, a lot of crates with platform-specific implementations of common interfaces (libc is just a very high-profile example) are going to have wrong documentation.

Copy link
Member Author

@GuillaumeGomez GuillaumeGomez Aug 25, 2022

Choose a reason for hiding this comment

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

I don't agree on that but it confirms that allowing to disable/enable doc_auto_cfg is a must have.

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as we agree that doc_auto_cfg needs to be optional, I’m fine with merging this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this PR just highlighted it. The discussion now will be either it's enabled by default or not and what the attribute to enable/disable should look like.

@GuillaumeGomez
Copy link
Member Author

@bors: r=notriddle rollup

@bors
Copy link
Contributor

bors commented Aug 26, 2022

📌 Commit 2ed9454 has been approved by notriddle

It is now in the queue for this repository.

@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 Aug 26, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 26, 2022
…llaumeGomez

Rollup of 8 pull requests

Successful merges:

 - rust-lang#95005 (BTree: evaluate static type-related check at compile time)
 - rust-lang#99742 (Add comments about stdout locking)
 - rust-lang#100128 (Document that `RawWakerVTable` functions must be thread-safe.)
 - rust-lang#100956 (Reduce right-side DOM size)
 - rust-lang#101006 (Fix doc cfg on reexports)
 - rust-lang#101012 (rustdoc: remove unused CSS for `.variants_table`)
 - rust-lang#101023 (rustdoc: remove `type="text/css"` from stylesheet links)
 - rust-lang#101031 (Remove unused build dependency)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7cffb4c into rust-lang:master Aug 26, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 26, 2022
@GuillaumeGomez GuillaumeGomez deleted the doc-cfg-reexport branch August 26, 2022 22:00
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 28, 2022
…r=notriddle

[rustdoc] Remove Attrs type alias

When working on rust-lang#101006, I was quite confused because of this type alias as I'm used to having rustdoc types into `clean/types.rs`. Anyway, considering how few uses of it we have, I simply removed it.

r? `@notriddle`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 28, 2022
…r=notriddle

[rustdoc] Remove Attrs type alias

When working on rust-lang#101006, I was quite confused because of this type alias as I'm used to having rustdoc types into `clean/types.rs`. Anyway, considering how few uses of it we have, I simply removed it.

r? ``@notriddle``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 28, 2022
…r=notriddle

[rustdoc] Remove Attrs type alias

When working on rust-lang#101006, I was quite confused because of this type alias as I'm used to having rustdoc types into `clean/types.rs`. Anyway, considering how few uses of it we have, I simply removed it.

r? ```@notriddle```
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 28, 2022
…r=notriddle

[rustdoc] Remove Attrs type alias

When working on rust-lang#101006, I was quite confused because of this type alias as I'm used to having rustdoc types into `clean/types.rs`. Anyway, considering how few uses of it we have, I simply removed it.

r? ````@notriddle````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 29, 2022
…r=notriddle

[rustdoc] Remove Attrs type alias

When working on rust-lang#101006, I was quite confused because of this type alias as I'm used to having rustdoc types into `clean/types.rs`. Anyway, considering how few uses of it we have, I simply removed it.

r? `````@notriddle`````
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

rustdoc: doc_cfg hints not shown on reexports from private modules
6 participants